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 algorithmfunc
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.
'SESM' :
SingleExponentialSmoothing
'DESM' :
DoubleExponentialSmoothing
'TESM' :
TripleExponentialSmoothing
'AESM' :
AutoExponentialSmoothing
'BESM' :
BrownExponentialSmoothing
For more parameter mappings of hana_ml and HANA PAL, please refer to the doc page: Parameter Mappings
Examples
>>> ub = UnifiedExponentialSmoothing(func='besm', alpha=0.1, forecast_num=6, adaptive_method=False, accuracy_measure='mse', expost_flag=True)
Perform fit_predict():
>>> ub.fit_predict(data=df)
Output:
>>> ub.forecast_.collect() >>> ub.stats_.collect()
- Attributes:
- forecast_DataFrame
Forecast values.
- stats_DataFrame
Statistics.
- error_msg_DataFrame
Error message. Only valid if
massive
is True when initializing an 'UnifiedExponentialSmoothing' instance.
Methods
fit_predict
(data[, key, endog, group_key, ...])fit_prediction function for unified exponential smoothing.
- 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.
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.