Skip to content

Commit d8b727e

Browse files
radar love
1 parent 47ef08a commit d8b727e

7 files changed

Lines changed: 22 additions & 23 deletions

cybench/runs/analysis/collect_walk_forward_results.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,8 +397,8 @@ def summary_rows_to_dashboard_records(
397397
("spatial", "r_agg", "r_spatial_agg"),
398398
("temporal", "r", "r_temporal"),
399399
("temporal", "r_agg", "r_temporal_agg"),
400+
("anomaly", "r", "r_res"),
400401
("anomaly", "r2", "r2_res"),
401-
("anomaly", "r_pooled", "r_res"),
402402
]
403403
records: list[dict[str, Any]] = []
404404
for row in summary_rows:

cybench/runs/analysis/global_insights_lib.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,10 @@
4444
{
4545
"id": "anomaly",
4646
"label": "Anomaly",
47-
"note": "Pooled residual R² on location-demeaned yields (variance explained in anomalies). "
48-
"Spatial and temporal axes use Pearson r because they assess pattern agreement; "
49-
"anomaly uses R² because the objective is explained anomaly variance, not ranking alone.",
47+
"note": "Pooled Pearson r on location-demeaned yields (all region×year residuals). "
48+
"Distinct from temporal median per-region r; measures whether anomalous years line up globally.",
5049
"metrics": (
51-
{"id": "r2", "column": "r2_res", "label": "", "higher_better": True},
50+
{"id": "r", "column": "r_res", "label": "r", "higher_better": True},
5251
),
5352
},
5453
)

cybench/runs/analysis/model_family_radar_lib.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@
3939
},
4040
{
4141
"label": "Anomaly",
42-
"metric": "r2_res",
43-
"display": "",
44-
"question": "How much interannual anomaly variance is explained after removing regional means (pooled residual R²)?",
42+
"metric": "r_res",
43+
"display": "r",
44+
"question": "Across all regions and years, do anomalous years line up (pooled Pearson r on location-demeaned yields)?",
4545
},
4646
)
4747

@@ -86,13 +86,13 @@
8686
"nrmse": {"lo": 0.1, "hi": 0.30, "higher_better": False, "display": "NRMSE"},
8787
"r_spatial": {"lo": 0.0, "hi": 1.0, "higher_better": True, "display": "r"},
8888
"r_temporal": {"lo": 0.0, "hi": 1.0, "higher_better": True, "display": "r"},
89-
"r2_res": {"lo": 0.0, "hi": 1.0, "higher_better": True, "display": ""},
89+
"r_res": {"lo": 0.0, "hi": 1.0, "higher_better": True, "display": "r"},
9090
}
9191

9292
RADAR_ABSOLUTE_NOTE = (
9393
"Absolute: fixed scales per axis — NRMSE 0.10 (outer, best) to 0.30 (center, worst); "
94-
"Pearson r axes and Anomaly R²: 0 (center) to 1 (outer). Values outside the range are clamped; "
95-
"negative values are shown at 0 on the radar."
94+
"Pearson r axes 0 (center) to 1 (outer). Values outside the range are clamped; "
95+
"negative r is shown at 0."
9696
)
9797

9898
MODEL_DISPLAY_NAMES: dict[str, str] = {

cybench/runs/viz/global_insights_template.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ <h3 style="font-size:1rem;margin:1rem 0 0.5rem;">Model × country</h3>
220220
</div>
221221
<p class="muted" style="margin-top:0;" id="matrix-metric-note">
222222
Median column = median across countries per model (click column headers to sort). Green = better.
223-
Pattern axes (spatial, temporal) show Pearson r; anomaly shows pooled residual R²; overall shows R²/NRMSE.
223+
Pattern axes (spatial, temporal, anomaly) show Pearson r; overall shows R²/NRMSE.
224224
Country cells link to the matching country dashboard with that model pre-selected.
225225
</p>
226226
<div class="table-scroll" id="model-country-wrap"></div>
@@ -378,7 +378,7 @@ <h3 style="font-size:1rem;margin:1rem 0 0.5rem;">Detail per crop × country × m
378378
},
379379
{ id: "spatial", label: "Spatial", note: "Median per-year r across regions (typical-year slice).", metrics: [{ id: "r", label: "r", higher_better: true }] },
380380
{ id: "temporal", label: "Temporal", note: "Median per-region r across years (typical-region slice).", metrics: [{ id: "r", label: "r", higher_better: true }] },
381-
{ id: "anomaly", label: "Anomaly", note: "Pooled residual R² on location-demeaned yields.", metrics: [{ id: "r2", label: "", higher_better: true }] },
381+
{ id: "anomaly", label: "Anomaly", note: "Pooled Pearson r on location-demeaned yields (r_res).", metrics: [{ id: "r", label: "r", higher_better: true }] },
382382
];
383383

384384
function syncCropSelects(value) {

cybench/runs/viz/model_family_radar_template.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@
195195
<p class="back"><a href="index.html">← All dashboards</a></p>
196196
<header>
197197
<h1>Model family comparison</h1>
198-
<p class="lead">NRMSE (Overall); Pearson r pattern slices (Spatial, Temporal); pooled residual R² (Anomaly) — one best-NRMSE representative per modeling paradigm (five families).</p>
198+
<p class="lead">NRMSE (Overall); Pearson r (Spatial, Temporal, and pooled anomaly r<sub>res</sub>) — one best-NRMSE representative per modeling paradigm (five families).</p>
199199
<p class="muted">Paper-level summary. For every model and crop×country drill-down, see <a href="insights.html">Global insights</a> (leaderboard and model×country heatmap).</p>
200200
</header>
201201

tests/runs/test_collect_walk_forward_results.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ def test_summary_rows_to_dashboard_records(tmp_path: Path):
241241
assert sp_agg["value"] == 0.12
242242
tm_agg = next(r for r in records if r["view"] == "temporal" and r["metric"] == "r_agg")
243243
assert tm_agg["value"] == 0.48
244-
an_pool = next(r for r in records if r["view"] == "anomaly" and r["metric"] == "r_pooled")
244+
an_pool = next(r for r in records if r["view"] == "anomaly" and r["metric"] == "r")
245245
assert an_pool["value"] == 0.05
246246
scatter_recs = [r for r in records if r.get("images", {}).get("scatter")]
247247
assert scatter_recs

tests/runs/test_model_family_radar.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def test_relative_scores_span_unit_interval():
116116
"nrmse": [0.2, 0.8],
117117
"r_spatial": [0.1, 0.9],
118118
"r_temporal": [0.3, 0.7],
119-
"r2_res": [0.0, 1.0],
119+
"r_res": [0.0, 1.0],
120120
}
121121
)
122122
rel = relative_scores(raw)
@@ -132,7 +132,7 @@ def test_absolute_scores_use_fixed_scales():
132132
"nrmse": [0.1, 0.2, 0.30],
133133
"r_spatial": [-0.2, 0.5, 1.0],
134134
"r_temporal": [0.0, 0.5, 1.0],
135-
"r2_res": [0.25, 0.5, 0.75],
135+
"r_res": [0.25, 0.5, 0.75],
136136
}
137137
)
138138
abs_scores = absolute_scores(raw)
@@ -148,7 +148,7 @@ def test_absolute_scores_clamps_out_of_range_nrmse():
148148
"nrmse": [0.05, 0.40],
149149
"r_spatial": [0.5, 0.5],
150150
"r_temporal": [0.5, 0.5],
151-
"r2_res": [0.5, 0.5],
151+
"r_res": [0.5, 0.5],
152152
}
153153
)
154154
abs_scores = absolute_scores(raw)
@@ -189,7 +189,7 @@ def test_build_family_dataset_rows_includes_all_view_metrics():
189189
rows = build_family_dataset_rows(df, reps)
190190
assert len(rows) == 1
191191
assert rows[0]["dataset"] == "maize_DE"
192-
assert set(rows[0]["metrics"]) == {"nrmse", "r_spatial", "r_temporal", "r2_res"}
192+
assert set(rows[0]["metrics"]) == {"nrmse", "r_spatial", "r_temporal", "r_res"}
193193

194194

195195
def test_build_radar_payload_structure(tmp_path: Path):
@@ -205,32 +205,32 @@ def test_build_radar_payload_structure(tmp_path: Path):
205205
nrmse=0.22,
206206
r_spatial=0.62,
207207
r_temporal=0.33,
208-
r2_res=0.12,
209208
r_res=0.2,
209+
r2_res=0.12,
210210
),
211211
_summary_row(
212212
"lightgbm",
213213
nrmse=0.15,
214214
r_spatial=0.74,
215215
r_temporal=0.1,
216-
r2_res=0.28,
217216
r_res=0.5,
217+
r2_res=0.28,
218218
),
219219
_summary_row(
220220
"transformer_lf",
221221
nrmse=0.17,
222222
r_spatial=0.73,
223223
r_temporal=0.21,
224-
r2_res=0.18,
225224
r_res=0.4,
225+
r2_res=0.18,
226226
),
227227
_summary_row(
228228
"tabpfn",
229229
nrmse=0.16,
230230
r_spatial=0.77,
231231
r_temporal=0.31,
232-
r2_res=0.22,
233232
r_res=0.45,
233+
r2_res=0.22,
234234
),
235235
]
236236
).to_csv(d / "walk_forward_summary.csv", index=False)

0 commit comments

Comments
 (0)