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

Issue saving ForecasterSarimax object #627

Closed
tyg3rr opened this issue Jan 24, 2024 · 4 comments
Closed

Issue saving ForecasterSarimax object #627

tyg3rr opened this issue Jan 24, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@tyg3rr
Copy link
Contributor

tyg3rr commented Jan 24, 2024

Hello! First off I just want to thank you for making this library available. It's been super helpful as I work on my masters' thesis!

I have a trained ForecasterSarimax object that I'd like to save, but I'm hitting an AttributeError

save_forecaster(forecaster3, file_name='SARIMAX_001.py')

with the following error traceback:


AttributeError Traceback (most recent call last)
Cell In[599], line 1
----> 1 save_forecaster(forecaster3, file_name='SARIMAX_001.py')

File c:\Users\ljens\scoop\apps\python\current\Lib\site-packages\skforecast\utils\utils.py:1314, in save_forecaster(forecaster, file_name, verbose)
1311 joblib.dump(forecaster, filename=file_name)
1313 if verbose:
-> 1314 forecaster.summary()

AttributeError: 'ForecasterSarimax' object has no attribute 'summary'

When I save the forecaster with verbose=False I don't get the error, but then I encounter the same error when loading the forecaster:

load_forecaster('SARIMAX_001.py')


AttributeError Traceback (most recent call last)
Cell In[600], line 1
----> 1 load_forecaster('SARIMAX_001.py')

File c:\Users\ljens\scoop\apps\python\current\Lib\site-packages\skforecast\utils\utils.py:1354, in load_forecaster(file_name, verbose)
1344 warnings.warn(
1345 (f"The skforecast version installed in the environment differs "
1346 f"from the version used to create the forecaster.\n"
(...)
1350 SkforecastVersionWarning
1351 )
1353 if verbose:
-> 1354 forecaster.summary()
1356 return forecaster

AttributeError: 'ForecasterSarimax' object has no attribute 'summary'

I am having no issues saving and loading the other Forecaster objects that I created with ElasticNetCV & RandomForest. It's just SARIMAX, and I think it's related to the fact that the sarimax forecaster is wrapping the statsmodels sarimax, as opposed to the others which wrap sklearn models.

I've had other hiccups with the SarimaxForecaster, too. I noticed another issue was opened regarding the time needed for sarimax gridsearching/backtesting - I had a similar issue as that user, with muuuch smaller data. It took over 6 hours to complete my gridsearch.

Regardless, that ^^^ is just a side note. Is there a different way to save/load Sarimax forecaster objects?

@tyg3rr
Copy link
Contributor Author

tyg3rr commented Jan 24, 2024

OK I just figured out that I can load my SARIMAX forecaster if I do

load_forecaster('SARIMAX_001.py',verbose=False)

Just out of curiosity I tried it with another saved forecaster load_forecaster('ElasticNet_001.py',verbose=True) and it gave me double the output ¯\(ツ)/¯ This is in a jupyter notebook, fyi

@JoaquinAmatRodrigo
Copy link
Owner

Hi @tyg3rr
Thanks for using skforecast.

You are right, we missed adding the method summary() in the ForecasterSarimax class. Until we fix it, please use verbose=False.
Thanks a lot for reporting it!

@JoaquinAmatRodrigo
Copy link
Owner

Regarding the grid search for Sarimax, unfortunately, the fitting process of these models is quite slow. ForecasterSarimax is also compatible with the auto-arima process, these may be a much faster alternative, see an example here: https://cienciadedatos.net/documentos/py51-arima-sarimax-models-python#Model-tuning

Would you mind opening a new issue with this last topic? This will allow others to find it faster.

Thanks!

@JavierEscobarOrtiz
Copy link
Collaborator

Bug fixed in skforecast 0.12.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants