0

I am trying to reproduce this executable (https://www.kaggle.com/robinteuwens/forecasting-energy-demand) but in the section where it begins with the fit of the HoltWinters model, the jupyter notebook is hanging. .. I've been waiting more than 30 minutes and nothing!

Example of the input data

The cell (number 18 in the Kaggle example) that is taking a lot of time...

import statsmodels.api as sm

# exponential smoothing only takes into consideration patterns in the target variable
# so we discard the other features
exp_smooth_train, exp_smooth_test = train['demand_in_MW'], test['demand_in_MW']

# fit & predict
holt_winter = sm.tsa.ExponentialSmoothing(exp_smooth_train,
                                          seasonal_periods=24*365,
                                          seasonal='add').fit()
y_hat_holt_winter = holt_winter.forecast(len(exp_smooth_test))

Jackie
  • 1
  • 1
  • Perhaps because it tries to estimate `24 * 365 = 8760` parameters associated with seasonal part. You have *a lot* of samples, too; combining these it is expected to take so long... – Mustafa Aydın May 03 '21 at 11:25
  • In paragraph 3 of [this](https://otexts.com/fpp3/dhr.html), it says "*The ETS() model restricts seasonality to be a maximum period of 24 to allow hourly data but not data with a larger seasonal period. The problem is that there are m−1 parameters to be estimated for the initial seasonal states where m is the seasonal period. So for large m, the estimation becomes almost impossible.*" which is for R but idea is the same for any language really.. – Mustafa Aydın May 03 '21 at 11:27
  • I don't know how much time the Kaggler you linked to waited or how much supercompute they have but for practicality, I'd say ETS is not the way for such long seasonality. – Mustafa Aydın May 03 '21 at 11:28
  • Okey, thank you. That makes a lot of sense... what seasonal_period would you recommend to use? @mustafa-aydın – Jackie May 03 '21 at 11:43
  • I'm no expert but from the notebook's visuals the daily seasonality is apparent. So if you must use ETS perhaps you can try 24. For this kind of complex seasonality data, you may want to look at [TBATS](https://otexts.com/fpp2/complexseasonality.html#tbats-models) model which also has a Python [implementation](https://github.com/intive-DataScience/tbats). This is slow too, but may be faster than ETS in this case. – Mustafa Aydın May 03 '21 at 12:06
  • there is also [dynamic harmonic regression](https://otexts.com/fpp3/dhr.html) models (which is a fancy name for linear regression with Fourier terms) that can handle these seasonalities much faster; the trade-off being the seasonality is assumed to be constant throughout.. – Mustafa Aydın May 03 '21 at 12:07

0 Answers0