Add probabilistic ensemble evaluation metrics (CRPS, spread-skill ratio, rank histogram) - #4
Add probabilistic ensemble evaluation metrics (CRPS, spread-skill ratio, rank histogram)#4GiGiKoneti wants to merge 10 commits into
Conversation
…semble evaluation Adds probabilistic ensemble evaluation metrics to mllam-verification, as proposed in issue mllam#3 and approved by @mfroelund. New functions in statistics.py: - crps(): wraps scores.probability.crps_for_ensemble via compute_pipeline_statistic, following the same pattern as rmse() and mae(). Uses the fair (unbiased) estimator. Accepts any ensemble_member_dim name. - spread_skill_ratio(): computes ensemble spread / RMSE of ensemble mean. SSR = 1.0 indicates perfect calibration. SSR < 1.0 indicates underdispersion. New function in plot.py: - plot_rank_histogram(): wraps scores.plotdata.rank_histogram to produce a Talagrand diagram. Includes a reference line for perfect calibration. New test fixture in conftest.py: - da_ensemble_prediction_2d_utc: 10-member ensemble DataArray built from the existing deterministic prediction fixture. All functions follow the existing architecture exactly: compute_pipeline_statistic backbone, Google-style docstrings, cell_methods CF-convention attribute, 90-char line length. No new dependencies introduced. All functions use the existing scores>=1.2.0 dependency already pinned in pyproject.toml. Closes mllam#3
|
@mfroelund.. PR ready for your review when you get a chance |
mfroelund
left a comment
There was a problem hiding this comment.
Hi! Sorry for the delay. I've made the review, and it generally looks great! I've just added a few minor comments/suggestions.
…ove imports - Remove unused groupby parameter from crps() and spread_skill_ratio() - Swap argument order to (ds_reference, ds_prediction) matching plot calling convention and mae() signature - Add preserve_dims support to spread_skill_ratio() for hovmoller plots - Move matplotlib/plot_rank_histogram imports to top of test_plot.py - Add crps and spread_skill_ratio to timeseries/hovmoller test parametrizations - Add da_ensemble_prediction_2d_elapsed fixture for elapsed-time tests - Update test_statistics.py to match new argument order All 38 tests pass. Pre-commit hooks (isort, black, flake8, mypy) clean.
|
I think now it should be okay @mfroelund . |
mfroelund
left a comment
There was a problem hiding this comment.
Thanks for your edits. Just one last small addition :)
…nable groupby support
|
Hey @mfroelund! Just wrapped your last bit of feedback on the "unexpected input" tests. I've added Should be good to go for final review now. Thanks for all the guidance! |
|
Another thing @mfroelund Based on my work so far, here are a few ideas that could really level up the repo:
Lmk what you think 🙂 |
Thanks for the final adjustments, looks great! Just realized, that we don't have a changelog in this repo. Do you mind adding one in this PR? |
|
@mfroelund I've updated the CHANGELOG.md and ensured it follows the same style as the neural-lam repository, including PR links and contributor handles. Ready for review! |
|
I'm ready to merge, when linting passes:) |
there's an ongoing GitHub Actions outage failing the cache download right now.. |
|
@mfroelund |
|
@mfroelund |
No I have no idea, but now it seems to be resolved! |
Describe your changes
mllam-verificationcurrently only covers deterministic metrics(
rmse,mae). This PR adds the probabilistic ensemble evaluationsuite proposed in issue #3 and approved by @mfroelund.
Three new functions following the exact
compute_pipeline_statisticarchitecture already established in
statistics.pyandplot.py:statistics.pycrps()— wrapsscores.probability.crps_for_ensembleviacompute_pipeline_statistic, mirroring howrmsewrapsscores.continuous.rmse. Uses the fair (unbiased) estimator(Zamo & Naveau 2018) which correctly accounts for finite ensemble
size. Accepts a configurable
ensemble_member_dimparameter.spread_skill_ratio()— computes ensemble spread divided by RMSEof the ensemble mean. A perfectly calibrated ensemble has SSR = 1.0.
Values below 1.0 indicate underdispersion.
plot.pyplot_rank_histogram()— wrapsscores.plotdata.rank_histogramtoproduce a Talagrand diagram. Includes a dashed reference line
marking perfect calibration.
tests/unit/conftest.pyda_ensemble_prediction_2d_utcfixture — a 10-member ensembleDataArraybuilt from the existing deterministic prediction fixtureby adding Gaussian noise per member.
No new dependancies introduced. All three functions use the existing
scores>=1.2.0dependency already pinned inpyproject.toml.All 34 tests pass. Pre-commit hooks (
isort,black,flake8,mypy) pass cleanly at the 90-char line length.Note: no CHANGELOG file exists in the repository currently.
Issue Link
Closes #3
Type of change
Checklist before requesting a review
Checklist for reviewers
Each PR comes with its own improvements and flaws. The reviewer should check the following:
Author checklist after completed review
reflecting type of change (add section where missing):
Checklist for assignee