awslabs / gluonts

Probabilistic time series modeling in Python
https://ts.gluon.ai
Apache License 2.0
4.56k stars 748 forks source link

Extend `Predictor` interface to support variable prediction length #2785

Open lostella opened 1 year ago

lostella commented 1 year ago

Description

Currently, predictors are configured with a fixed prediction_length at construction time, and they will only yield forecasts of that length. This is somewhat limiting, and we could have the model support something like

forecasts = predictor.predict(data, prediction_length=42)

This would allow training a model once, and be able to use it for predictions of different length without retraining (in case of global models).

Some types of models (e.g. local ones) should be able support this natively. Some types of global models (state-space models, or autoregressive RNN models such as DeepAR) could in principle support this natively, by just unfolding their dynamics for as long as requested (as long as inputs, such as features, are provided for long enough). Other global models such as sequence-to-sequence would not support this natively, but one can think of reiterating the model by taking some statistics from the prediction as "ground truth" each time, until enough prediction length is covered.

lostella commented 1 year ago

Related to #1998

jaheba commented 1 year ago

Would that mean that the prediction_length argument to predict is mandatory? If a model is trained with a specific value that could become the default. On the other hand this might be confusing since models would behave differently.

lostella commented 1 year ago

I think having the argument mandatory would not be that bad: you have a model, you ask for predictions of length prediction_length. From the user perspective, it makes sense I think.

Of course it would be very breaking, so we could have the "default prediction length" behaviour as (deprecated) default for the transition, if we decide to go ahead with this.

gul1lis commented 1 year ago

This feature would be very useful for our use case. I'm not sure if I understood correctly your last point regarding seq2seq models. As we use an MQCNN, would we already be able to extend our prediction length by:

  1. making predictions for our current time window,
  2. appending those predictions to our data variable,
  3. calling predictor.predict() again, thus doubling our time window?