Treat unsure and blank answers as missing information, not choices
- engine.js / analyze.py: one MISSING set ("Unknown", "Unsure",
"Unsure/unknown", "Multiple", "(not recorded)", "(not asked)", ...).
Factor tables compare only runs that answered each question and report how
many were left out; models are complete-case for every choice variable;
route rankings group only fully known routes; the route flow skips
missing steps.
- "I've lost count" now counts as a later attempt.
- The chase goal keeps its "not asked" stratum as an adjustment only; it is
no longer displayed as a finding.
- Page: no unknown levels in charts, tables or filters; factor explorer notes
how many runs were left out; Methods explains the rule.
JS/Python parity still exact.
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
de80e99c74
commit
1b0ef9a2c1
@@ -15,6 +15,13 @@ import pandas as pd
|
||||
from stats_core import Z95, bh, logistic_ridge, odds_ratio, p_from_z, wilson
|
||||
|
||||
COLORS = ["Red", "Green", "Orange", "Brown", "Blue", "Black"]
|
||||
# answers with no information about the choice: treated as missing everywhere (mirrors MISSING in engine.js)
|
||||
MISSING = {"Unknown", "Unsure", "Unsure/unknown", "Multiple", "(not recorded)", "(not asked)",
|
||||
"(not asked/blank)", "Unknown/lost count", "Blank/not asked"}
|
||||
|
||||
|
||||
def is_missing(v):
|
||||
return v is None or (isinstance(v, float) and v != v) or v == "" or v in MISSING
|
||||
FACTORS = ["company", "direction", "first_sighting", "scream", "resolution", "combat_first",
|
||||
"post_path", "hour", "wing", "squad", "attempt_group", "source", "goal", "sighting_action", "combat_second", "malek_intent"]
|
||||
|
||||
@@ -47,7 +54,7 @@ def factor_table(d, key, min_n=5):
|
||||
D["_e"] = ev(D).astype(bool)
|
||||
rows = []
|
||||
for f in FACTORS:
|
||||
sub = D[D[f].notna()]
|
||||
sub = D[D[f].notna() & ~D[f].isin(MISSING)]
|
||||
nf, ef = len(sub), int(sub._e.sum())
|
||||
for lv in sorted(sub[f].astype(str).unique()):
|
||||
g = sub[sub[f].astype(str) == lv]
|
||||
@@ -99,7 +106,11 @@ def src2(r):
|
||||
|
||||
|
||||
def first2(r):
|
||||
return r.first_sighting if r.first_sighting in ("Red", "Brown", "Orange", "Green") else "Unsure/unknown"
|
||||
return r.first_sighting if r.first_sighting in ("Red", "Brown", "Orange", "Green") else None
|
||||
|
||||
|
||||
def known(f):
|
||||
return lambda r: None if is_missing(r[f]) else r[f]
|
||||
|
||||
|
||||
def period(r):
|
||||
@@ -112,13 +123,13 @@ def analyse(d):
|
||||
res = {"n": len(d), "factors": {k: factor_table(d, k) for k in OUT}}
|
||||
res["models"] = {
|
||||
"blue_meadow": model(d, "blue_meadow", {
|
||||
"source": src2, "goal": goal2, "direction": lambda r: r.direction, "first_sighting": first2,
|
||||
"resolution": lambda r: r.resolution, "company": lambda r: None if r.company == "Unknown" else r.company}),
|
||||
"source": src2, "goal": goal2, "direction": known("direction"), "first_sighting": first2,
|
||||
"resolution": known("resolution"), "company": known("company")}),
|
||||
"shadow": model(d, "shadow", {
|
||||
"source": src2, "goal": goal2, "attempt": lambda r: r.attempt_group,
|
||||
"direction": lambda r: r.direction}),
|
||||
"source": src2, "goal": goal2, "attempt": known("attempt_group"),
|
||||
"direction": known("direction")}),
|
||||
"bond_blue_meadow": model(d, "bond_blue_meadow", {
|
||||
"source": src2, "goal": goal2, "direction": lambda r: r.direction, "resolution": lambda r: r.resolution}),
|
||||
"source": src2, "goal": goal2, "direction": known("direction"), "resolution": known("resolution")}),
|
||||
}
|
||||
return res
|
||||
|
||||
|
||||
@@ -352,7 +352,8 @@ def code_row(r, C):
|
||||
return {
|
||||
"source": source, "date": date, "wing": wing, "section": section,
|
||||
"squad": g("squad") or "Unknown", "attempt": attempt,
|
||||
"attempt_group": "First attempt" if attempt == 1 else ("Later attempt" if attempt and attempt > 1 else "Unknown/lost count"),
|
||||
# "I've lost count" means many attempts, so it is a later attempt, not missing
|
||||
"attempt_group": "First attempt" if attempt == 1 else ("Later attempt" if (attempt and attempt > 1) or "lost count" in (g("attempt") or "").lower() else "Unknown"),
|
||||
"goal": goal, "company": company, "left_squadmates": left_squad,
|
||||
"direction": direction, "first_sighting": first or "Unknown",
|
||||
"sighting_action": (SIGHTING_ACTION.get(g("sighting_action")) or g("sighting_action") or "Unknown") if "sighting_action" in C else "(not asked)",
|
||||
|
||||
Reference in New Issue
Block a user