Skip to content

Commit 132f3bd

Browse files
dashboard
1 parent b30f510 commit 132f3bd

4 files changed

Lines changed: 506 additions & 0 deletions

File tree

cybench/runs/analysis/build_global_insights_dashboard.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from pathlib import Path
1919

2020
from cybench.runs.analysis.global_insights_lib import build_insights_payload
21+
from cybench.runs.analysis.index_map_lib import ensure_world_geojson
2122

2223

2324
def build_insights_html(payload: dict) -> str:
@@ -39,6 +40,7 @@ def write_insights_dashboard(
3940
if payload["n_rows"] == 0:
4041
raise RuntimeError(f"No walk_forward_summary.csv files found under {output_root}")
4142
dest.parent.mkdir(parents=True, exist_ok=True)
43+
payload["geojson_href"] = ensure_world_geojson(dest.parent)
4244
dest.write_text(build_insights_html(payload), encoding="utf-8")
4345
return dest
4446

cybench/runs/analysis/global_insights_lib.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
import pandas as pd
1010

11+
from cybench.runs.analysis.index_map_lib import map_iso_for_cybencH
12+
1113
_PAPER_DIR_RE = re.compile(
1214
r"^paper_walk_forward_(?P<country>[a-z]{2})_(?P<horizon>eos|mid|qtr|early)_v(?P<version>\d+)$"
1315
)
@@ -28,6 +30,19 @@
2830
# Process baselines evaluated only at end-of-season (no mid/qtr walk-forward runs).
2931
EOS_ONLY_HORIZON_CURVE_MODELS: frozenset[str] = frozenset({"lpjml_bc"})
3032

33+
# Fixed choropleth scales (aligned with insights heatmap cell coloring).
34+
METRIC_MAP_SCALES: dict[str, dict[str, Any]] = {
35+
"nrmse": {"lo": 0.0, "hi": 0.5, "higher_better": False, "label": "NRMSE"},
36+
"r2": {"lo": 0.0, "hi": 1.0, "higher_better": True, "label": "R²"},
37+
"r": {"lo": -1.0, "hi": 1.0, "higher_better": True, "label": "r"},
38+
}
39+
40+
MAP_COVERAGE_NOTE = (
41+
"Only CY-Bench countries are colored; all other land is neutral gray. "
42+
"ISO country polygons are used as-is (e.g. the United States outline includes Alaska). "
43+
"France is metropolitan only (French Guiana is not colored)."
44+
)
45+
3146

3247
def horizons_in_data(df: pd.DataFrame) -> tuple[str, ...]:
3348
"""Horizons present in a summary frame, ordered by increasing season progress."""
@@ -1298,6 +1313,9 @@ def build_insights_payload(output_root: Path, *, version: int = 1) -> dict[str,
12981313
crops = _crop_keys(df)
12991314
baseline_models = sorted({str(m) for m in df["model"].unique() if is_baseline_model(m)})
13001315
horizon_labels = {hz: HORIZON_DISPLAY_LABELS.get(hz, hz) for hz in available_horizons}
1316+
1317+
country_map_cc = {str(cc): map_iso_for_cybencH(str(cc)) for cc in countries}
1318+
benchmark_map_isos = sorted(set(country_map_cc.values()))
13011319
return {
13021320
"output_root": str(output_root.resolve()),
13031321
"dashboard_hrefs": build_dashboard_hrefs(output_root, version=version),
@@ -1316,6 +1334,10 @@ def build_insights_payload(output_root: Path, *, version: int = 1) -> dict[str,
13161334
"model_country_skilled": model_country_skilled,
13171335
"horizon_skill_curves": build_horizon_skill_curves_payload(df),
13181336
"crop_comparison": build_crop_comparison_payload(df),
1337+
"country_map_cc": country_map_cc,
1338+
"benchmark_map_isos": benchmark_map_isos,
1339+
"map_coverage_note": MAP_COVERAGE_NOTE,
1340+
"metric_map_scales": METRIC_MAP_SCALES,
13191341
}
13201342

13211343

0 commit comments

Comments
 (0)