Repository navigation
feat(conformal): add finite-sample corrected error intervals - #92
Conversation
AzulGarza
left a comment
There was a problem hiding this comment.
hey @viventriglia, thanks for this. the exact ceil((W+1)·level/100) rank with the inf sentinel is right, the tests are really thorough (the leave-one-out rank coverage one is great), and i like that the docs don't oversell exchangeability on rolling windows. also thanks for fixing the stale "must pass level or quantiles" line.
the main thing: infinite bounds are silent. with n_windows=2 (or anything under what the level needs) forecast() returns ±inf and nothing tells the user. the notebook shows it (coverage 1.0, width inf), and inf breaks plotting and anything that scores intervals. i would not rely on the docs alone here.
could we emit a UserWarning at forecast time when any requested level has rank > W? something like "level 95 needs at least 19 calibration windows, got 4; bounds are infinite". it can't live in ConformalIntervals.__post_init__ since level is not known there, so add_conformal_error_intervals (or the forecaster, right before calling the method) is the natural spot. keep the behavior itself as is, inf is the correct answer, it should just not be a surprise.
for the notebook: the 19-window rows show it working, but as a metrics table. i would add a short cell before the coverage check with a plain forecast(h=24, level=[80, 95]) using n_windows=19 on one M4 Hourly series, plotted with the finite bounds, so the reader first sees the method producing usable intervals and then sees what happens when there are too few windows.
smaller things:
max(1, ...)clamp. a comment saying level 0 is only reachable through odd quantile conversions would help, since rank 1 is not a zero width interval.- notebook wording. "corrected ranks give intervals at least as wide as the uncorrected" holds for levels ≥ 50. below that it can be narrower (your own test at level 20 shows it). fine for 80 and 95, but i would scope the sentence.
- cost note in the docs. 95% needs 19 windows, so each
forecast()runs about 20 forecasts per model, and history must be at leasth + 18 * step_size + 1observations (456+ ath=24). you mention the history part, a line on compute would help. - README. the highlight bullet became a paragraph. i would keep one sentence and link to the guide for the details.
CI has not run yet because it is a fork PR, i will approve the workflows so we get the full matrix.
wdyt?
|
Thanks @AzulGarza, agreed, and addressed all points. Infinite bounds now emit a |
AzulGarza
left a comment
There was a problem hiding this comment.
hey @viventriglia, thanks for the quick turnaround, this looks great now. approving, i'll merge once CI is green. thanks again for the contribution!:)
Merging this PR will not alter performance1 note
Comparing |
|
Thanks for enabling CI, @AzulGarza! Python 3.10/3.11, lint, docs and CodSpeed passed, while 3.12/3.13 and both replication jobs failed. Could the replication failures be related to secrets being unavailable to fork PRs? |
|
yes, @viventriglia! that's the reason, meging it now;) thanks! |
Adds opt-in
conformal_error_finite_sampleintervals using the exactceil((n + 1) * level / 100)-th absolute-error order statistic, without
interpolation. When the rank exceeds the calibration sample size,
bounds are infinite. Existing methods and defaults are unchanged.
Documents the exchangeability assumption and adds an executed M4 Hourly
rolling-origin comparison reporting coverage, width, and finite intervals.
Refs #89. This PR covers finite-sample correction; ACI and persistent
online state remain separate follow-up work.
Validation: