UnifiedExponentialSmoothing

class hana_ml.algorithms.pal.unified_exponentialsmoothing.UnifiedExponentialSmoothing(func, massive=False, group_params=None, **kwargs)

The Python wrapper for SAP HANA PAL Unified Exponential Smoothing function.

The Unified Exponential Smoothing algorithms include:

  • SESM (Single Exponential Smoothing)

  • DESM (Double Exponential Smoothing)

  • TESM (Triple Exponential Smoothing)

  • BESM (Brown Exponential Smoothing)

  • AESM (Auto Exponential Smoothing)

Parameters:
funcstr

The name of a specified exponential smoothing algorithm.

The following algorithms are supported:

  • 'SESM' : Single Exponential Smoothing.

  • 'DESM' : Double Exponential Smoothing.

  • 'TESM' : Triple Exponential Smoothing.

  • 'BESM' : Brown Exponential Smoothing.

  • 'AESM' : Auto Exponential Smoothing.

massivebool, optional

Specifies whether or not to use massive mode.

  • True : massive mode.

  • False : single mode.

For parameter setting in massive mode, you could use both group_params (please see the example below) or the original parameters. Using original parameters will apply for all groups. However, if you define some parameters of a group, the value of all original parameter setting will be not applicable to such group.

An example is as follows:

In this example, as 'adaptive_method' is set in group_params for Group_1, 'accuracy_measure' is not applicable to Group_1.

Defaults to False.

group_paramsdict, optional

If massive mode is activated (massive is True), input data for exponential smoothing shall be divided into different groups with different exponential smoothing parameters applied. This parameter specifies the parameter values of the chosen exponential smoothing algorithm func w.r.t. different groups in a dict format, where keys corresponding to group ids while values should be a dict for exponential smoothing algorithm parameter value assignments.

An example is as follows:

Valid only when massive is True and defaults to None.

**kwargskeyword arguments

Arbitrary keyword arguments and please referred to the responding algorithm for the parameters' key-value pair.

For more parameter mappings of hana_ml and HANA PAL, please refer to the doc page: Parameter Mappings

Examples

Input dataframe df:

>>> df.collect()
ID        RAWDATA
 1          143.0
 2          152.0
 3          161.0
 4          139.0
 5          137.0
 ...

Create an UnifiedExponentialSmoothing instance:

>>> ub = UnifiedExponentialSmoothing(func='besm',
                                     alpha=0.1,
                                     forecast_num=6,
                                     adaptive_method=False,
                                     accuracy_measure='mse',
                                     expost_flag=True,
                                     prediction_confidence_1=0.8,
                                     prediction_confidence_2=0.95)

Perform fit on the given data:

>>> ub.fit_predict(data=df)

Output:

>>> ub.forecast_.collect().set_index('TIMESTAMP').head(6)
TIMESTAMP      VALUE
        2  143.00000
        3  144.80000
        4  148.13000
        5  146.55600
        6  144.80550
        7  150.70954
>>> ub.stats_.collect()
STAT_NAME       STAT_VALUE
      MSE       474.142004
Attributes:
forecast_DataFrame

Forecast values.

stats_DataFrame

Statistics analysis content.

error_msg_DataFrame

Error message. Only valid if massive is True when initializing an 'UnifiedExponentialSmoothing' instance.

Methods

build_report()

Generate the time series report.

fit_predict(data[, key, endog, group_key, ...])

fit_prediction function for unified exponential smoothing.

generate_html_report([filename])

Display function.

generate_notebook_iframe_report()

Display function.

fit_predict(data, key=None, endog=None, group_key=None, build_report=False)

fit_prediction function for unified exponential smoothing.

Parameters:
dataDataFrame

Training data.

keystr, optional

Name of 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 column of data after eliminating key column.

group_keystr, optional

The column of group_key. Data type can be INT or NVARCHAR/VARCHAR.

If data type is INT, only parameters specified in group_params in class instance initialization are valid.

This parameter is only valid when massive mode is activated(i.e. massive is set as True in class instance initialization).

Defaults to the first column of data if the index columns of data is not provided. Otherwise, defaults to the first column of index columns.

build_reportbool, optional

Whether to build a time series report or not.

Example:

>>> from hana_ml.visualizers.unified_report import UnifiedReport
>>> ub = UnifiedExponentialSmoothing(func='besm')
>>> ub.fit_predict(data=df, build_report=True)
>>> UnifiedReport(ub).display()

Defaults to False.

Returns:
DataFrame

Forecast values.

build_report()

Generate the time series report.

Examples

>>> from hana_ml.visualizers.unified_report import UnifiedReport
>>> ub = UnifiedExponentialSmoothing(func='besm')
>>> ub.fit_predict(data=df)
>>> ub.build_report()
>>> UnifiedReport(ub).display()
generate_html_report(filename=None)

Display function.

property fit_hdbprocedure

Returns the generated hdbprocedure for fit.

generate_notebook_iframe_report()

Display function.

property predict_hdbprocedure

Returns the generated hdbprocedure for predict.

Inherited Methods from PALBase

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