AsianPlayer/TriDrive / code /eval /report_final_udwm.py
AsianPlayer's picture
download
raw
23.9 kB
"""cwm3/eval/report_final_udwm.py — results/tables/stage_final_udwm.md: owner experiment C (pre-registration docs/decisions.md 2026-09-17T07:00:22Z part (C)):
the Driver-WM temporal encoder (aide/models/driverwm_kp.py internal stream, PUBLISHED width, NOT parameter-matched) as the BATON driver branch (models/u_driverwm.py,
variant `kin_can_noK_clip8_ln_udwm` = the FINAL U recipe / targets), joint `I1_all_minus_road2drv_s<k>_final_udwm` = the FINAL command line with only the U base swapped.
Composes eval/report_joint.py blocks (load / render / verdict / claim / provenance) from results/paired_compare.csv; nothing is recomputed here; every number comes
from the CSV rows written by eval/run_joint_evals_final_udwm.sh (eval/pc_joint_locked.py, n_boot 1000 device-cluster resamples, identical rows, v2 causal kin targets).
python eval/report_final_udwm.py [--seeds 0,1,2] [--out results/tables/stage_final_udwm.md]
Blocks (tags): finalc_s<k>_allminusudwm_vs_allminus (a) the pre-registered Table 3 comparison: udwm main vs the FROZEN main, TEST split
finalcv_s<k>_allminusudwm_vs_allminus (a-val) the same on the VALIDATION split (descriptive; no adoption decision is attached to this experiment)
finalc_s<k>_allminusudwm_vs_indepudwm (b) interaction effect on the udwm bases (B2-style)
finalc_s<k>_indepudwm_vs_indep (c) the U-base swap alone (assembled bases, no training)
finalP_s<k>_{allminusudwm_vs_allminus, allminusudwm_vs_indepudwm, indepudwm_vs_indep} P road cells (eval/pressure_eval.py)
PRE-REGISTERED READING (this renderer was written before any udwm pairing existed): cells = the four REPORTED driver cells (manual hand_leave / hand_return /
head_turn_onset, engaged head_turn_onset; the engaged hand cells are computed and shown but marked 'not reported' — label-quality caveat, Supp E), the vehicle cells
(gas / brake / steer_phase onset, both regimes), the D / P road cells and the hazard-NLL costs; verdict per cell = kill_checks.beats (>= 2/3 seeds with the paired CI
excluding 0, same sign, |mean Δ| > seed sd -> BEATS / WORSE; NOT_WORSE / INCONCLUSIVE otherwise; INSUFFICIENT < 3 seeds). Placement = a row in Table 3 REGARDLESS
of direction; the parameter counts (GRU U 159,314 incl. encoder 56,832 vs the Driver-WM trunk) are printed with the row; the variant never replaces the headline
by itself. Also writes results/tables/stage_final_udwm_decision.json. No openpilot DMS field is read.
"""
from __future__ import annotations
import argparse
import json
import sys
from pathlib import Path
import numpy as np
import pandas as pd
CWM3 = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(CWM3 / "eval"))
import report_joint as RJ # noqa: E402
RUNS = CWM3 / "results" / "runs"
EV = ("hand_leave", "hand_return", "head_turn_onset")
REPORTED = [("manual", "drv_onset|hand_leave|3s"), ("manual", "drv_onset|hand_return|3s"), ("manual", "drv_onset|head_turn_onset|3s"), ("engaged", "drv_onset|head_turn_onset|3s")]
NOT_REPORTED = [("engaged", "drv_onset|hand_leave|3s"), ("engaged", "drv_onset|hand_return|3s")]
VEH_EV = ("gas_on", "brake_on", "steer_phase_on")
VEH = [f"veh_onset|{e}|3s" for e in VEH_EV]
ROAD_D = [f"d_onset|{f}|3s" for f in ("steer_rate", "decel", "ttc", "ttc_drop", "lane", "badas")]
ROAD_P = [f"p_onset|{f}|3s" for f in ("ttc", "ttc_drop", "cut_in", "lead_braking", "lane_excursion", "badas")]
NLL_DRV = [f"hazard_nll|{e}" for e in EV]
NLL_VEH = [f"hazard_nll|{e}" for e in VEH_EV]
NLL_ROAD = [f"hazard_nll|D_{f}" for f in ("steer_rate", "decel", "ttc", "ttc_drop", "lane", "badas")]
U_DIR, U_DIR_REF = "U0_kin_can_noK_s{k}_kcv2_clip8_ln_udwm", "U0_kin_can_noK_s{k}_kcv2_clip8_ln"
J_DIR, J_DIR_REF = "I1_all_minus_road2drv_s{k}_final_udwm", "I1_all_minus_road2drv_s{k}_final"
I_DIR, I_DIR_REF = "I1_indep_s{k}_final_udwm", "I1_indep_s{k}_final"
def block(stage, a, b, claim, title, seeds):
df = RJ.load(stage, a, b, seeds)
if not len(df):
return df, [f"### {title}: A = {a}, B = {b} — no rows yet (tags `{stage}_s<k>_{a}_vs_{b}`)", ""], {}, ("NO ROWS", [], [], [])
body, verdicts = RJ.render(df, sorted(df.seed.unique()), a, b, title)
return df, body, verdicts, RJ.claim(verdicts, claim)
def ms(v, nd=4):
v = [float(x) for x in v if str(x) not in ("", "nan")]
return "—" if not v else (f"{np.mean(v):.{nd}f} ± {np.std(v, ddof=1):.{nd}f}" if len(v) > 1 else f"{v[0]:.{nd}f}")
def fmt(ks):
return [f"{r}|{c}" + (f"|{m}" if m != "pr_auc" else "") for (r, c, m) in ks] or "none"
def cell_table(df, verdicts, title, spec, note=None):
"""spec = [(regime, cell, metric, status_label)]: A (udwm) / B per seed, Δ [CI] per seed, mean Δ ± sd, verdict, reporting status."""
lines = [f"### {title}", ""] + ([note, ""] if note else []) + \
["| regime | cell | metric | A (udwm) per seed | B per seed | Δ per seed [CI] | Δ mean ± sd | verdict (≥ 2/3 rule) | reporting |", "|---|---|---|---|---|---|---|---|---|"]
out = {}
for r, cell, metric, status in spec:
g = df[(df.regime == r) & (df.cell == cell) & (df.metric == metric)].sort_values("seed") if len(df) else pd.DataFrame()
if not len(g):
lines.append(f"| {r} | {cell.replace('|', '/')} | {metric} | — | — | no rows | | | {status} |")
continue
v = verdicts.get((r, cell, metric), {"verdict": "—"})
lb = cell.startswith(RJ.LOWER_BETTER)
A = " / ".join(f"{float(x):.4f}" for x in g.value_a)
B = " / ".join(f"{float(x):.4f}" for x in g.value_b)
D = " / ".join(f"{float(x.delta):+.4f} [{float(x.delta_ci_lo):+.4f},{float(x.delta_ci_hi):+.4f}]" for x in g.itertuples())
d = g.delta.astype(float).to_numpy()
sd = d.std(ddof=1) if len(d) > 1 else 0.0
out[(r, cell, metric)] = {"verdict": v["verdict"], "mean_delta": float(d.mean()), "sd_delta": float(sd), "n_seeds": int(len(d)),
"a": [float(x) for x in g.value_a], "b": [float(x) for x in g.value_b],
"ci": [[float(x.delta_ci_lo), float(x.delta_ci_hi)] for x in g.itertuples()], "reporting": status}
lines.append(f"| {r} | {cell.replace('|', '/')} | {metric}{' (lower better)' if lb else ''} | {A} | {B} | {D} | {d.mean():+.4f} ± {sd:.4f} | {v['verdict']} | {status} |")
return lines + [""], out
def spec_onset(cells_by_regime, status):
return [(r, c, "pr_auc", status) for r, c in cells_by_regime]
def spec_both(cells, metric, status):
return [(r, c, metric, status) for r in ("manual", "engaged") for c in cells]
def _json(p):
try:
return json.loads(Path(p).read_text())
except Exception:
return None
def _latest_run_json(rd, prefix):
c = sorted(Path(rd).glob(f"{prefix}*_latest.json"))
return _json(c[0]) if c else None
def param_counts():
"""the exact module sizes (built on CPU under the paired seed), cross-checked with what the run dirs recorded."""
rows, js = [], {}
try:
sys.path.insert(0, str(CWM3)); sys.path.insert(0, str(CWM3 / "train"))
import torch # noqa: F401
from models import build_branch
import train_cwm3 as T
dwm = build_branch("U", 0, **T.model_kwargs(T.stage_cfg("U0", "kin_can_noK_clip8_ln_udwm")))
gru = build_branch("U", 0, **T.model_kwargs(T.stage_cfg("U0", "kin_can_noK_clip8_ln")))
n = lambda m: sum(p.numel() for p in m.parameters())
ai = dwm.arch_info
js = {"dwm_branch_total": n(dwm), "dwm_encoder": ai["encoder_params"], "dwm_encoder_parts": ai["encoder_parts"], "gru_branch_total": n(gru),
"gru_encoder": n(gru.gru), "ratio_encoder": round(ai["encoder_params"] / n(gru.gru), 1), "ratio_branch": round(n(dwm) / n(gru), 1),
"arch": {k: ai[k] for k in ("d_int", "heads", "d_ff", "layers", "transition", "parameter_matched", "source")}}
rows += ["| module | GRU U (frozen main) | Driver-WM U (udwm) | ratio |", "|---|---|---|---|",
f"| sequence encoder (trunk) | {n(gru.gru):,} (GRU 18 -> 128) | {ai['encoder_params']:,} (tok {ai['encoder_parts']['tok']:,} + pre_int {ai['encoder_parts']['pre_int']:,} + f_int {ai['encoder_parts']['f_int']:,} + proj {ai['encoder_parts']['proj']:,}) | x {js['ratio_encoder']} |",
f"| whole U branch (encoder + input LN + mode emb + flat head) | {n(gru):,} | {n(dwm):,} | x {js['ratio_branch']} |",
f"| architecture | GRU(18 -> 128), 1 layer | TransformerEncoderLayer(d {ai['d_int']}, {ai['heads']} heads, d_ff {ai['d_ff']}, {ai['layers']} layer, causal mask) + f_int res-MLP (transition {ai['transition']}) + LN + Linear(1024 -> 128) | published width; NOT parameter-matched |"]
except Exception as e: # pragma: no cover
rows += [f"(module sizes not built: {e})"]
rec = []
for k in (0, 1, 2):
u = _latest_run_json(RUNS / U_DIR.format(k=k), "run_train_U0")
j = _json(RUNS / J_DIR.format(k=k) / "params.json")
jr = _json(RUNS / J_DIR_REF.format(k=k) / "params.json")
rec.append({"seed": k, "U0_params_total": (u or {}).get("params", {}).get("total"), "joint_U_total": ((j or {}).get("U") or {}).get("total"),
"joint_total": (j or {}).get("total"), "joint_total_frozen": (jr or {}).get("total")})
js["recorded"] = rec
rows += ["", "Recorded by the runs: " + "; ".join(f"s{r['seed']}: U0 total {r['U0_params_total']}, joint U {r['joint_U_total']}, joint total {r['joint_total']} (frozen {r['joint_total_frozen']})" for r in rec)]
return rows, js
def training_summary():
"""epochs / BEST / validation objective / wall of every udwm run next to its frozen counterpart; GPU minutes = sum of wall_s (single-GPU, exclusive per job)."""
lines = ["| run | epochs (BEST) | val objective | frozen counterpart | epochs (BEST) | val objective | wall s |", "|---|---|---|---|---|---|---|"]
tot, js, missing = 0.0, [], []
for k in (0, 1, 2):
for d, dref, pre in ((U_DIR, U_DIR_REF, "run_train_U0"), (J_DIR, J_DIR_REF, "run_train_I1"), (I_DIR, I_DIR_REF, "run_train_I1")):
rd, rr = RUNS / d.format(k=k), RUNS / dref.format(k=k)
a, b = _latest_run_json(rd, pre), _latest_run_json(rr, pre)
if a is None:
missing.append(d.format(k=k)); lines.append(f"| {d.format(k=k)} | pending | | {dref.format(k=k)} | | | |"); continue
w = float(a.get("wall_s", 0) or 0); tot += w
e = lambda j: (f"{j.get('epochs_run', '—')} ({j.get('best_epoch', '—')})" if j else "—")
vo = lambda j: (f"{float(j['val_objective']):.5f}" if j and j.get("val_objective") not in (None, "") and np.isfinite(float(j["val_objective"])) else "—")
js.append({"run": d.format(k=k), "epochs_run": a.get("epochs_run"), "best_epoch": a.get("best_epoch"), "val_objective": a.get("val_objective"), "wall_s": w,
"frozen": {"run": dref.format(k=k), "epochs_run": (b or {}).get("epochs_run"), "best_epoch": (b or {}).get("best_epoch"), "val_objective": (b or {}).get("val_objective")}})
lines.append(f"| {d.format(k=k)} | {e(a)} | {vo(a)} | {dref.format(k=k)} | {e(b)} | {vo(b)} | {w:.0f} |")
lines += ["", f"GPU minutes (sum of wall_s over the {len(js)} finished udwm runs; pre-registered estimate ≈ 90 min): **{tot / 60:.1f} min**" + (f"; pending: {missing}" if missing else "")]
return lines, {"gpu_minutes": round(tot / 60, 1), "runs": js, "pending": missing}
def counts(cells):
c = {"BEATS": 0, "WORSE": 0, "NOT_WORSE": 0, "INCONCLUSIVE": 0, "INSUFFICIENT": 0, "other": 0}
for v in cells.values():
c[v["verdict"] if v["verdict"] in c else "other"] += 1
return c
def main():
ap = argparse.ArgumentParser()
ap.add_argument("--seeds", default="0,1,2")
ap.add_argument("--out", default=str(CWM3 / "results" / "tables" / "stage_final_udwm.md"))
a = ap.parse_args()
seeds = [int(s) for s in a.seeds.split(",")]
dfs = []
dA, bodyA, vA, (stA, worseA, bcA, boA) = block("finalc", "allminusudwm", "allminus", "B2", "(a) udwm main vs the FROZEN main — TEST split (the Table 3 comparison), v2 causal kin targets", seeds)
dV, bodyV, vV, (stV, worseV, bcV, boV) = block("finalcv", "allminusudwm", "allminus", "B2", "(a-val) udwm main vs the FROZEN main — VALIDATION split (descriptive)", seeds)
dB, bodyB, vB, (stB, worseB, bcB, boB) = block("finalc", "allminusudwm", "indepudwm", "B2", "(b) interaction effect on the udwm bases: all_minus_road2drv_udwm vs indep_udwm (B2-style)", seeds)
dC, bodyC, vC, (stC, worseC, bcC, boC) = block("finalc", "indepudwm", "indep", "B2", "(c) the U-base swap alone: indep_udwm vs indep (assembled bases, no training)", seeds)
dP1, bodyP1, vP1, _ = block("finalP", "allminusudwm", "allminus", "B3", "P road cells (road-pressure onset PR-AUC@3s, eval/pressure_eval.py): udwm main vs FROZEN main", seeds)
dP2, bodyP2, vP2, _ = block("finalP", "allminusudwm", "indepudwm", "B3", "P road cells: all_minus_udwm vs indep_udwm", seeds)
dP3, bodyP3, vP3, _ = block("finalP", "indepudwm", "indep", "B3", "P road cells: indep_udwm vs indep", seeds)
dfs += [dA, dV, dB, dC, dP1, dP2, dP3]
# ---- the Table 3 row: reported driver cells, vehicle cells, road cells, NLL costs (test, udwm main vs frozen main)
t_drv, c_drv = cell_table(dA, vA, "Driver cells — TEST (a): the four REPORTED cells + the two engaged hand cells (computed, not reported)",
spec_onset(REPORTED, "reported (Table 3)") + spec_onset(NOT_REPORTED, "computed; NOT reported (engaged hand cells: label-quality caveat, Supp E)"))
t_veh, c_veh = cell_table(dA, vA, "Vehicle cells — TEST (a)", spec_both(VEH, "pr_auc", "reported (Table 3)"))
t_road, c_road = cell_table(dA, vA, "D road cells — TEST (a) (the E branch is identical in both models; the joint fine-tune moves them only through the shared optimisation)", spec_both(ROAD_D, "pr_auc", "reported (road)"))
t_p, c_p = cell_table(dP1, vP1, "P road cells — TEST (a) (detached P head, eval/pressure_eval.py)", spec_both(ROAD_P, "pr_auc", "reported (road)"))
t_nll, c_nll = cell_table(dA, vA, "Hazard-NLL costs — TEST (a) (lower is better)", spec_both(NLL_DRV, "nll", "driver NLL") + spec_both(NLL_VEH, "nll", "vehicle NLL") + spec_both(NLL_ROAD, "nll", "road NLL"))
tv_drv, cv_drv = cell_table(dV, vV, "Driver cells — VALIDATION (a-val, descriptive)", spec_onset(REPORTED, "reported (Table 3)") + spec_onset(NOT_REPORTED, "computed; NOT reported"))
tv_veh, cv_veh = cell_table(dV, vV, "Vehicle cells — VALIDATION (a-val, descriptive)", spec_both(VEH, "pr_auc", "reported (Table 3)"))
# swap-alone and interaction pictures on the reported cells
tc_drv, cc_drv = cell_table(dC, vC, "(c) U-base swap alone — reported driver cells + engaged hand cells (test)", spec_onset(REPORTED, "reported") + spec_onset(NOT_REPORTED, "computed; NOT reported"))
tb_drv, cb_drv = cell_table(dB, vB, "(b) interaction effect on the udwm bases — reported driver cells + vehicle cells (test)", spec_onset(REPORTED, "reported") + spec_onset(NOT_REPORTED, "computed; NOT reported") + spec_both(VEH, "pr_auc", "reported"))
pc_lines, pc_json = param_counts()
tr_lines, tr_json = training_summary()
# ---- summary
rep = {k: v for k, v in c_drv.items() if v["reporting"].startswith("reported")}
n_seeds = int(dA.seed.nunique()) if len(dA) else 0
cr, cvh, crd, cp, cn = counts(rep), counts(c_veh), counts(c_road), counts(c_p), counts(c_nll)
if not len(dA):
verdict, vtxt = "NOT RENDERABLE", "no finalc_s<k>_allminusudwm_vs_allminus rows yet (test split)"
elif n_seeds < 3 or any(v["verdict"] == "INSUFFICIENT" for v in rep.values()) or len(rep) < 4:
verdict, vtxt = "INSUFFICIENT", f"{n_seeds}/3 seeds paired on test; reported driver cells with rows {len(rep)}/4"
else:
beats = [k for k, v in rep.items() if v["verdict"] == "BEATS"]; worse = [k for k, v in rep.items() if v["verdict"] == "WORSE"]
vbeats = [k for k, v in c_veh.items() if v["verdict"] == "BEATS"]; vworse = [k for k, v in c_veh.items() if v["verdict"] == "WORSE"]
if beats and not worse:
verdict = "Driver-WM trunk BETTER on the reported driver cells"
elif worse and not beats:
verdict = "Driver-WM trunk WORSE on the reported driver cells"
elif beats and worse:
verdict = "MIXED on the reported driver cells"
else:
verdict = "NO DIFFERENCE detected on the reported driver cells (≥ 2/3 rule)"
vtxt = (f"reported driver cells: BEATS {fmt(beats)}, WORSE {fmt(worse)}, other {cr['NOT_WORSE']} NOT_WORSE / {cr['INCONCLUSIVE']} INCONCLUSIVE; "
f"vehicle cells: BEATS {fmt(vbeats)}, WORSE {fmt(vworse)}; D road cells BEATS {crd['BEATS']} / WORSE {crd['WORSE']}; P cells BEATS {cp['BEATS']} / WORSE {cp['WORSE']}; "
f"hazard-NLL costs better(BEATS) {cn['BEATS']} / worse {cn['WORSE']} of {sum(cn.values())}")
allrows = pd.concat([d for d in dfs if len(d)], ignore_index=True) if any(len(d) for d in dfs) else pd.DataFrame(columns=["a", "b", "regime", "run_stamp"])
prov, stale = RJ.provenance(allrows) if len(allrows) else ([], [])
void = f" — **VOID: stale rows for {stale}**" if stale else ""
row = []
for (r, c) in REPORTED:
v = rep.get((r, c, "pr_auc"))
row.append(f"{r} {c.split('|')[1]}: " + (f"{ms(v['a'])} vs frozen {ms(v['b'])} (Δ {v['mean_delta']:+.4f} ± {v['sd_delta']:.4f}, {v['verdict']})" if v else "pending"))
for r in ("manual", "engaged"):
for c in VEH:
v = c_veh.get((r, c, "pr_auc"))
row.append(f"{r} {c.split('|')[1]}: " + (f"{ms(v['a'])} vs {ms(v['b'])} (Δ {v['mean_delta']:+.4f} ± {v['sd_delta']:.4f}, {v['verdict']})" if v else "pending"))
L = ["# Stage FINAL — owner experiment C: the Driver-WM temporal encoder as the driver branch (`U0_kin_can_noK_s<k>_kcv2_clip8_ln_udwm` = FINAL U recipe + `arch: driverwm`), 3 seeds, both regimes", "",
"Runs `I1_{indep,all_minus_road2drv}_s<k>_final_udwm` = the FINAL command line with only the U base swapped (V0 `can4s_stats2`, E0 `pooled_P_v2`, seeds, recipe and selection unchanged; "
"driver inputs = EXACTLY the GRU U branch's Kx [B,40,18] causal kinematics / CAN history + mode; h_u 128-d for the same heads / interactions). The U trunk = the AIDE port's Driver-WM internal "
"stream at its PUBLISHED width (models/u_driverwm.py: Linear tokeniser + step embedding -> one causal pre-norm TransformerEncoderLayer(1024, 4 heads, d_ff 4096) -> last state -> "
"residual MLP transition f_int (1024 -> 4096 -> 1024) -> LN -> Linear(1024 -> 128)); the external stream is absent (the main model has no road -> driver path = the paper's own do(Ext = ∅)). "
"**NOT parameter-matched** (below). The frozen main `I1_all_minus_road2drv_s<k>_final` and `I1_indep_s<k>_final` are read as B layouts only. Paired device-cluster bootstrap on identical rows "
"(eval/paired_compare_joint.py via eval/pc_joint_locked.py, n_boot 1000; verdict = kill_checks.beats: ≥ 2/3 seeds CI excl. 0, same sign, |mean Δ| > seed sd); driver populations from the "
"v2 causal kin targets; `finalc_*` = test, `finalcv_*` = validation (descriptive), `finalP_*` = P cells. Identity of the assembled `indep_udwm` with its bases: `results/tables/identity_final_udwm.md`. "
"Every number comes from `results/paired_compare.csv`.", "",
"**Pre-registered reading (docs/decisions.md 2026-09-17T07:00:22Z part (C); this renderer written before any udwm pairing existed):** cells = the four reported driver cells + vehicle cells "
"+ hazard-NLL costs (road cells added as context), both regimes, 3 seeds, device-cluster bootstrap, ≥ 2/3 rule; placement = a row in Table 3 REGARDLESS of direction, with the parameter "
"counts stated; the engaged hand cells are computed but not reported; no adoption decision is attached (the frozen main stays the headline).", "",
f"## VERDICT (test, udwm main vs frozen main): **{verdict}**{void}", "", f"- {vtxt}",
f"- B2-style status of (a): **{stA}** (own WORSE {fmt(worseA)}; own BEATS {fmt(boA)}; cross BEATS {fmt(bcA)}); (b) all_minus_udwm vs indep_udwm: **{stB}** (own WORSE {fmt(worseB)}; cross BEATS {fmt(bcB)}); "
f"(c) indep_udwm vs indep: **{stC}** (own WORSE {fmt(worseC)}; own BEATS {fmt(boC)})",
f"- validation picture (descriptive): reported driver cells " + ", ".join(f"{r} {c.split('|')[1]} {cv_drv[(r, c, 'pr_auc')]['verdict']} ({cv_drv[(r, c, 'pr_auc')]['mean_delta']:+.4f})" for (r, c) in REPORTED if (r, c, 'pr_auc') in cv_drv) if cv_drv else "- validation rows pending", "",
"## Table 3 row (test; udwm mean ± sd over seeds vs frozen main; Δ = udwm − frozen)", ""] + [f"- {x}" for x in row] + ["",
"## Parameter counts (the row is NOT parameter-matched; stated with it)", ""] + pc_lines + ["",
"## Training summary and GPU minutes", ""] + tr_lines + ["",
"## Provenance of the A / B layouts (guard 2): layout mtime, source hash, model_id / code hash, completeness; rows older than the layout are STALE", "",
"| run | regime | layout mtime (UTC) | source sha256 | model_id / code | status |", "|---|---|---|---|---|---|", *prov, "",
*([f"**STALE ROWS DETECTED for {stale} — every verdict is VOID; recompute (eval/run_joint_evals_final_udwm.sh).**", ""] if stale else []),
"## 1. (a) udwm main vs the FROZEN main — TEST split (the Table 3 comparison)", ""] + t_drv + t_veh + t_road + t_p + t_nll + bodyA + ["",
"## 2. (a-val) udwm main vs the FROZEN main — VALIDATION split (descriptive)", ""] + tv_drv + tv_veh + bodyV + ["",
"## 3. (c) Attribution — the U-base swap alone (indep_udwm vs indep, no training)", ""] + tc_drv + bodyC + ["", f"B2-style status: **{stC}** — own WORSE {fmt(worseC)}; own BEATS {fmt(boC)}", "",
"## 4. (b) Interaction effect on the udwm bases (all_minus_road2drv_udwm vs indep_udwm)", ""] + tb_drv + bodyB + ["", f"B2-style verdict (b): **{stB}** — own WORSE {fmt(worseB)}; cross BEATS {fmt(bcB)}; own BEATS {fmt(boB)}", "",
"## 5. P road cells (detached head)", ""] + bodyP1 + [""] + bodyP2 + [""] + bodyP3
out = Path(a.out); out.parent.mkdir(parents=True, exist_ok=True)
out.write_text("\n".join(L) + "\n")
key = lambda d: {f"{r}|{c}|{m}": v for (r, c, m), v in d.items()}
dec = {"verdict": verdict, "detail": vtxt, "B2_style_a_test": stA, "B2_style_b": stB, "B2_style_c": stC, "table3_row": row, "seeds": seeds, "n_seeds_paired_test": n_seeds,
"reported_driver_cells_test": key(rep), "not_reported_engaged_hand_cells_test": key({k: v for k, v in c_drv.items() if not v["reporting"].startswith("reported")}),
"vehicle_cells_test": key(c_veh), "d_road_cells_test": key(c_road), "p_road_cells_test": key(c_p), "hazard_nll_test": key(c_nll),
"driver_cells_val": key(cv_drv), "vehicle_cells_val": key(cv_veh), "swap_alone_driver_cells_test": key(cc_drv), "interaction_cells_test": key(cb_drv),
"verdict_counts": {"reported_driver": cr, "vehicle": cvh, "d_road": crd, "p_road": cp, "nll": cn}, "parameter_counts": pc_json, "training": tr_json, "stale": stale}
(out.parent / "stage_final_udwm_decision.json").write_text(json.dumps(dec, indent=1, default=str))
print("\n".join(L[:12]))
print("\n".join("ROW " + x for x in row))
print(f"\nVERDICT {verdict}: {vtxt}\nwritten {out} and {out.parent / 'stage_final_udwm_decision.json'}")
if __name__ == "__main__":
main()

Xet Storage Details

Size:
23.9 kB
·
Xet hash:
1be49c43d6f057e5ba4994822305efe9e3fab641829310b40787bd86faec490c

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.