BOT: Fix #895: Add get_non_monotonic_forecasts() and monotonicity warning#1081
Draft
nikosbosse wants to merge 1 commit intomainfrom
Draft
BOT: Fix #895: Add get_non_monotonic_forecasts() and monotonicity warning#1081nikosbosse wants to merge 1 commit intomainfrom
nikosbosse wants to merge 1 commit intomainfrom
Conversation
Add diagnostic helper and early warning for non-monotonic quantile predictions: - New exported `get_non_monotonic_forecasts()` function (modeled on `get_duplicate_forecasts()`) to identify forecast units where predicted values decrease with increasing quantile levels - New internal `check_monotonicity()` helper - Warning in `assert_forecast.forecast_quantile()` (guarded by `verbose`) so users are alerted during `as_forecast_quantile()` instead of only discovering the issue deep inside `bias_quantile()` at scoring time Also addresses #412. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1081 +/- ##
==========================================
+ Coverage 97.83% 97.86% +0.03%
==========================================
Files 35 36 +1
Lines 1845 1875 +30
==========================================
+ Hits 1805 1835 +30
Misses 40 40 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
nikosbosse
commented
Feb 13, 2026
Collaborator
Author
nikosbosse
left a comment
There was a problem hiding this comment.
CLAUDE: Review verdict — APPROVE. Clean implementation following the established get_duplicate_forecasts()/check_duplicates() pattern. Core detection logic (diff(predicted) < 0) correctly flags strictly decreasing predictions while allowing equal values. Warning (not error) in assert_forecast.forecast_quantile() is the right design choice per issue discussion. All 12 test specifications covered by 15 tests. No issues found.
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.
Summary
get_non_monotonic_forecasts()diagnostic function (modeled onget_duplicate_forecasts()) that identifies forecast units where quantile predictions are not monotonically non-decreasing with increasing quantile levelsassert_forecast.forecast_quantile()(guarded byverbose) so users are alerted atas_forecast_quantile()time rather than only discovering the issue deep insidebias_quantile()during scoringvalidate_forecast()that predictions must not decrease with quantile #412 (add monotonicity check to forecast validation)Root cause: Non-monotonic quantile predictions silently pass through
as_forecast_quantile()andassert_forecast(). The only check exists deep inbias_quantile_single_vector()as a hard error, which users only encounter atscore()time — often after significant pipeline setup.What changed:
R/get-non-monotonic-forecasts.Rwith exportedget_non_monotonic_forecasts()and internalcheck_monotonicity()assert_forecast.forecast_quantile()now callscheck_monotonicity()and emits acli_warn()when violations are foundverbose = FALSEtest-get-non-monotonic-forecasts.R+ 4 new tests intest-class-forecast-quantile.RCloses #895
Closes #412
Test plan
get_non_monotonic_forecasts()tests: well-formed data returns empty, detects violations, mixed units, counts argument, custom forecast_unit, class checks, data.frame input, equal predictions edge casecheck_monotonicity()tests: returns TRUE for good data, message string for bad dataassert_forecast.forecast_quantile()tests: warns on non-monotonic, no false positive, verbose=FALSE suppresses, end-to-end score works with bias excluded🤖 Generated with Claude Code