autogluon / autogluon

Fast and Accurate ML in 3 Lines of Code
https://auto.gluon.ai/
Apache License 2.0
7.42k stars 880 forks source link

[timeseries] Does DirectTabular predict recursively? #4244

Closed samuel-woerz closed 4 weeks ago

samuel-woerz commented 1 month ago

Hi,

I am a little confused about the naming of the DirectTabular and the RecursiveTabular estimator. As far as I know, direct multi-step forecasting consists of training a different model for each step of the horizion, while recursive multi-step forecasting uses the same model recursively.

Your DirectTabular model uses the MLForecast framework and they write on their site:

> By default mlforecast uses the recursive strategy, i.e. a model is trained to predict the next value and if we’re predicting several values we do it one at a time and then use the model’s predictions as the new target, recompute the features and predict the next step.

They also support direct multi-step forecasting with one model per horizon step, but this would require calling the .fitfunction with the max_horizon argument, which I did not find in your code. Am I missing something in your implementation?

Thanks for reading :)

shchur commented 4 weeks ago

Hi @samuel-woerz, sorry for a delayed response.

The DirectTabular model does not predict the time series recursively and it uses a single tabular regressor (e.g., LightGBM model) for all future timesteps. Therefore, it's not really a direct forecasting strategy described in the doc that you shared, and the name is kind of a misnomer (it's there for historical reasons).

The way the model actually works, is by masking the unknown past time series values with NaN. The feature matrix X received by the tabular regression model looks similar to the following (assuming prediction_length = 4).

[[1, 2, 3, 4, 5],
[2, 3, 4, 5, NaN],
[3, 4, 5, NaN, NaN],
[4, 5, NaN, NaN, NaN]]