fix: miniInfraBayes with interleaved sequence errors.
This commit is contained in:
parent
ef34fb34fa
commit
c92d46ed92
Binary file not shown.
|
@ -163,7 +163,7 @@ proc jitBayesLoop(
|
|||
|
||||
## Infrabayesianism
|
||||
|
||||
proc miniInfraBayes(
|
||||
proc miniInfraBayesArgminMaxLoss(
|
||||
seqs: seq[seq[string]],
|
||||
observations: seq[string],
|
||||
n_observations_seen: int,
|
||||
|
@ -195,18 +195,29 @@ proc miniInfraBayes(
|
|||
proc getEvens(xs: seq[string]): seq[string] =
|
||||
var evens: seq[string]
|
||||
for i,x in xs:
|
||||
if i%2 == 0:
|
||||
if i mod 2 == 0:
|
||||
evens.add(x)
|
||||
return evens
|
||||
|
||||
proc getOdds(xs: seq[string]): seq[string] =
|
||||
var odds: seq[string]
|
||||
for i,x in xs:
|
||||
if i%2 == 1:
|
||||
if i mod 2 == 1:
|
||||
odds.add(x)
|
||||
return odds
|
||||
|
||||
proc miniInfraBayes2(
|
||||
proc interleave(xs: seq[string], ys: seq[string]): seq[string] =
|
||||
if xs.len != ys.len:
|
||||
echo "Interleaved sequences have to have the same length; returning empty sequence."
|
||||
return @[]
|
||||
else:
|
||||
var zs: seq[string]
|
||||
for i in 0..<xs.len:
|
||||
zs.add(xs[i])
|
||||
zs.add(ys[i])
|
||||
return zs
|
||||
|
||||
proc miniInfraBayesArgminMaxLossInterleavedHypotheses(
|
||||
seqs: seq[seq[string]],
|
||||
observations: seq[string],
|
||||
n_observations_seen: int,
|
||||
|
@ -218,10 +229,10 @@ proc miniInfraBayes2(
|
|||
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. This time with a twist: You don't have hypotheses over the sequences you observe, but rather over their odd and even position, i.e., you think that you observe interleaved OEIS sequences, (a1, b1, a2, b2, a3, b3). See the README.md for more."
|
||||
|
||||
var losses: seq[float]g
|
||||
var losses: seq[float]
|
||||
for i in n_observations_seen..<observations.len:
|
||||
var parity_subsequence: seq[string]
|
||||
if i % 2 == 0:
|
||||
if i mod 2 == 0:
|
||||
parity_subsequence = getEvens(observations[0..<i])
|
||||
else:
|
||||
parity_subsequence = getOdds(observations[0..<i])
|
||||
|
@ -262,5 +273,9 @@ jitBayesLoop(seqs, observations, 3, 1_000, 30_000)
|
|||
echo ""
|
||||
|
||||
observations = @["1", "2", "3", "23", "11", "18", "77", "46", "84"]
|
||||
miniInfraBayes(seqs, observations, 3, "logloss")
|
||||
miniInfraBayesArgminMaxLoss(seqs, observations, 3, "logloss")
|
||||
echo ""
|
||||
|
||||
observations = interleave(@["1", "2", "3", "23", "11", "18", "77", "46", "84"], @["2", "11", "13", "23", "47", "59", "71", "83", "107"])
|
||||
miniInfraBayesArgminMaxLossInterleavedHypotheses(seqs, observations, 6, "logloss")
|
||||
echo ""
|
||||
|
|
Loading…
Reference in New Issue
Block a user