Nixtla / statsforecast

Lightning ⚡️ fast forecasting with statistical and econometric models.
https://nixtlaverse.nixtla.io/statsforecast
Apache License 2.0
3.97k stars 282 forks source link

Make best fitted ARIMA an output of AutoARIMA #774

Open RickoClausen opened 9 months ago

RickoClausen commented 9 months ago

Description

I would greatly appreciate being able to access the best-fitted ARIMA model from AutoARIMA.

It is a common use case to optimize the model hyperparameters on one period and then fit and predict an ARIMA model with those hyperparameters on a different period.

jmoralez commented 8 months ago

Hey @RickoClausen, thanks for using statsforecast. If you use fit then the trained models are stored in the fitted_ attribute. The p, d, q, P, D, Q, m parameters can be retrieved with the following:

sf = StatsForecast(...)
sf.fit(...)
params = [
    [m.model_["arma"][i] for i in [0, 5, 1, 2, 6, 3, 4]]
    for m in sf.fitted_[:, 0]  # assuming AutoARIMA is the first model in the list
] 

This will create a list where each element is a list with the optimal parameters for that serie.

RickoClausen commented 8 months ago

Thanks. :) However I still think it would make sense to have a property of the Auto classes, which can return the best-fitted non-auto version of the model, entire model class instance, instead of just the parameters.