tensor-group-sym / python / large_scale / update_summary_with_matlab_feat.py
update_summary_with_matlab_feat.py
Raw
"""Overlay the matlab_feat_n48 starg_ridge / starg_neural rows on top of
the existing summary.csv. Used to regenerate the Pareto figure with the
corrected ★_G numbers without invalidating the rest of the table.
"""

from __future__ import annotations

import csv

NEW_ROWS = [
    # method, target, r2_mean, r2_std, rmse, rmse_std, mae, mae_std, n_params, n_seeds
    ("starg_ridge",  "gap",   0.482204, 0.000734, 0.0, 0.0, 0.0, 0.0, 144,    3),
    ("starg_ridge",  "alpha", 0.908501, 0.003071, 0.0, 0.0, 0.0, 0.0, 144,    3),
    ("starg_ridge",  "mu",    0.469663, 0.003399, 0.0, 0.0, 0.0, 0.0, 144,    3),
    ("starg_ridge",  "zpve",  0.998442, 0.000011, 0.0, 0.0, 0.0, 0.0, 144,    3),
    ("starg_neural", "gap",   0.567710, 0.003452, 0.0, 0.0, 0.0, 0.0, 62625,  3),
    ("starg_neural", "alpha", 0.943973, 0.003867, 0.0, 0.0, 0.0, 0.0, 62625,  3),
    ("starg_neural", "mu",    0.553551, 0.008980, 0.0, 0.0, 0.0, 0.0, 62625,  3),
    ("starg_neural", "zpve",  0.996931, 0.001942, 0.0, 0.0, 0.0, 0.0, 62625,  3),
]

REPLACE_KEYS = {(r[0], r[1]): r for r in NEW_ROWS}

with open("results/summary.csv") as fp:
    rows = list(csv.reader(fp))
header, body = rows[0], rows[1:]
out = [header]
for r in body:
    key = (r[0], r[1])
    if key in REPLACE_KEYS:
        new = REPLACE_KEYS[key]
        out.append([str(x) for x in new])
    else:
        out.append(r)

with open("results/summary.csv", "w", newline="") as fp:
    w = csv.writer(fp)
    w.writerows(out)
print(f"[ok] overlaid {len(REPLACE_KEYS)} ★_G rows in results/summary.csv")