TripleExponentialSmoothing
- class hana_ml.algorithms.pal.tsa.exponential_smoothing.TripleExponentialSmoothing(alpha=None, beta=None, gamma=None, seasonal_period=None, forecast_num=None, seasonal=None, initial_method=None, phi=None, damped=None, accuracy_measure=None, ignore_zero=None, expost_flag=None, level_start=None, trend_start=None, season_start=None, prediction_confidence_1=None, prediction_confidence_2=None)
Triple exponential smoothing is used to handle the time series data containing a seasonal component.
- Parameters:
- alphafloat, optional
Weight for smoothing. Value range: 0 < alpha < 1.
Defaults to 0.1.
- betafloat, optional
Weight for the trend component. Value range: 0 <= beta < 1.
Defaults to 0.1.
- gammafloat, optional
Weight for the seasonal component. Value range: 0 < gamma < 1.
Defaults to 0.1.
- seasonal_periodint, optional
Length of a seasonal_period(should be greater than 1).
For example, the
seasonal_period
of quarterly data is 4, and theseasonal_period
of monthly data is 12.Defaults to 2.
- forecast_numint, optional
Number of values to be forecast.
Defaults to 0.
- seasonal{'multiplicative', 'additive'}, optional
Specifies the type of model for triple exponential smoothing.
'multiplicative': Multiplicative triple exponential smoothing.
'additive': Additive triple exponential smoothing.
When
seasonal
is set to 'additive', the default value of initial_method is 1; Whenseasonal
is set to 'multiplicative', the default value of initial_method is 0.Defaults to 'multiplicative'.
- initial_methodint, optional
Initialization method for the trend and seasonal components.
Defaults to 0 or 1, depending the setting of
seasonal
.- phifloat, optional
Value of the damped smoothing constant phi (0 < phi < 1).
Defaults to 0.1.
- dampedbool, optional
Specifies whether or not to use damped trend method.
False: No, uses the Holt's linear trend method.
True: Yes, use damped trend method.
Defaults to False.
- accuracy_measurestr or a list of str, optional
The metric to quantify how well a model fits input data. Options: "mpe", "mse", "rmse", "et", "mad", "mase", "wmape", "smape", "mape".
No default value.
Note
Specify a measure name if you want the corresponding measure value to be reflected in the output statistics self.stats_.
- ignore_zerobool, optional
False: Uses zero values in the input dataset when calculating "mpe" or "mape".
True: Ignores zero values in the input dataset when calculating "mpe" or "mape".
Only valid when
accuracy_measure
is "mpe" or "mape".Defaults to False.
- expost_flagbool, optional
False: Does not output the expost forecast, and just outputs the forecast values.
True: Outputs the expost forecast and the forecast values.
Defaults to True.
- level_startfloat, optional
The initial value for level component S.
If this value is not provided, it will be calculated in the way as described in Triple Exponential Smoothing.
level_start
cannot be zero. If it is set to zero, 0.0000000001 will be used instead.- trend_startfloat, optional
The initial value for trend component B.
- season_startlist of tuple/float, optional
A list of initial values for seasonal component C. If specified, the list must be of the length specified in
seasonal_period
, i.e. start values must be provided for a whole seasonal period.We can simply give out the start values in a list, where the cycle index of each value is determined by its index in the list; or we can give out the start values together with their cycle indices in a list of tuples.
For example, suppose the seasonal period is 4, with starting values \(x_i, 1 \leq i \leq 4\) indexed by their cycle ID. Then the four season start values can be specified in a list as \([x_1, x_2, x_3, x_4]\), or equivalently in a list of tuples as \([(1, x_1), (2, x_2), (3, x_3), (4, x_4)]\).
If not provided, start values shall be computed by a default scheme.
- prediction_confidence_1float, optional
Prediction confidence for interval 1.
Only valid when the upper and lower columns are provided in the result table.
Defaults to 0.8.
- prediction_confidence_2float, optional
Prediction confidence for interval 2.
Only valid when the upper and lower columns are provided in the result table.
Defaults to 0.95.
Examples
Input DataFrame df:
>>> df.collect() ID RAW_DATA 1 362.0 2 385.0 ... 23 854.0 24 661.0
Create a TripleExponentialSmoothing instance:
>>> tesm = TripleExponentialSmoothing(alpha=0.822, beta=0.055, gamma=0.055)
Perform fit_predict():
>>> tesm.fit_predict(data=df)
Output:
>>> tesm.forecast_.collect().set_index('TIMESTAMP').head(3) TIMESTAMP VALUE PI1_LOWER PI1_UPPER PI2_LOWER PI2_UPPER 5 371.288158 NaN NaN NaN NaN 6 414.636207 NaN NaN NaN NaN 7 471.431808 NaN NaN NaN NaN
>>> tesm.stats_.collect() STAT_NAME STAT_VALUE MSE 616.541542
- Attributes:
- forecast_DataFrame
Forecast values.
- stats_DataFrame
Statistics analysis content.
Methods
fit_predict
(data[, key, endog])Fit and predict based on the given time series.
- fit_predict(data, key=None, endog=None)
Fit and predict based on the given time series.
- Parameters:
- dataDataFrame
Input data. At least two columns, one is ID column, the other is raw data.
- keystr, optional
The ID column.
Defaults to the first column of data if the index column of data is not provided. Otherwise, defaults to the index column of data.
- endogstr, optional
The column of series to be fitted and predicted.
Defaults to the first non-ID column.
- Returns:
- DataFrame
Forecast values.
Inherited Methods from PALBase
Besides those methods mentioned above, the TripleExponentialSmoothing class also inherits methods from PALBase class, please refer to PAL Base for more details.