Download code/compare_leaf50.py from Devya27/orca-table3-repro: direct link, hf CLI and curl.
- Browser
- Download file 3.65 kB
-
https://huggingface.co/datasets/Devya27/orca-table3-repro/resolve/main/code/compare_leaf50.py
- Command line
-
hf download hf://datasets/Devya27/orca-table3-repro/code/compare_leaf50.py
-
curl -L -o compare_leaf50.py https://huggingface.co/datasets/Devya27/orca-table3-repro/resolve/main/code/compare_leaf50.py
3.65 kB
| #!/usr/bin/env python | |
| """F1 analysis: compare leaf=50 vs split=50 vs Table 3 (raw scale).""" | |
| import os | |
| import urllib.request | |
| import pandas as pd | |
| BASE = ("https://huggingface.co/datasets/Devya27/orca-table3-repro/resolve/main/results/") | |
| PAPER = { # Table 3 raw: (mean, se) per dataset | |
| "blog": {"orca": (3.61, 1.27), "pcp": (8.27, 0.21), "cqr": (16.18, 2.61), | |
| "chr": (10.26, 1.77), "distsplit": (16.93, 2.13)}, | |
| "fb1": {"orca": (3.70, 1.75), "pcp": (7.79, 0.28), "cqr": (14.78, 2.31), | |
| "chr": (11.23, 1.34), "distsplit": (15.88, 2.07)}, | |
| "fb2": {"orca": (5.68, 1.62), "pcp": (9.35, 0.21), "cqr": (18.31, 1.57), | |
| "chr": (10.12, 1.04), "distsplit": (14.48, 1.43)}, | |
| } | |
| def load(name): | |
| return pd.read_csv(urllib.request.urlopen(BASE + name, timeout=120)) | |
| out_rows = [] | |
| for ds in ("blog", "fb1", "fb2"): | |
| leaf = load(f"full_leaf50_raw_{ds}.csv") | |
| split = load(f"full_cpu_raw_{ds}.csv") | |
| print(f"\n===== {ds} — leaf=50 vs split=50 (30 runs, mean ± SE) =====") | |
| print(f"{'config':34s} {'leaf50 cov':>16s} {'leaf50 eff':>16s} {'split50 cov':>16s} {'split50 eff':>16s}") | |
| cfgs = sorted(set(leaf.method_config) | set(split.method_config)) | |
| for mc in cfgs: | |
| gl = leaf[(leaf.method_config == mc) & (leaf.status == "ok")] | |
| gs = split[(split.method_config == mc) & (split.status == "ok")] | |
| f = lambda g, c: (f"{g[c].mean():.4f}±{g[c].sem():.4f}" if len(g) else "n/a") | |
| print(f"{mc:34s} {f(gl,'coverage'):>16s} {f(gl,'eff'):>16s} " | |
| f"{f(gs,'coverage'):>16s} {f(gs,'eff'):>16s}") | |
| out_rows.append(dict(dataset=ds, method_config=mc, leaf_mode="leaf", | |
| n=len(gl), coverage_leaf50=round(gl.coverage.mean(), 4) if len(gl) else None, | |
| eff_leaf50=round(gl.eff.mean(), 4) if len(gl) else None, | |
| coverage_split50=round(gs.coverage.mean(), 4) if len(gs) else None, | |
| eff_split50=round(gs.eff.mean(), 4) if len(gs) else None)) | |
| # ORCA/PCP ratios under both leaf modes | |
| for mode, df in (("leaf50", leaf), ("split50", split)): | |
| p = df[(df.method_config == "pcp|sampler=iid") & (df.status == "ok")] | |
| for oc in ("orca|spec=paper|sampler=iid", "orca|spec=author|sampler=iid", | |
| "orca|spec=paper|sampler=shared", "orca|spec=author|sampler=shared"): | |
| o = df[(df.method_config == oc) & (df.status == "ok")] | |
| if len(o) and len(p): | |
| r = o.eff.mean() / p.eff.mean() | |
| po = PAPER[ds]["orca"][0] / PAPER[ds]["pcp"][0] | |
| print(f" ratio {mode} {oc:34s} = {r:.3f} (paper claims {po:.3f})") | |
| # leaf50 baselines vs paper | |
| for m, col in (("cqr", "cqr"), ("chr", "chr"), ("distsplit", "distsplit")): | |
| g = leaf[(leaf.method_config == col) & (leaf.status == "ok")] | |
| pm = PAPER[ds][m] | |
| print(f" leaf50 {m:10s} eff {g.eff.mean():.3f}±{g.eff.sem():.3f} vs paper " | |
| f"{pm[0]}±{pm[1]} (Δ = {g.eff.mean()-pm[0]:+.3f}, {abs(g.eff.mean()-pm[0])/pm[1]:.2f} paper-SE)") | |
| comp = pd.DataFrame(out_rows) | |
| comp.to_csv("/tmp/comparison_leaf50.csv", index=False) | |
| if os.environ.get("ORCA_UPLOAD_REPO", "Devya27/orca-table3-repro"): | |
| try: | |
| from huggingface_hub import HfApi | |
| HfApi().upload_file(path_or_fileobj="/tmp/comparison_leaf50.csv", | |
| path_in_repo="results/comparison_leaf50_vs_split50.csv", | |
| repo_id=os.environ["ORCA_UPLOAD_REPO"], repo_type="dataset") | |
| print("\n[upload] ok") | |
| except Exception as exc: | |
| print(f"\n[upload] FAILED: {exc}") | |