Spaces:
Sleeping
Sleeping
github-actions[bot] Claude Sonnet 5 commited on
Commit ·
2c21c31
1
Parent(s): 7cef48a
Filter heatmap rows without data for selected metric
Browse filesA variant/head that never reports the selected metric (e.g. ridge is
regression-only, so it has no auprc_test/mcc_test/etc.) previously left
an all-blank row once its only columns got filtered out. Now such rows
are dropped, and multi-model best-variant selection skips families with
no non-null metric values instead of crashing on idxmax over all-NaN.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
- src/plots.py +15 -4
src/plots.py
CHANGED
|
@@ -343,20 +343,28 @@ def heatmap_variants(
|
|
| 343 |
family_df = mdf[mdf["model_alias"] == m]
|
| 344 |
if family_df.empty:
|
| 345 |
continue
|
| 346 |
-
# Pick the variant with highest mean metric for this family
|
| 347 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 348 |
best_vkey = vkey_means.idxmax()
|
| 349 |
best_df = family_df[family_df["_vkey"] == best_vkey]
|
| 350 |
rows_iter.append((_variant_label(best_df.iloc[0]), best_df))
|
| 351 |
else:
|
| 352 |
-
configs = sorted(
|
|
|
|
|
|
|
| 353 |
if len(configs) > 1:
|
| 354 |
rows_iter = [
|
| 355 |
(_variant_label(mdf[mdf["_vkey"] == c].iloc[0]), mdf[mdf["_vkey"] == c])
|
| 356 |
for c in configs
|
| 357 |
]
|
|
|
|
|
|
|
| 358 |
else:
|
| 359 |
-
rows_iter = [
|
| 360 |
|
| 361 |
# A task/dataset only gets a column if the selected metric is ever reported for it —
|
| 362 |
# e.g. bulk_rna_expression is regression-only (r2_test), so it never has mcc_test/
|
|
@@ -386,6 +394,9 @@ def heatmap_variants(
|
|
| 386 |
def _cell_vals(vdf: pd.DataFrame, col_key: str) -> pd.Series:
|
| 387 |
return vdf[vdf["task_name"] == col_key][metric].dropna()
|
| 388 |
|
|
|
|
|
|
|
|
|
|
| 389 |
col_names = col_names + ["Overall"]
|
| 390 |
|
| 391 |
rows_z, rows_text, rows_hover, row_labels = [], [], [], []
|
|
|
|
| 343 |
family_df = mdf[mdf["model_alias"] == m]
|
| 344 |
if family_df.empty:
|
| 345 |
continue
|
| 346 |
+
# Pick the variant with highest mean metric for this family. A variant/head
|
| 347 |
+
# (e.g. ridge, regression-only) that never reports this metric has an all-NaN
|
| 348 |
+
# group mean — idxmax would raise, and it'd render as an all-blank row anyway.
|
| 349 |
+
vkey_means = family_df.groupby("_vkey")[metric].mean().dropna()
|
| 350 |
+
if vkey_means.empty:
|
| 351 |
+
continue
|
| 352 |
best_vkey = vkey_means.idxmax()
|
| 353 |
best_df = family_df[family_df["_vkey"] == best_vkey]
|
| 354 |
rows_iter.append((_variant_label(best_df.iloc[0]), best_df))
|
| 355 |
else:
|
| 356 |
+
configs = sorted(
|
| 357 |
+
c for c in mdf["_vkey"].unique() if mdf[mdf["_vkey"] == c][metric].notna().any()
|
| 358 |
+
)
|
| 359 |
if len(configs) > 1:
|
| 360 |
rows_iter = [
|
| 361 |
(_variant_label(mdf[mdf["_vkey"] == c].iloc[0]), mdf[mdf["_vkey"] == c])
|
| 362 |
for c in configs
|
| 363 |
]
|
| 364 |
+
elif len(configs) == 1:
|
| 365 |
+
rows_iter = [(_variant_label(mdf[mdf["_vkey"] == configs[0]].iloc[0]), mdf[mdf["_vkey"] == configs[0]])]
|
| 366 |
else:
|
| 367 |
+
rows_iter = []
|
| 368 |
|
| 369 |
# A task/dataset only gets a column if the selected metric is ever reported for it —
|
| 370 |
# e.g. bulk_rna_expression is regression-only (r2_test), so it never has mcc_test/
|
|
|
|
| 394 |
def _cell_vals(vdf: pd.DataFrame, col_key: str) -> pd.Series:
|
| 395 |
return vdf[vdf["task_name"] == col_key][metric].dropna()
|
| 396 |
|
| 397 |
+
if not rows_iter:
|
| 398 |
+
return go.Figure()
|
| 399 |
+
|
| 400 |
col_names = col_names + ["Overall"]
|
| 401 |
|
| 402 |
rows_z, rows_text, rows_hover, row_labels = [], [], [], []
|