Download code/run_v2_eval.py from Tonic/protostar-climate-2026: direct link, hf CLI and curl.
- Browser
- Download file 1.74 kB
-
https://huggingface.co/datasets/Tonic/protostar-climate-2026/resolve/main/code/run_v2_eval.py
- Command line
-
hf download hf://datasets/Tonic/protostar-climate-2026/code/run_v2_eval.py
-
curl -L -o run_v2_eval.py https://huggingface.co/datasets/Tonic/protostar-climate-2026/resolve/main/code/run_v2_eval.py
1.74 kB
| """Phase 0/1/4(generic): evaluate pre-declared candidates per metric.""" | |
| from __future__ import annotations | |
| import sys | |
| from functools import partial | |
| from pathlib import Path | |
| import pandas as pd | |
| sys.path.insert(0, str(Path(__file__).parent)) | |
| from candidates import (CDD_LINEAR_CANDIDATES, GENERIC_CANDIDATES, | |
| TEMP_CANDIDATES, level_trend) | |
| from harness import evaluate, skill_table | |
| from panel import Panel | |
| CLIP = {"cdd", "total_precip_in"} | |
| def wrap(metric: str, cfg: dict): | |
| return lambda p, origin: level_trend(p, metric, origin, | |
| clip_zero=metric in CLIP, **cfg) | |
| def main() -> None: | |
| root = Path(__file__).resolve().parent.parent | |
| panel = Panel(root) | |
| out = root / "outputs" / "v2" | |
| out.mkdir(parents=True, exist_ok=True) | |
| jobs = { | |
| "annual_avg_temp": TEMP_CANDIDATES, | |
| "cdd": CDD_LINEAR_CANDIDATES, | |
| "total_precip_in": GENERIC_CANDIDATES, | |
| "hottest_day_temp": GENERIC_CANDIDATES, | |
| } | |
| all_detail = [] | |
| for metric, registry in jobs.items(): | |
| cands = {name: wrap(metric, cfg) for name, cfg in registry.items()} | |
| detail = evaluate(panel, metric, cands) | |
| detail.to_csv(out / f"detail_{metric}.csv", index=False) | |
| all_detail.append(detail) | |
| tab = skill_table(detail) | |
| piv = tab.pivot_table(index="candidate", columns="era", values="skill") | |
| print(f"\n== {metric} (skill by era) ==") | |
| print(piv.sort_values("tune", ascending=False).round(4).to_string()) | |
| pd.concat(all_detail).to_csv(out / "detail_all.csv", index=False) | |
| print("\nwrote outputs/v2/detail_*.csv") | |
| if __name__ == "__main__": | |
| main() | |