Hi again, I am trying to save off the fitted model...
# statsforecast
t
Hi again, I am trying to save off the fitted model for re-use with the StatsForecast.save() and StatsForecast.load() methods but am hitting the error in the SS. Code:
Copy code
from statsforecast import StatsForecast    

def fit():
    model = StatsForecast(df=panel_df,
                         models=[AutoARIMA(), SeasonalNaive(season_length=7)],
                         freq='D',
                         n_jobs=1,
                         verbose=True)
    model.fit(panel_df)
    model.save('/Users/tmb/PycharmProjects/data-science/UFE/output_files/model')
Error:
Copy code
AttributeError: type object 'StatsForecast' has no attribute 'save'
I have the latest version of the package installed (e.g. 1.6.0)
j
Hey. This was merged recently and hasn't been released. You can install from github if you want to use those methods or you can just use pickle/cloudpickle on the object:
Copy code
import pickle

with open('your_model.pkl', 'wb') as f:
    pickle.dump(model, f)
t
Ahhh thanks for the speedy reply!
Does that go for StatsForecast.plot as well?
As that doesn’t do anything when I call it.
Copy code
StatsForecast.plot(panel_df, df)
j
No, that has been there for several versions, you should be able to use it. The default engine in 1.6 is matplotlib, are you using jupyter notebooks?
t
No I running directly from a .py script in Pycharm
I thought I read that the default plotting engine is plotly, is this incorrect? That could be the issue, I don’t have matplotlib installed
Now I have installed matplotlib but it still isn’t working.
j
In 1.6 is matplotlib. You probably need to save the figure or do something with it. I don't think it's shown from a script
t
ok no worries I will figure it out.
FYI, I saved the fig and can now see it, in case anyone else has the same question.
👍 2
Copy code
x = StatsForecast.plot(panel_df)
    x.savefig('testfig.png')
r
Hi there, I'm very interested in these two methods (save and load), but I work on a poetry virtual environment. What would be the normative way of introducing these changes on the statsforecast already installed in my poetry environment?
j
We're going to make a release in the following weeks. In the meantime you can install from github, I'm not sure how to set it for poetry but you might be able to specify your requirements like
git+<https://github.com/Nixtla/statsforecast|https://github.com/Nixtla/statsforecast>
r
Thanx!