-
Notifications
You must be signed in to change notification settings - Fork 900
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/conformal prediction #2552
Merged
Merged
Conversation
This file contains 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
flaessig
reviewed
Dec 12, 2024
flaessig
reviewed
Dec 12, 2024
3 tasks
flaessig
reviewed
Dec 16, 2024
madtoinou
approved these changes
Dec 16, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks really nice, the notebook require a few adjustment/improvement and I think that this is ready to be merged.
There are a few "WIP" keyword in some docstring and in the notebook, let's maybe get ride of them ;)
flaessig
reviewed
Dec 17, 2024
Closed
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.
Checklist before merging this PR:
Fixes #1704, fixes #2161.
Short Summary
ConformalNaiveModel
, andConformalQRModel
(read more below).iws()
, and Mean Interval Winkler Scoresmiws()
(time-aggregated) (source)ic()
(binary if observation is within the quantile interval), and Mean Interval Covaragemic()
(time-aggregated)incs_qr()
, and Mean ...mincs_qr()
(time-aggregated) (source)overlap_end=True
inForecastingModel.residuals()
. This computes historical forecasts and residuals that can extend further than the end of the target series. With this, all returned residual values have the same length per forecast (the last residuals will contain missing values, if the forecasts extended further into the future than the end of the target series).Summary
Adds first conformal prediction models to Darts. Conformal models can be applied to any of Darts' global forecasting model, as long as the model has been fitted before. In general the workflow of the models to produce one forecast/prediction is as follows:
the past of your input series relative to the forecast start point. The number of calibration examples
(forecast errors / non-conformity scores) to consider can be defined at model creation
with parameter
cal_length
. Note that when usingcal_stride>1
, a longer history is required sincethe calibration examples are generated with stridden historical forecasts.
cal_stride
.creation with parameter
quantiles
).existing intervals of) the forecasting model's predictions.
Input Support
All added conformal models support the following input (depending on the fitted forecasting model):
Forecast/Output Support
All models support the following prediction modes:
quantiles=[0.05, 0.2, 0.5, 0.8, 0.95]
).cal_length
(to make the algorithm adaptive)predict_likelihood_parameters=True, num_samples=1
in all prediction methods.num_samples>>1
in all prediction methods.Requirements to use a conformal model:
n
. It must be possible to generate at leastn + cal_length
historical forecasts from the calibration input series.Added Algorithms
Added two algorithms each with two symmetry modes:
ConformalNaiveModel
: Adds calibrated intervals around the median forecast from the forecasting model.symmetric=True
:ae()
(absolute error) to compute the non-conformity scoressymmetric=False
err()
(error) to compute the non-conformity scores of the upper bounds, an-err()
for the lower bounds.ConformalQRModel
(Conformalized Quantile Regression, source): Calibrates the quantile predictions from a probabilistic forecasting model.symmetric=True
:incs_qr(symmetric=True)
(Quantile Regression Non-Conformity Score) to compute the non-conformity scoressymmetric=False
incs_qr(symmetric=False)
(Quantile Regression Non-Conformity Score) to compute the non-conformity scores for the upper and lower bound separately.