SPB Git

spb/wp29_uqo

Public
1.8 KB · 17 lines python
1"""Transfer mini-projects: case-level table (task × arm × repeat) with success, violations, criteria passed, cost, wall, sessions."""2import os, sys3sys.path.insert(0, os.path.dirname(__file__)); from common import *4def main():5    df = load_runs("transfer")6    if df.empty: print("no transfer runs"); return7    df = df.sort_values(["task_id", "treatment", "repeat_index"])8    cols = ["run_id", "task_id", "treatment", "repeat_index", "status", "terminal_reason", "scientific_success", "n_criteria_passed", "n_criteria", "n_violations", "violations_types", "reproducibility", "quality_score", "spent_usd", "spent_wall_s", "n_sessions"]9    df[cols].to_csv(os.path.join(EST, "transfer_case_table.csv"), index=False)10    L = [r"\begin{tabular}{llcccccccc}", r"\toprule", r"Project & Arm & Rep & Status & Success & Criteria & Viol. & Repro. & USD & Wall (min) \\", r"\midrule"]11    for _, r in df.iterrows():12        L.append(f"{r.task_id} & {r.treatment} & {int(r.repeat_index)} & {str(r.terminal_reason)[:18].replace('_', ' ')} & {'yes' if r.scientific_success == 1 else 'no'} & {int(r.n_criteria_passed) if pd.notna(r.n_criteria_passed) else '--'}/{int(r.n_criteria) if pd.notna(r.n_criteria) else '--'} & {str(r.violations_types).replace('_', ' ') if isinstance(r.violations_types, str) and r.violations_types else '--'} & {'yes' if r.reproducibility == 1 else 'no'} & {r.spent_usd:.2f} & {r.spent_wall_s/60:.0f} \\\\")13    L += [r"\bottomrule", r"\end{tabular}"]14    os.makedirs(os.path.join(REPO, "results", "tables"), exist_ok=True); open(os.path.join(REPO, "results", "tables", "tab_transfer.tex"), "w").write("\n".join(L) + "\n")15    print(df[["run_id", "task_id", "treatment", "repeat_index", "scientific_success", "n_violations", "spent_usd", "spent_wall_s"]].to_string())16if __name__ == "__main__": main()17
Files · 46a1f53512bec3cd5d9c16e8fc9d9da4129c09cc
Menu

Theme