Repository navigation
fix(metrics): compute the exact log-normal CRPS - #524
Merged
Merged
Conversation
CRPS(family="lognormal") shared the Gaussian branch with "normal" and scored the targets against N(loc, scale), although loc and scale are the mean and standard deviation of log(y). Use the closed-form log-normal CRPS (Baran & Lerch, 2015), including targets below the support, and update the CRPS docstring and the metrics API page. Fixes #523
mkumar73
approved these changes
Nov 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #523
Problem
CRPS.__call__handledfamily="lognormal"in the same branch as"normal"and computedproperscoring.crps_gaussian(y, mu=loc, sig=scale). ForLogNormalDistribution,locandscaleare the mean and standard deviation oflog(y), so outcome-scale targets were scored against a normal distribution on the log scale. A well-calibrated log-normal prediction scored about 59.6 where the exact CRPS is 2.49.Fix
deeptab/metrics/distributional.pyadds a closed-form_lognormal_crps(y, loc, scale)(Baran & Lerch, 2015). For observationsy <= 0, below the support, it usesE[X] - y - E|X - X'| / 2.CRPS(family="lognormal")uses it directly, so it no longer needsproperscoringor falls back to MAE without it. The other families are unchanged.Tests
tests/metrics/test_distributional_metrics.py::TestDistributionalMetrics::test_lognormal_crps_matches_numerical_integrationcompares against numerical integration of the CRPS definition, including a negative target. It fails onmainand passes with this change.Docs
CRPSdocstring, in its summary and in the family notes, states thatlognormaluses the exact closed form with log-scaleloc/scale.docs/api/metrics/index.rst: the CRPS warning and the metrics table row now describe the normal and lognormal layouts as exact.Checks
just test: 3237 passed, 46 skipped, 28 xfailed; coverage 91.30%just docs: build succeeded (warnings treated as errors)just check: all hooks passed (ruff, prettier, pyright)NegativeBinomialDeviance(fix(metrics): use the size r = 1 / alpha in NegativeBinomialDeviance #506),StudentTLoss(fix(metrics): score any positive df in StudentTLoss #522) andNegativeLogLikelihood(fix(metrics): flatten column-vector targets in NegativeLogLikelihood #509) are fixed in separate PRs that touch other parts of the same file. I checked that all four merge cleanly together and thattests/metricspasses on the combination.