mini-infrabayes && use full oeis after switching to use danger compilation

danger compilation really increases speed
This commit is contained in:
NunoSempere 2023-05-24 17:35:46 -07:00
parent 98d982066c
commit 32e8a32e4c
2 changed files with 24 additions and 6 deletions

Binary file not shown.

View File

@ -32,8 +32,8 @@ proc findIndex(xs: seq[string], y: string): int =
return -1
## Get sequences
let file_path = "../data/one_to_three"
## let file_path = "../data/stripped"
## let file_path = "../data/one_to_three"
let file_path = "../data/stripped"
proc getOEIS(): seq[seq[string]] =
let f = open(file_path)
var i = 0
@ -102,7 +102,7 @@ proc predictContinuationWithTruncatedHypotheses(seqs: seq[seq[string]], start: s
let truncated_seqs = seqs[0..<n]
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
let l = seqs.len
for i in 1..10:
@ -111,7 +111,7 @@ proc showPredictionsWithMoreHypotheses(seqs: seq[seq[string]], start: seq[string
let predictions = predictContinuationWithTruncatedHypotheses(seqs, start, n)
print predictions
## showPredictionsWithMoreHypotheses()
## showPredictionsWithIncreasinglyManyHypotheses()
proc jitBayesLoop(
seqs: seq[seq[string]],
@ -163,6 +163,24 @@ proc jitBayesLoop(
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.
@ -182,11 +200,11 @@ echo ""
echo "## Predictions with increasingly many hypotheses"
observations = @["1", "2", "3", "23"]
showPredictionsWithMoreHypotheses(seqs, observations)
showPredictionsWithIncreasinglyManyHypotheses(seqs, observations)
echo ""
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 ""