Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: method to save fitted models #442

Closed
sammiller06 opened this issue Mar 14, 2023 · 2 comments
Closed

Feature request: method to save fitted models #442

sammiller06 opened this issue Mar 14, 2023 · 2 comments

Comments

@sammiller06
Copy link

Description

StatsForecast currently lacks a method to save fitted models to disk.

Currently pickling the models that I access with the following snippet:

fitted_models = sf.fit().fitted_

Use case

This would be helpful in use cases where we want to call predict() separately on a pre-trained model.

@philippschmalen
Copy link

You could use joblib to store model artifacts.
Here is an example

import joblib
from statsforecast import StatsForecast
from statsforecast.models import MSTL, SeasonalNaive

season_length = 24

sf = StatsForecast(
    df=df,  # assume you have a dataframe loaded
    freq="H",
    n_jobs=-1,
    models=[
        MSTL(
            season_length=[
                season_length,
                season_length * 90,
            ],
        ),
    ],
    fallback_model=SeasonalNaive(season_length=season_length),
)

sf.fit()

# store StatsForecast predictor in joblib
model_filename = "model/mstl.joblib"
joblib.dump(sf, model_filename)

# load from file
model = joblib.load(model_filename)
forecast = model.predict(h=30, level=[90])

@jmoralez
Copy link
Member

jmoralez commented Jan 3, 2024

I believe this was fixed by #667

@jmoralez jmoralez closed this as completed Jan 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants