SingleExponentialSmoothing

class hana_ml.algorithms.pal.tsa.exponential_smoothing.SingleExponentialSmoothing(alpha=None, delta=None, forecast_num=None, adaptive_method=None, accuracy_measure=None, ignore_zero=None, expost_flag=None, prediction_confidence_1=None, prediction_confidence_2=None)

Single exponential smoothing is suitable to model the time series without trend and seasonality. In the model, the smoothed value is the weighted sum of previous smoothed value and previous observed value. PAL provides two simple exponential smoothing algorithms: single exponential smoothing and adaptive-response-rate simple exponential smoothing. The adaptive-response-rate single exponential smoothing algorithm may have an advantage over single exponential smoothing in that it allows the value of alpha to be modified.

Parameters:
alphafloat, optional

The smoothing constant alpha for single exponential smoothing, or the initialization value for adaptive-response-rate single exponential smoothing.

Valid range is (0, 1).

Defaults to 0.1 for single exponential smoothing, and 0.2 for adaptive-response-rate single exponential smoothing.

deltafloat, optional

Value of weighted for At and Mt(relative for the computation of adaptive smoothing parameter).

The definitions of At and Mt are stated in SAP HANA PAL Single Exponential Smoothing

Only valid when adaptive_method is True.

Defaults to 0.2.

forecast_numint, optional

Number of values to be forecast.

Defaults to 0.

adaptive_methodbool, optional
  • False: Single exponential smoothing.

  • True: Adaptive-response-rate single exponential smoothing.

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.

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

>>> sesm = SingleExponentialSmoothing(adaptive_method=False,
                                      accuracy_measure='mse',
                                      alpha=0.1,
                                      delta=0.2,
                                      forecast_num=12,
                                      expost_flag=True)

Perform fit_predict():

>>> sesm.fit_predict(data=df)

Output:

>>> sesm.forecast_.collect()
>>> sesm.stats_.collect()
Attributes:
forecast_DataFrame

Forecast values.

stats_DataFrame

Statistics.

Methods

fit_predict(data[, key, endog])

Fit and predict based on the given time series.

get_model_metrics()

Get the model metrics.

get_score_metrics()

Get the score metrics.

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.

get_model_metrics()

Get the model metrics.

Returns:
DataFrame

The model metrics.

get_score_metrics()

Get the score metrics.

Returns:
DataFrame

The score metrics.

Inherited Methods from PALBase

Besides those methods mentioned above, the SingleExponentialSmoothing class also inherits methods from PALBase class, please refer to PAL Base for more details.