mini-infrabayes && use full oeis after switching to use danger compilation
danger compilation really increases speed
This commit is contained in:
parent
98d982066c
commit
32e8a32e4c
Binary file not shown.
|
@ -32,8 +32,8 @@ proc findIndex(xs: seq[string], y: string): int =
|
||||||
return -1
|
return -1
|
||||||
|
|
||||||
## Get sequences
|
## Get sequences
|
||||||
let file_path = "../data/one_to_three"
|
## let file_path = "../data/one_to_three"
|
||||||
## let file_path = "../data/stripped"
|
let file_path = "../data/stripped"
|
||||||
proc getOEIS(): seq[seq[string]] =
|
proc getOEIS(): seq[seq[string]] =
|
||||||
let f = open(file_path)
|
let f = open(file_path)
|
||||||
var i = 0
|
var i = 0
|
||||||
|
@ -102,7 +102,7 @@ proc predictContinuationWithTruncatedHypotheses(seqs: seq[seq[string]], start: s
|
||||||
let truncated_seqs = seqs[0..<n]
|
let truncated_seqs = seqs[0..<n]
|
||||||
return predictContinuation(truncated_seqs, start)
|
return predictContinuation(truncated_seqs, start)
|
||||||
|
|
||||||
proc showPredictionsWithMoreHypotheses(seqs: seq[seq[string]], start: seq[string]) =
|
proc showPredictionsWithIncreasinglyManyHypotheses(seqs: seq[seq[string]], start: seq[string]) =
|
||||||
echo "Showing predictions with increasingly many hypotheses after seeing ", start
|
echo "Showing predictions with increasingly many hypotheses after seeing ", start
|
||||||
let l = seqs.len
|
let l = seqs.len
|
||||||
for i in 1..10:
|
for i in 1..10:
|
||||||
|
@ -111,7 +111,7 @@ proc showPredictionsWithMoreHypotheses(seqs: seq[seq[string]], start: seq[string
|
||||||
let predictions = predictContinuationWithTruncatedHypotheses(seqs, start, n)
|
let predictions = predictContinuationWithTruncatedHypotheses(seqs, start, n)
|
||||||
print predictions
|
print predictions
|
||||||
|
|
||||||
## showPredictionsWithMoreHypotheses()
|
## showPredictionsWithIncreasinglyManyHypotheses()
|
||||||
|
|
||||||
proc jitBayesLoop(
|
proc jitBayesLoop(
|
||||||
seqs: seq[seq[string]],
|
seqs: seq[seq[string]],
|
||||||
|
@ -163,6 +163,24 @@ proc jitBayesLoop(
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
|
## Infrabayesianism
|
||||||
|
|
||||||
|
proc miniInfraBayes(
|
||||||
|
seqs: seq[seq[string]],
|
||||||
|
observations: seq[string],
|
||||||
|
utility_function: string
|
||||||
|
) =
|
||||||
|
if utility_function != "logloss":
|
||||||
|
echo "miniInfraBayes function only programmed for the logloss utility function"
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
echo "## Mini-infra-bayesianism over environments, where your utility in an environment is just the log-loss in the predictions you make until you become certain that you are in that environment."
|
||||||
|
|
||||||
|
let l = observations.len
|
||||||
|
for i in 0..<l: # to do: make so that this can start at 0.
|
||||||
|
let predictions = predictContinuation(seqs, observations[0..<i]) ## See the README for why this ends up being equivalent.
|
||||||
|
|
||||||
|
|
||||||
## Infrabayesianism. Part 1: Have hypotheses over just part of the world.
|
## Infrabayesianism. Part 1: Have hypotheses over just part of the world.
|
||||||
|
|
||||||
|
|
||||||
|
@ -182,11 +200,11 @@ echo ""
|
||||||
|
|
||||||
echo "## Predictions with increasingly many hypotheses"
|
echo "## Predictions with increasingly many hypotheses"
|
||||||
observations = @["1", "2", "3", "23"]
|
observations = @["1", "2", "3", "23"]
|
||||||
showPredictionsWithMoreHypotheses(seqs, observations)
|
showPredictionsWithIncreasinglyManyHypotheses(seqs, observations)
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
observations = @["1", "2", "3", "23", "11", "18", "77", "46", "84"]
|
observations = @["1", "2", "3", "23", "11", "18", "77", "46", "84"]
|
||||||
jitBayesLoop(seqs, observations, 3, 1_000, 2_000)
|
jitBayesLoop(seqs, observations, 3, 1_000, 30_000)
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user