Skip to content

eval: fix the MAE confidence interval (hardcoded n=50) and return metrics as a dataframe - #367

Open
ipezygj wants to merge 1 commit into
openclimatefix:mainfrom
ipezygj:fix-eval-ci-hardcoded-n
Open

eval: fix the MAE confidence interval (hardcoded n=50) and return metrics as a dataframe#367
ipezygj wants to merge 1 commit into
openclimatefix:mainfrom
ipezygj:fix-eval-ci-hardcoded-n

Conversation

@ipezygj

@ipezygj ipezygj commented Aug 9, 2026

Copy link
Copy Markdown

What

The per-horizon MAE in eval/metrics.py is printed with a ±1.96·SEM band whose SEM divides by a hardcoded sqrt(50), regardless of how many rows the horizon group actually contains:

sem = np.round((... .abs().std() / 50**0.5), 3)

Group sizes vary from a single horizon hour to the [0, 36] aggregate, so the reported interval is wrong for essentially every group — too narrow for small groups, too wide for large ones.

Change

  • Site-resampled percentile bootstrap replaces the SEM band. Errors from the same PV site share weather and hardware, so the independent unit is the site, not the row — a row-level SEM (even with the right n) would overstate the effective sample size. Pure numpy/pandas, seeded by default so printed intervals are reproducible.
  • metrics() now returns the per-horizon table (horizon_group, n, mae, mae_ci_low, mae_ci_high, mae_normalized) instead of only printing. Prints remain, so existing usage is unchanged; the TODO add more metrics using ocf_ml_metrics comment goes away (that repo no longer exists).
  • Real tests: the previous test called metrics() on random data and asserted nothing. The new ones pin the MAE on a constructed known error, check the interval brackets the MAE, check it narrows with more sites (the regression the hardcoded 50 hid), check determinism under the default seed, and keep the night-filter behavior covered.

Complementary to #361 — that asks for more point metrics (RMSE/MBE); this puts an honest uncertainty on the ones already reported. Happy to follow up with a persistence skill-score baseline (the truth is already fetched for every horizon 0–48h, so it's computable straight from results_df) if there's interest.

Verification note: the metric suite runs green locally (5/5); I have not run the full run_eval pipeline (needs HF dataset access).

…a dataframe

The per-horizon MAE was printed with a +-1.96*SEM band whose SEM divided
by sqrt(50) regardless of how many rows the horizon group actually
contained, so the reported interval was wrong whenever a group had more
or fewer rows than 50 - which is essentially always (single-hour groups
vs the [0, 36] aggregate).

Replace it with a site-resampled percentile bootstrap: errors from the
same PV site share weather and hardware, so sites are the independent
unit - a plain row-level SEM would overstate the effective sample size.
metrics() now also returns the per-horizon table (n, mae, 95% CI,
normalized MAE) instead of only printing, so evaluations can be compared
programmatically; prints remain.

The previous test called metrics() on random data and asserted nothing;
the new tests pin the MAE on a known constructed error, check the CI
brackets it, narrows with more sites (the regression the hardcoded 50
hid), stays deterministic under the default seed, and that night rows
are still filtered.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant