Skip to content

[FEAT] Add conformal_error prediction intervals method - #1175

Merged
Saul (nasaul) merged 6 commits into
Nixtla:mainfrom
DresdenGman:feature/conformal-error-clean
Jul 13, 2026
Merged

Saul (nasaul) merged 6 commits into
Nixtla:mainfrom
DresdenGman:feature/conformal-error-clean

Conversation

@DresdenGman

Copy link
Copy Markdown
Contributor

Adds the conformal_error prediction intervals method, which uses quantiles of the conformity scores as the error margin for prediction intervals. This is a companion to the existing conformal_distribution method.

Changes:

  • Add _add_conformal_error_intervals() function to models.py
  • Enable "conformal_error" in _get_conformal_method()
  • Add test test_conformal_error_intervals

@nasaul Saul (nasaul) left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for picking this up. However, there's a blocker outside the diff plus two issues in the new code (inline comments below).

Blocker: the method can't actually be enabled. ConformalIntervals.__init__ in python/statsforecast/utils.py still has allowed_methods = ["conformal_distribution"], so ConformalIntervals(method="conformal_error") — the only public entry point, and what the new test constructs — raises ValueError. I ran test_conformal_error_intervals locally and it fails at exactly that line. Please add "conformal_error" to allowed_methods and update the class docstring there as well.

Given that gate was missed, it would also be worth adding one end-to-end test through a real model (e.g. AutoARIMA(prediction_intervals=ConformalIntervals(method="conformal_error")) via StatsForecast.forecast) so the public path is exercised.

Comment thread python/statsforecast/models.py Resolved
Comment thread python/statsforecast/models.py Resolved
Comment thread tests/test_models.py Resolved
Comment thread tests/test_models.py Resolved
@nasaul Saul (nasaul) changed the title add conformal_error prediction intervals method [FEAT] Add conformal_error prediction intervals method Jul 10, 2026
…lumn ordering, and test strength

- utils.py: add 'conformal_error' to ConformalIntervals allowed_methods
- models.py: fix quantile cut from 1-alpha/200 to correct lv/100
- models.py: fix column output order to match conformal_distribution convention
- test_models.py: add exact-value assertions to catch quantile formula errors
…lumn ordering, and test strength

- utils.py: add 'conformal_error' to ConformalIntervals allowed_methods
- models.py: fix quantile cut from 1-alpha/200 to correct lv/100
- models.py: fix column output order to match conformal_distribution convention
- test_models.py: add exact-value assertions to catch quantile formula errors
- models.py: remove redundant .keys() calls in _get_conformal_method
- models.py: clarify _add_conformal_error_intervals docstring
- Cache quantile computations instead of recomputing 4 times
- Note that symmetry assertions are implied by exact-value checks
- Reduce n_windows from 10 to 2 (minimum; ZeroModel is deterministic)
- Add sync comment between allowed_methods and _get_conformal_method
@DresdenGman

Copy link
Copy Markdown
Contributor Author

Thanks for the thorough review — all four points addressed:

  • allowed_methods gate: added "conformal_error" to ConformalIntervals.__init__ and updated the class docstring.
  • Quantile cut: changed from 1 - alpha / 200 to lv / 100. On absolute scores this is the correct split-conformal cut, and it brings the method in line with mlforecast and the equivalent path through conformal_distribution.
  • Column ordering: switched to compute all quantiles first, then emit lo in descending level order and hi in ascending — matches conformal_distribution's output convention.
  • Test strength: added exact-value assert_allclose against np.quantile(cs, 0.9/0.8, axis=0). These would have caught the quantile formula bug even without the visual key-order assertion.

I haven't added an end-to-end test through AutoARIMA + StatsForecast.forecast yet — let me know if you'd like that in this PR or as a follow-up.

@nasaul

Copy link
Copy Markdown
Contributor

Hello Dresden Goehner (@DresdenGman) have you pushed the changes? I cannot see anything from this side.

@DresdenGman

Copy link
Copy Markdown
Contributor Author

Sorry about that — the fix commits were on a different branch. Just force-pushed them to the PR branch — you should see 3 new commits from 2026-07-10 now.

@codspeed

codspeed Bot commented Jul 13, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 38 untouched benchmarks


Comparing DresdenGman:feature/conformal-error-clean (693015e) with main (ecb1e86)

Open in CodSpeed

@nasaul Saul (nasaul) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution. Happy forecasting

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.

2 participants