sktime / sktime

A unified framework for machine learning with time series
https://www.sktime.net
BSD 3-Clause "New" or "Revised" License
7.96k stars 1.38k forks source link

[DOC] Exponential Smoothing configuration modes #476

Open robomotic opened 4 years ago

robomotic commented 4 years ago

Describe the issue linked to the documentation

It is unclear from the documentation about how to use the constructor to achieve the different configurations for ExponentialSmoothing. With reference on page 204, section 7.4 of the book Forecasting: Principles and Practice (which is also mentioned in the source code) there are various combinations with Trend and Seasonal Component.

For example how can I achieve the (N,N) case with Simple exponential smoothing? I tried this:

forecaster = ExponentialSmoothing(trend=None, seasonal=None,optimized=True)
forecaster.fit(y_train)
y_pred = forecaster.predict(fh)
fig,ax = plot_series(y_train, y_test, y_pred, labels=["y_train", "y_test", "y_pred"]);
ax.set_title('Exponential smoothing')

I then want to see the level that would have been estimated forecaster.smoothing_level (which is referred as alpha in the book) but this is None. I also don't see a property in the code that would refer to what in the book is called lt (level different from alpha).

Suggest a potential alternative/fix

Provide example code that matches the 6 potential configurations described in the book.

mloning commented 4 years ago

Hi @robomotic, thanks for raising the issue! The reason they are different is that the book is based on the forecast library in R, our class is based on statsmodels exponential smoothing class.

One way to get the fitted parameters is to use get_fitted_params() (the interface is still experimental):

from sktime.forecasting.all import *
y = load_airline()
forecaster = ExponentialSmoothing(trend=None, seasonal=None, optimized=True)
forecaster.fit(y)
forecaster.get_fitted_params()

There is also the AutoETS class from from sktime.forecasting.ets import AutoETS, but again based on statsmodels.

A PR would be appreciated if you want to write the examples you suggest!

I also ping @HYang1996 who wrote AutoETS.

robomotic commented 4 years ago

Perfect let me play with it and will post my findings here. I can then do a pull request if you like or you can just copy and paste my code.

mloning commented 4 years ago

Yes @robomotic that would be great! Thanks!

robomotic commented 3 years ago

@mloning I have started with a Colab notebook: https://colab.research.google.com/drive/1UpGTb00pza1ss7iZ81VO_nj-xgyQTo_-?usp=sharing what I need now is the equivalent of getting the fitted values from the SK model, so I can plot the same graphs.

Thanks!

mloning commented 3 years ago

Hi @robomotic,

I had a look at the notebook and added two options to get the parameters:

Hope this helps!

robomotic commented 3 years ago

Brilliant I completed the first example, I will do the other test cases now.