Three packages, the same data, the same test year. Every model is scored three ways: one step ahead, multi-step (fed its own forecasts) and multi-output (the whole year in one shot). Click any cell to see that forecast of 1960 and the line of code behind it. Then see why the recursive LSTM went flat, and what fixed it.
Goes with Deep Forecasting: Nixtla in Python, one table, every forecasting horizonThe notebook
Fed its own forecasts, the LSTM scored 13.4 percent: worse than copying last year, in every one of the 10 runs. Here is the story in the order the video tells it. Step through it.
| Horizon | StatsForecast | MLForecast | NeuralForecast |
|---|---|---|---|
| One step ahead | cross_validation(h=1, n_windows=12, step_size=1, refit=False) in all three packages: trained once on data to December 1959, then 12 forecasts, each from real data. | ||
| Multi-step | forecast(h=12), the default | fit(train).predict(h=12), the default. The loop is inside predict. | recurrent=True on an RNN, GRU or LSTM. For any other network, a short loop of your own. |
| Multi-output | Not available: a classical model is one equation that rolls forward. | fit(train, max_horizon=12): 12 separate models, one for each month ahead. | h=12: one network with 12 outputs. |
One step ahead, every model on the board lands between 2.8 and 4.4 percent. That is the number most tutorials report. Order the rows by multi-step or by multi-output and the board looks different.
A linear regression with 12 lags, multi-output: 2.6 percent. The model for 12 months ahead was fitted on exactly that question. On a small, regular series like this one, the heavy families do not pay for themselves. On thousands of series with many features, that can change.
Every network cell is the middle of 10 runs, with its range. Train the same multi-output LSTM again with a new seed, and the year lands anywhere from 2.9 to 4.9 percent.
Try a longer memory first, if you have the data for it. Otherwise detrend and deseasonalize, and let the network learn the change. The same three horizons, drawn as blocks with a small model you can step by hand: One step, multi-step, multi-output. And why every error needs a benchmark next to it: Beat the benchmark.