hana_ml.algorithms.pal.tsa.seasonal_decompose.seasonal_decompose(data, key=None, endog=None, alpha=None, thread_ratio=None, model=None, decompose_type=None, extrapolation=None, smooth_width=None, auxiliary_normalitytest=None, periods=None)

seasonal_decompose function is to decompose a time series into three components: trend, seasonality and random noise.


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 decomposed.

Defaults to the first non-ID column.

alphafloat, optional

The criterion for the autocorrelation coefficient. The value range is (0, 1). A larger value indicates stricter requirement for seasonality.

Defaults to 0.2.

thread_ratiofloat, optional

Controls the proportion of available threads to use. The ratio of available threads.

  • 0: single thread.

  • 0~1: percentage.

  • Others: heuristically determined.

Defaults to -1.

decompose_type{'additive', 'multiplicative', 'auto'}, optional

Specifies decompose type.

  • 'additive': Additive decomposition model

  • 'multiplicative': Multiplicative decomposition model

  • 'auto': Decomposition model automatically determined from input data

Defaults to 'auto'.

extrapolationbool, optional

Specifies whether to extrapolate the endpoints. Set to True when there is an end-point issue.

Defaults to False.

smooth_widthint, optional

Specifies the width of the moving average applied to non-seasonal data. 0 indicates linear fitting to extract trends. Can not be larger than half of the data length.

Defaults to 0.

auxiliary_normalitytestbool, optional

Specifies whether to use normality test to identify model types.

Defaults to False.

periodsint, optional

Length of the periods. When this parameter is specified between 2 and half of the series length, autocorrelation value is calculated for this number of periods and the result is compared to alpha parameter.

If correlation value is equal to or higher than alpha, decomposition is executed with the value of periods. Otherwise, decomposition is executed with no seasonality. For other value of periods, decomposition is also executed with no seasonality.

Defaults to None.


DataFrame 1 : Statistics

  • STAT_NAME: includes type (additive or multiplicative), period (number of seasonality), acf (autocorrelation coefficient).

  • STAT_VALUE: value of stats above.

DataFrame 2 : Seasonal decomposition

  • ID column of input data.

  • SEASONAL: seasonality component.

  • TREND: trend component.

  • RANDOM: white noise component.


Input data df:

>>> df.collect().head(3)
0    1     10.0
1    2      7.0
2    3     17.0

Perform seasonal_decompose function:

>>> stats, decompose = seasonal_decompose(data=df, endog='SERIES', alpha=0.2, thread_ratio=0.5)


>>> stats.collect()
0        type   multiplicative
1      period                4
2         acf         0.501947
>>> decompose.collect().head(3)
    ID    SEASONAL      TREND        RANDOM
0    1    1.252660     10.125      0.788445
1    2    0.349952     14.000      1.428769
2    3    0.748851     16.875      1.345271