HoltWinters¶
Holt-Winters forecaster.
This is a standard implementation of the Holt-Winters forecasting method. Certain parametrisations result in special cases, such as simple exponential smoothing.
Optimal parameters and initialisation values can be determined in a batch setting. However, in an online setting, it is necessary to wait and observe enough values. The first k = max(2, seasonality)
values are indeed used to initialize the components.
Level initialization
Trend initialization
Trend initialization
Parameters¶
-
alpha
Smoothing parameter for the level.
-
beta – defaults to
None
Smoothing parameter for the trend.
-
gamma – defaults to
None
Smoothing parameter for the seasonality.
-
seasonality – defaults to
0
The number of periods in a season. For instance, this should be 4 for quarterly data, and 12 for yearly data.
-
multiplicative – defaults to
False
Whether or not to use a multiplicative formulation.
Examples¶
>>> from river import datasets
>>> from river import metrics
>>> from river import time_series
>>> dataset = datasets.AirlinePassengers()
>>> model = time_series.HoltWinters(
... alpha=0.3,
... beta=0.1,
... gamma=0.6,
... seasonality=12,
... multiplicative=True
... )
>>> metric = metrics.MAE()
>>> time_series.evaluate(
... dataset,
... model,
... metric,
... horizon=12
... )
+1 MAE: 25.899087
+2 MAE: 26.26131
+3 MAE: 25.735903
+4 MAE: 25.625678
+5 MAE: 26.093842
+6 MAE: 26.90249
+7 MAE: 28.634398
+8 MAE: 29.284769
+9 MAE: 31.018351
+10 MAE: 32.252349
+11 MAE: 33.518946
+12 MAE: 33.975057
Methods¶
clone
Return a fresh estimator with the same parameters.
The clone has the same parameters but has not been updated with any data. This works by looking at the parameters from the class signature. Each parameter is either - recursively cloned if it's a River classes. - deep-copied via copy.deepcopy
if not. If the calling object is stochastic (i.e. it accepts a seed parameter) and has not been seeded, then the clone will not be idempotent. Indeed, this method's purpose if simply to return a new instance with the same input parameters.
forecast
Makes forecast at each step of the given horizon.
Parameters
- horizon (int)
- xs (list) – defaults to
None
learn_one
Updates the model.
Parameters
- y (float)
- x (dict) – defaults to
None