Skip to content

fix: count negative forecast samples as zero in the log1p metrics - #968

Open
ivargr wants to merge 2 commits into
masterfrom
fix/clip-negative-forecasts-in-log1p-metrics
Open

ivargr wants to merge 2 commits into
masterfrom
fix/clip-negative-forecasts-in-log1p-metrics

Conversation

@ivargr

@ivargr ivargr commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

Summary

crps_log1p and the two winkler_score_*_log1p metrics gave NaN for a forecast with a sample at -1 or below, because log1p is undefined there. The leaderboard mean skipped such a forecast for that model only, while the selection bias estimate dropped it for every model, so the two disagreed. Negative forecast samples are now counted as 0 before the transform, so every forecast gets a score.

This changes the stored values of these three metrics for backtests whose forecasts have negative samples. Samples between -1 and 0 were scored as negative log values before and are scored as 0 now.

Review needed

Review needed: check: that capping in the log1p metrics only (not in the other metrics or in the stored forecasts) is the intended place

Test plan

  • New test that the three log1p metrics score negative samples the same as samples capped at 0, per row and per sample.
  • New test that split_scores keeps the forecasts where one model has samples below -1.
  • Both fail without the change. make lint and make test pass.

@ivargr

ivargr commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

@claude review

@ivargr
ivargr marked this pull request as ready for review December 4, 2026 13:41
@claude

claude Bot commented Dec 4, 2026

Copy link
Copy Markdown

No significant findings: the cap is applied the same way in the per-sample and per-row paths of all three log1p metrics, and the new tests check the right values.

  • Needs a look, not a bug: backtest.aggregate_metrics is computed once and stored (db_worker_functions.py:317). Backtests made before this change keep their NaN-skipped or negative-log values, and prediction_monitoring_service.py:232 compares stored aggregates between a setup and its baseline backtest. A pair of old and new backtests can therefore differ in these three metrics for reasons unrelated to the models. Decide whether old backtests need recomputing or a note.

Verdict: safe to merge.

This branch has not been deployed

No deployments
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