UnifiedTimeSeries¶
- class hana_ml.algorithms.pal.unified_timeseries.UnifiedTimeSeries(func, split_method='none', fold_num=None, gap_num=None, percentage=None, **kwargs)¶
The Python wrapper for SAP HANA PAL Unified Time Series function. The Unified Time Series algorithms include:
Additive Model Time Series Analysis (AMTSA)
Auto Regressive Integrated Moving Average (ARIMA)
Bayesian Structural Time Series (BSTS)
Exponential Smoothing (SMOOTH)
- Parameters
- funcstr
The name of a specified time series algorithm.
The following algorithms are supported:
'AMTSA': Additive Model Time Series Analysis
'ARIMA': Auto Regressive Integrated Moving Average
'BSTS': Bayesian Structural Time Series
'SMOOTH': Auto Exponential Smoothing
- split_method{'none', 'rocv', 'blocked'}, optional
Specifies the split method for evaluation.
Set to 'rocv' or 'blocked' to enable model evaluation.
Defaults to 'none'.
- fold_numint, optional
Specifies the fold number for cross validation.
Defaults to 5.
Valid only if
split_methodis either 'rocv' or 'blocked'.- gap_numint, optional
Specifies the number of samples to exclude from the end of each train set before the test set.
Defaults to 0.
Valid only if
split_methodis either 'rocv' or 'blocked'.- percentagefloat, optional
Specifies the percentage between training and test data.
Valid only if
split_methodis 'blocked'.- **kwargskeyword arguments
Arbitrary keyword arguments and please refer to the corresponding algorithm for the parameters' key-value pair.
'AMTSA' :
AdditiveModelForecastAMTSA in UnifiedTimeSeries has some additional parameters, please see the following section.fixed_interval : {'S', 'Min', 'H', 'D', 'W', 'M', 'Q', 'Y'}, optional, specify a fixed interval for type conversion, with correspondence as follows:
'S': second
'Min': minute
'H': hour
'D': day
'W': week
'M': month
'Q': quarter
'Y': year
Defaults to None.
target_type : str, optional, specify the type when converting the INT type of key column to other types.
start_point : str, optional, specify a start point in type conversion.
interval : int, optional, specify an interval in type conversion, valid only if
fixed_intervalis None(not set).holiday : str, optional, add holiday to model in a json format, including name, timestamp, (optional) lower_window, and (optional) upper_window elements. For example: '{ "name": "New Year", "timestamp": "2025-01-01" }'.
'ARIMA' :
AutoARIMA'BSTS' :
BSTS'SMOOTH' :
AutoExponentialSmoothing
For more parameter mappings of hana_ml and HANA PAL, please refer to the doc page: Parameter Mappings
- Attributes
- model_DataFrame
Model information.
- statistics_DataFrame
Statistics.
- decompose_DataFrame
Decomposition values.
- metrics_DataFrame
Evaluation metrics when
split_methodis 'rocv' or 'blocked'.
Methods
fit(data[, key, endog, exog])Fit function.
make_future_dataframe([data, key, periods, ...])Create a new dataframe for time series prediction.
predict(data[, key, exog])Predict function.
Examples
>>> uts = UnifiedTimeSeries(func='AMTSA')
Perform fit_predict():
>>> uts.fit_predict(data=df)
Output:
>>> uts.model_.collect() >>> uts.statistics_.collect() >>> uts.decompose_.collect()
- fit(data, key=None, endog=None, exog=None)¶
Fit function.
- 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 non-ID column.
- exogstr or list of str, optional
The column(s) of exogenous variables to be used in the model.
Defaults to all non-ID, non-endog columns if not provided.
- make_future_dataframe(data=None, key=None, periods=1, increment_type='seconds')¶
Create a new dataframe for time series prediction.
- Parameters
- dataDataFrame, optional
The training data contains the index.
Defaults to the data used in the fit().
- keystr, optional
The index defined in the training data.
Defaults to the specified key in fit function or the data.index or the first column of the data.
- periodsint, optional
The number of rows created in the predict dataframe.
Defaults to 1.
- increment_type{'seconds', 'days', 'months', 'years'}, optional
The increment type of the time series.
Defaults to 'seconds'.
- Returns
- DataFrame
- predict(data, key=None, exog=None, **kwargs)¶
Predict function.
- Parameters
- dataDataFrame
Data for prediction.
- 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.
- exogstr or list of str, optional
The column(s) of exogenous variables to be used in the model.
Defaults to all non-ID columns if not provided.
- **kwargskeyword arguments
Arbitrary keyword arguments and please refer to the corresponding algorithm for the parameters' key-value pair.
- Returns
- DataFrame 1
DataFrame containing the forecast values and other related statistics(like standard error estimation, upper/lower quantiles).
- DataFrame 2
DataFrame containing the trend/seasonal/regression components w.r.t. the forecast values.