etna
etna copied to clipboard
Enabling passing context into `Model.forecast`
🚀 Feature Request
We decided that we want to enable passing context into forecast
method of the model. It will be done with a new parameter: prediction_size
. First n - prediction_size
points in a given ts
won't be forecasted and if model needs a context, it will use this points for this.
Proposal
- Add
prediction_size
parameter for the adapters.- implement separately common logic on selection of last
prediction_size
elements of prediction
- implement separately common logic on selection of last
- Add
prediction_size
parameter toforecast
method in classes:-
base.Model
-
base.ForecastAbstractModel
-
base.PredictIntervalAbstractModel
-
base.PerSegmentModel
-- determine the context needed for prediction and pass it into the adapter indf_context
parameter, if context isn't needed don't passdf_context
. -
base.PerSegmentPredictionIntervalModel
-- same as above -
base.MultiSegmentModel
-- same as above -
base.DeepBaseAbstractModel
-- renamehorizon
toprediction_size
-
base.DeepBaseModel
-- renamehorizon
toprediction_size
- add to other classes if it wasn't enough
- default value should be
None
and in the body of the function correct value is determined as a maximum possibleprediction_size
- if a too big
prediction_size
is set (not enough context) throw an error
-
- Fix
forecast
in pipelines to work with context- Fix
Pipeline.forecast
, the code should be similar to snippet withDeepBaseModel
- Fix
AutoRegressivePipeline.forecast
- Fix ensembles.
- Fix
Test cases
- Make sure current tests pass.
- Test function on selection of last
prediction_size
elements for adapters. - Test that if
prediction_size is None
then value is determined aslen(df) - context_size
. Probably, it is convenient to do with some dummy/mock model. - Test that models throw error if
prediction_size
is too big. Look above about dummy/mock. - Test that
Pipeline.forecast
passes big enough dataset according to `horizon. Look above about dummy/mock. - Test that
AutoRegressivePipeline.forecast
passes big enough dataset according tohorizon
. Look above about dummy/mock.
Additional context
- Is blocked by #844.
- Merge it into an
inference
branch.