3

I have implemented the Holt-Winters model via Statsmodels in my script and I can make predictions with it but I manually set the alpha beta and gamma hyperparameters. According to you, what would be the fastest way to get the ideal values for those parameters with my dataset and how to implement it? Is there any auto optimization for the Holt-Winters just like Auto Arima? You can find my Python code below:

sample file:

https://ufile.io/e3zqs

from statsmodels.tsa.api import ExponentialSmoothing
import pandas as pd
import numpy as np


df = pd.read_excel("C:\\Users\\YannickLECROART\\Documents\\Python\\temprennes.xlsx", index_col=0)

df = df.fillna(0)

df.index = pd.to_datetime(df.index)

# our guessed parameters
alpha = 0.4
beta = 0.2
gamma = 0.01

# initialise model
ets_model = ExponentialSmoothing(df_data, trend='add', seasonal='add', 
seasonal_periods=12)
ets_fit = ets_model.fit(smoothing_level=alpha, smoothing_slope=beta,
smoothing_seasonal=gamma)

# forecast p hours ahead
p_ahead = 12
yh = ets_fit.forecast(p_ahead)
Synox
  • 89
  • 3
  • 6
  • As you tagged, I think the best solution will be a [grid search](https://scikit-learn.org/stable/modules/generated/sklearn.model_selection.GridSearchCV.html#sklearn.model_selection.GridSearchCV), which can also be parallelized via the `n_jobs` argument. – Thomas Lang Jan 25 '19 at 07:41
  • Could you show me how to implement it in my code? Thanks in adavance. – Synox Jan 25 '19 at 07:51
  • [Here](https://scikit-learn.org/stable/modules/grid_search.html#grid-search) is a quite extensive tutorial on how to use this grid search. Give it a try, it should be easy to use. – Thomas Lang Jan 25 '19 at 07:54
  • 1
    Nope, Grid Search would not be the best, I think, because it will only try some discrete values of your choice. You can try an optimization approach instead. I.e. look here for complete implementation details https://nbviewer.jupyter.org/github/Yorko/mlcourse_open/blob/master/jupyter_english/topic09_time_series/topic9_part1_time_series_python.ipynb?flush_cache=true – Artem Trunov Jan 25 '19 at 09:59

0 Answers0