Route model: correct for reporting bias
- core/atlas/bias.py: for each rare roll (shadow, meadow Blue) and each source group, the factor by which the group over-reports the rare outcome relative to complete logging (bot, bulk logs), with a 90% range; rare outcomes from biased groups count 1/rho; a roll the complete logs have (almost) never shown is learned from them only - planner/policy.yaml: groups, rolls and thresholds; estimates published in policy.json under model.reportingBias - fit_alpha: a roll seen only one way is pooled fully - docs: goal accounts follow the best route, research accounts use Thompson sampling (decisionMode atlas_thompson) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
c0355616b6
commit
2271fe0976
+13
-4
@@ -311,12 +311,18 @@ def summarise(xs):
|
||||
|
||||
# ---------------------------------------------------------------- the published policy
|
||||
|
||||
def build_policy(runs, draws=200, seed=20261101, min_support=None, alpha=None, colours=None):
|
||||
"""The full policy for every colour. runs: coded runs (atlas.coding), as dicts."""
|
||||
def build_policy(runs, draws=200, seed=20261101, min_support=None, alpha=None, colours=None, bias_config=None):
|
||||
"""The full policy for every colour. runs: coded runs (data/public/runs_clean.csv), as dicts. bias_config:
|
||||
planner/policy.yaml `reporting_bias` (None: every run counts as reported)."""
|
||||
colours = colours or model.COLOURS
|
||||
min_support = G["min_support"] if min_support is None else min_support
|
||||
prepared = [model.prepare_run(r) for r in runs]
|
||||
T = model.count_tables(prepared)
|
||||
bias_est, w = None, None
|
||||
if bias_config:
|
||||
from . import bias
|
||||
bias_est, names = bias.estimate(runs, prepared, bias_config, set(model.RARE_GOALS))
|
||||
w = bias.weights(names, prepared, bias_est, bias_config["rolls"])
|
||||
T = model.count_tables(prepared, w)
|
||||
support, counts = model.support_from(prepared, min_support)
|
||||
fitted = {k: model.fit_alpha(T, k) for k in model.CHANCE}
|
||||
alphas = {k: alpha for k in model.CHANCE} if alpha else {k: f["alpha"] for k, f in fitted.items()}
|
||||
@@ -325,7 +331,8 @@ def build_policy(runs, draws=200, seed=20261101, min_support=None, alpha=None, c
|
||||
# Cross-fitting: choose the policy on one random half of the runs and score it on the other half.
|
||||
r = model.Rng(seed)
|
||||
fold = [0 if r() < 0.5 else 1 for _ in prepared]
|
||||
halves = [model.count_tables([v for v, f in zip(prepared, fold) if f == h]) for h in (0, 1)]
|
||||
halves = [model.count_tables([v for v, f in zip(prepared, fold) if f == h],
|
||||
[x for x, f in zip(w, fold) if f == h] if w else None) for h in (0, 1)]
|
||||
half_params = [model.Params(Th, "mean", alphas=alphas) for Th in halves]
|
||||
|
||||
targets = {}
|
||||
@@ -366,6 +373,8 @@ def build_policy(runs, draws=200, seed=20261101, min_support=None, alpha=None, c
|
||||
"chanceContext": {k: s["context"] for k, s in model.CHANCE.items()},
|
||||
"decisions": model.DECISIONS, "support": support, "supportCounts": counts,
|
||||
"tables": T,
|
||||
# how much each kind of source over-reports each rare roll, and the correction applied (bias.py)
|
||||
"reportingBias": bias_est,
|
||||
# the game itself (core/spec/game.yaml), so the advisor in core/solver.js can re-solve from any point
|
||||
"game": {k: G[k] for k in ("version", "colours", "decisions", "chance", "encounters", "encounter_outcomes",
|
||||
"by_colour", "start", "steps", "from_form", "bot_text")},
|
||||
|
||||
Reference in New Issue
Block a user