https://github.com/nixtla logo
g

Gerard Conangla Planes

06/29/2023, 2:40 PM
Hello Nixtla team, I have a question regarding statsforecast models: how can I save them to reuse them between sessions? I can't seem to find a "save" or "load" method, for the ARIMA method for example, in the documentation. If there is nothing out of the box, what do you recommend? Something like joblib?
a

Akmal Soliev

06/29/2023, 2:59 PM
Literally worked on that today 😄 So, at current moment, this is what I came to:
Copy code
from statsforecast import StatsForecast
from statsforecast.models import (
    AutoARIMA,
)
# Create a list of models and instantiation parameters
models = [
    AutoARIMA(season_length=24),
]
# Instantiate StatsForecast class as sf
sf = StatsForecast(
    df=Y_df, 
    models=models,
    freq='H', 
    n_jobs=-1,
    verbose=True
)
sf.fit()
fitted_model = sf.fitted_
# save the models with pickle
step 2 loading:
Copy code
empty_models = []
sf2 = StatsForecast(
    df=Y_df, 
    models=test_models,
    freq='H', 
    n_jobs=-1,
    verbose=True
)
sf2.models = fitted_model
fitted_model
is multi-dim array that you can use to index it based on the prefered model and its iterations
d

Deepanjan Datta

09/24/2023, 4:58 PM
Hi @Akmal Soliev, I am trying to load an already trained MLForecast model for reuse. Is there anyway out for this ? will this "fitted_" method work for MLForecast as well ?