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

Improvement/statsforecastets: make sf_ets probabilistic + add future_covariate support for sf_ets + add AutoTheta #1476

Merged

Conversation

Beerstabr
Copy link
Contributor

@Beerstabr Beerstabr commented Jan 9, 2023

This is the first time I make contribution to a library like this, so please forgive me if I forgot to do something obvious!

Main changes:

  • StatsForecastETS is now probabilistic.
  • StatsForecasETS now uses future_covariates through first performing OLS and then perform ETS on the in-sample residuals.
  • Moved StatsForecastAutoARIMA and StatsForecastETS to the same file and extracted some (2) functions.
  • Added AutoTheta from the StatsForecast library.
  • Removed sf_auto_arima.py and sf_ets.py since the code is now already included in sf_models.py.

Let me know if you'd like something implemented in a different way. Or if you'd like me to comment a bit more on the changes I've made.

I could also have included AutoCES from StatsForecast. Let me know if you want me to include that one too.

@Beerstabr Beerstabr changed the title Improvement/statsforecastets probabilistic Improvement/statsforecastets make sf_ets probabilistic + add future_covariate support for sf_ets + add AutoTheta Jan 9, 2023
@Beerstabr Beerstabr changed the title Improvement/statsforecastets make sf_ets probabilistic + add future_covariate support for sf_ets + add AutoTheta Improvement/statsforecastets: make sf_ets probabilistic + add future_covariate support for sf_ets + add AutoTheta Jan 9, 2023
@hrzn
Copy link
Contributor

hrzn commented Jan 10, 2023

Thanks @Beerstabr, that looks very good :) will have a look in detail soon.
Regarding AutoCES, it would be a welcome addition to Darts, but could also be part of another PR later.

@codecov-commenter
Copy link

codecov-commenter commented Jan 20, 2023

Codecov Report

Base: 94.08% // Head: 94.04% // Decreases project coverage by -0.05% ⚠️

Coverage data is based on head (a0a322b) compared to base (6887ed5).
Patch coverage: 90.38% of modified lines in pull request are covered.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1476      +/-   ##
==========================================
- Coverage   94.08%   94.04%   -0.05%     
==========================================
  Files         122      125       +3     
  Lines       10981    11056      +75     
==========================================
+ Hits        10332    10398      +66     
- Misses        649      658       +9     
Impacted Files Coverage Δ
darts/models/__init__.py 57.14% <60.00%> (+1.14%) ⬆️
darts/models/components/statsforecast_utils.py 70.00% <70.00%> (ø)
darts/models/forecasting/sf_auto_arima.py 96.87% <75.00%> (+5.69%) ⬆️
darts/models/forecasting/sf_auto_theta.py 93.54% <93.54%> (ø)
darts/models/forecasting/sf_auto_ces.py 96.29% <96.29%> (ø)
darts/models/forecasting/sf_auto_ets.py 97.91% <96.29%> (ø)
darts/utils/data/tabularization.py 99.27% <0.00%> (-0.73%) ⬇️
darts/timeseries.py 92.14% <0.00%> (-0.23%) ⬇️
darts/ad/anomaly_model/filtering_am.py 91.93% <0.00%> (-0.13%) ⬇️
...arts/models/forecasting/torch_forecasting_model.py 89.52% <0.00%> (-0.05%) ⬇️
... and 3 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Contributor

@hrzn hrzn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many thanks @Beerstabr , that looks really good and we will definitely be able to include that in the next release of Darts :) I like the way future covariates are now handled.

I just have two fairly important things to ask:

  • Could you please add unit tests for anything new that you've added (1-2 tests to make sure future covariates work as expected with ETS, and adding AutoTheta to the suite of tests)
  • Could you split the models in separate files (I know i've initially suggested to regroup... but I have second thoughts because of the impact on the documentation...)

I also have a few other very minor comments, but nothing important.

@Beerstabr
Copy link
Contributor Author

@hrzn thanks for having a look!

Will work on your request and comments. They all seem totally reasonable.

Beerstabr and others added 4 commits January 26, 2023 16:31
…ents explaining the handling of future covariates by StatsForecastETS. Included StatsForecastTheta in the tests. Moved the utility functions that the statsforecast models share to a singly .py file. Added the CES model which is supposed to be probabilistic, but that doesn't work yet eventhough it is supposed to be included in statsforecast 1.4.0. Trying to figure out why it isn't working. Removed sf_models.py.
Copy link
Contributor

@hrzn hrzn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks really good, only a few minor comments/questions left. Thanks @Beerstabr !

@@ -13,7 +13,7 @@ requests>=2.22.0
scikit-learn>=1.0.1
scipy>=1.3.2
shap>=0.40.0
statsforecast>=1.0.0
statsforecast>=1.4.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure this is the lowest possible version that supports everything?
I'm double checking because the higher our lower bounds, the more stringent a condition it puts on users who may have constraints on their Pypi settings.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to look into it for a bit more. I think it might depend on if we want AutoCES to be probabilistic as well. But let me check it and I'll come back to you with the options.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hrzn, I'm sure now that it is as follows:

  • ETS (from statsforecast 1.3.2 onwards is called AutoETS) is available from 1.0.0, but only made probabilistic in 1.4.0
  • AutoTheta became available in 1.3.0 and was probabilistic from the start
  • AutoCES became available in 1.1.0 and is not yet probabilistic but will be -soon- in the next pip release (1.4.1/1.5.0?)

So if we don't choose 1.4.0 as a requirement, then we will have to drop the probabilistic nature of StatsForecastETS.
And we might want to rename StatsForecastETS to StatsForecastAutoETS, because it is also renamed by statsforecast.

What would you like me to put in there as a requirement? And do you want me to rename the ETS model?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK thanks a lot for investigating @Beerstabr .
We can keep 1.4.0 as the lower bound (and even update it once AutoCES is made probabilistic). I think that's OK because anyway all releases of statsforecast are quite recent.
I also think we should rename StatsForecastETS to StatsForecastAutoETS if they renamed it on their side.
Thanks!

…in statsforecast 1.4.0

- changed AutoETS to SFAutoETS
- added models to the base tests
- wrote two units tests for future covariates use for sf_ets
…in statsforecast 1.4.0

- changed AutoETS to SFAutoETS
- added models to the base tests
- wrote two units tests for future covariates use for sf_ets
@hrzn
Copy link
Contributor

hrzn commented Feb 7, 2023

@Beerstabr the only last thing left is to renamed the model to StatsForecastAutoETS. Let me know if you're fine with still doing this. Thanks again!

@Beerstabr
Copy link
Contributor Author

@hrzn yes, sorry forgot about it. Will change the name tonight!

Copy link
Contributor

@hrzn hrzn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot @Beerstabr ! This will go in the next release.

@hrzn hrzn merged commit e1c8d34 into unit8co:master Feb 10, 2023
alexcolpitts96 pushed a commit to alexcolpitts96/darts that referenced this pull request May 31, 2023
…covariate support for sf_ets + add AutoTheta (unit8co#1476)

* StatsForecastETS now is probabilistic in the same way as StatsForecastAutoARIMA

* include future covariates in sf_ets

* sf_ets with future_covariates works.. probably it is underestimating the uncertainty because it doesn't take into account the uncertainty of the coef esimation of the OLS

* Create separate file for StatsForecast models and extract some functions.

* Added AutoTheta from the StatsForecast package.

* Deleted sf_auto_arima.py and sf_ets.py, because the code is now included in sf_models.py.

* Update darts/models/forecasting/sf_models.py

Co-authored-by: Julien Herzen <[email protected]>

* Update darts/models/forecasting/sf_models.py

Co-authored-by: Julien Herzen <[email protected]>

* Moved all statsforecast models to their own .py file. Added some comments explaining the handling of future covariates by StatsForecastETS. Included StatsForecastTheta in the tests. Moved the utility functions that the statsforecast models share to a singly .py file. Added the CES model which is supposed to be probabilistic, but that doesn't work yet eventhough it is supposed to be included in statsforecast 1.4.0. Trying to figure out why it isn't working. Removed sf_models.py.

* Beginning of test for fit on residuals for statsforecast ets.

* - AutoCES not probablisitc anymore, because that is not yet released in statsforecast 1.4.0
- changed AutoETS to SFAutoETS
- added models to the base tests
- wrote two units tests for future covariates use for sf_ets

* - AutoCES not probablisitc anymore, because that is not yet released in statsforecast 1.4.0
- changed AutoETS to SFAutoETS
- added models to the base tests
- wrote two units tests for future covariates use for sf_ets

* Changed StatsForecastETS to StatsForecastAutoETS.

---------

Co-authored-by: Julien Herzen <[email protected]>
Co-authored-by: Julien Herzen <[email protected]>
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

Successfully merging this pull request may close these issues.

3 participants