class hana_ml.algorithms.pal.tsa.lr_seasonal_adjust.LR_seasonal_adjust(forecast_length=None, trend=None, affect_future_only=None, seasonality=None, seasonal_period=None, accuracy_measure=None, seasonal_handle_method=None, expost_flag=None, ignore_zero=None)

Linear regression with damped trend and seasonal adjust is an approach for forecasting when a time series presents a trend.

forecast_lengthint, optional

Specifies the length of forecast results.

Defaults to 1.

trendfloat, optional

Specifies the damped trend factor, with valid range (0, 1].

Defaults to 1.

affect_future_onlybool, optional

Specifies whether the damped trend affect future only or it affects the entire history.

Defaults to True.

seasonalityint, optional

Specifies whether the data represents seasonality.

  • 0: Non-seasonality.

  • 1: Seasonality exists and user inputs the value of periods.

  • 2: Automatically detects seasonality.

Defaults to 0.

seasonal_periodint, optional

Length of seasonal_period.seasonal_period is only valid when seasonality is 1.

If this parameter is not specified, the seasonality value will be changed from 1 to 2, that is, from user-defined to automatically-detected.

No default value.

seasonal_handle_method{'average', 'lr'}, optional

Method used for calculating the index value in the seasonal_period.

  • 'average': Average method.

  • 'lr': Fitting linear regression.

Defaults to 'average'.

accuracy_measurestr or 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.


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.


Input Dataframe df:

>>> df.collect()
    TIMESTAMP      Y
0           1   5384
1           2   8081
2           3  10282
3           4   9156
4           5   6118
5           6   9139
6           7  12460
7           8  10717
8           9   7825
9          10   9693
10         11  15177
11         12  10990

Create a LR_seasonal_adjust instance:

>>> lr = LR_seasonal_adjust(forecast_length=10,
                            trend=0.9, affect_future_only=True,
                            seasonality=1, seasonal_period=4,

Perform fit_predict on the given data:

>>> lr.fit_predict(data=df)


>>> lr.forecast_.collect().set_index('TIMESTAMP').head(3)
0          1   5328.171741
1          2   7701.608247
2          3  11248.606332
>>> lr.stats_.collect()
0   Intercept     7626.072428
1       Slope      301.399114
2     Periods        4.000000
3      Index0        0.672115
4      Index1        0.935925
5      Index2        1.318669
6      Index3        1.073290
7         MSE   332202.479082
8  HandleZero        0.000000

Forecast values.


Statistics analysis content.


fit_predict(data[, key, endog])

Fit and predict based on the given time series.

property fit_hdbprocedure

Returns the generated hdbprocedure for fit.

fit_predict(data, key=None, endog=None)

Fit and predict based on the given time series.


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.

property predict_hdbprocedure

Returns the generated hdbprocedure for predict.

Inherited Methods from PALBase

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