Tia Guo
11/03/2022, 7:49 PMfede (nixtla) (they/them)
11/03/2022, 7:55 PMStatsForecast
you can recover the fitted values using fitted=True
in the forecast
method. After that, you just have to call forecast_fitted_values()
without parameters to obtain the insample forecasts. Here’s a complete example,from statsforecast import StatsForecast
from statsforecast.models import AutoARIMA, ETS, RandomWalkWithDrift
from statsforecast.utils import AirPassengersDF as Y_df
sf = StatsForecast(df=Y_df,
models=[AutoARIMA(season_length=12), ETS(season_length=12), RandomWalkWithDrift()],
freq='M')
forecasts = sf.forecast(h=12, fitted=True)
insample = sf.forecast_fitted_values()
Tia Guo
11/03/2022, 7:56 PMfede (nixtla) (they/them)
11/03/2022, 7:57 PMTia Guo
11/03/2022, 7:59 PMfede (nixtla) (they/them)
11/03/2022, 8:00 PMlevel
to forecast
right?Tia Guo
11/03/2022, 8:00 PMfede (nixtla) (they/them)
11/03/2022, 8:03 PMTia Guo
11/03/2022, 8:03 PMfede (nixtla) (they/them)
11/03/2022, 8:06 PMTia Guo
11/03/2022, 8:10 PMfede (nixtla) (they/them)
11/03/2022, 8:10 PMTia Guo
11/03/2022, 8:12 PMfede (nixtla) (they/them)
11/04/2022, 5:46 PMfallback_model.
The main idea behind it is that you can pass a safe model in case that a main model fails. So, StatsForecast tries to fit the main models for each time series and if something fails, it will fit a safer model, for example, Naive().
The code would be,
StatsForecast(models=[AutoARIMA(), ETS()], fallback_model=Naive(), extra params)
Please let us know if that works for your use case. 🙂Tia Guo
11/04/2022, 6:03 PM