# Holt-Winters Methods¶

This module contains four exponential smoothing algorithms.

They are Holt’s linear trend method and Holt-Winters seasonal methods (additive and multiplicative). The fourth method is the double seasonal exponential smoothing method with AR(1) autocorrelation and no trend.

References:

Hyndman, R. J.; Athanasopoulos, G. (2013) Forecasting: principles and practice. http://otexts.com/fpp/

Byrd, R. H.; Lu, P.; Nocedal, J. A Limited Memory Algorithm for Bound Constrained Optimization, (1995), SIAM Journal on Scientific and Statistical Computing, 16, 5, pp. 1190-1208.

Taylor, W James, (2003); Short-Term Electricity Demand Forecasting Using Double Seasonal Exponential Smoothing, Journal of the Operational Research Society

linear(x, forecast, alpha=None, beta=None)[source]

Returns a forecast calculated with linear exponential smoothing. If alpha or beta are None, the method will optimize the MSE() and find the most suitable parameters. The method returns these optimized parameters and also the one-step-forecasts, for each value of x.

Parameters: x (list) – the series to be forecasted forecast (int) – the timeperiod of the forecast. F.e. forecast=24*7 for one week (assuming hourly data) alpha (float) – the level component beta (float) – the trend component (forecast, parameters, one-step-forecasts)
additive(x, m, forecast, alpha=None, beta=None, gamma=None, initial_values_optimization=[0.002, 0.0, 0.0002], optimization_type='MSE')[source]

Returns a forecast calculated with the seasonal exponential smoothing method (additive Holt-Winters). This method will consider seasonality and can be configured by setting the length of the seasonality m. If alpha or beta or gamma are None, the method will optimize the MSE() and find the most suitable parameters. The method returns these optimized parameters and also the one-step-forecasts, for each value of x.

If optimization is used, a list of starting parameters can be supplied by initial_values_optimization. The algorithm will start searching in the neighbourhood of these values. It can’t be guaranteed, that all values in the boundaries (0,1) are considered.

Parameters: x (list) – the series to be forecasted m (int) – the seasonality, f.e. m=24 for daily seasonality (a daily cycle in data is expected) forecast (int) – the timeperiod of the forecast. F.e. forecast=24*7 for one week (assuming hourly data) alpha (float) – the level component beta (float) – the trend component gamma (float) – the seasonal component component initial_values_optimization (list) – a first guess of the parameters to use when optimizing. optimization_criterion (string) – type of minimization measure, if minimization is used “MSE” - use MSE() “MASE” - use MASE() (slowest) (forecast, parameters, one-step-forecasts)
multiplicative(x, m, forecast, alpha=None, beta=None, gamma=None, initial_values_optimization=[0.002, 0.0, 0.0002], optimization_type='MSE')[source]

This method uses the multiplicative Holt-Winters method. It often delivers better results for our use-case than the additive method. For parameters, see additive() .

double_seasonal(x, m, m2, forecast, alpha=None, beta=None, gamma=None, delta=None, autocorrelation=None, initial_values_optimization=[0.1, 0.0, 0.2, 0.2, 0.9], optimization_type='MSE')[source]

Returns a forecast calculated with the double seasonal holt-winters method ( Taylor 2003 ). This method considers two seasonalies. This is great for electrical demand forecasting, as demands have daily and weekly seasonalities. The method also uses autocorrelation, to forecast patterns in residuals. The trend component is ignored for this method, as electrical demands mostly dont have a trend.

Parameters: m (int) – intraday seasonality (m = 24, for hourly data) m2 (int) – intraweek seasonality (m = 24*7, for hourly data) (forecast, parameters, one-step-forecasts)
MSE(params, *args)[source]

Internal Method. Calculates the Mean Square Error of one run of holt-winters with the supplied arguments. The MSE is actually computed from the MSE of the one-step-forecast error and the error between the forecast and a testseries.

Parameters: params (list) – (alpha, ...) the parameters *args (list) – (input_series, hw type, m), with hwtype in [0:3] depicting hw method
MASE(params, *args)[source]

Calculates the Mean-Absolute Scaled Error (see server.forecasting.forecasting.StatisticalForecast.MASE()). For parameters see MSE().

## Choltwinters — Holt-Winters Extensions¶

This module contains an optimized version of the Holt-Winters double-seasonal method and the multiplicative method.

The functions in this module should deliver the same results as the unoptimized version in holt_winters. Just import the double_seasonal() from this module instead of the one in holt_winters.py. This module has to be compiled with Cython, it introduces statically typed variables and optimizes array usage and can therefore get speedups up to 100x. Note that the optimizing function differs from the normal version, as it first searches the global boundaries and then does a extremely accurate local search. This leads to results very close to the absolute optimum.

To build this module, use the build_holtwinters_extension() function. If it suceeds, a .pyd extension is built, which can be used like a normal python module. An example for importing and building the extension can be seen in server.forecasting.forecasting (source).