BCPD

class hana_ml.algorithms.pal.tsa.changepoint.BCPD(max_tcp, max_scp, trend_order=None, max_harmonic_order=None, min_period=None, max_period=None, random_seed=None, max_iter=None, interval_ratio=None)

Bayesian Change-point detection (BCPD) detects abrupt changes in the time series. It, to some extent, can been assumed as an enhanced version of seasonality test in additive mode. Similarly, it decomposes a time series into three components: trend, season and random, but with a remarkable difference that it is capable of detecting change points within both trend and season parts, using a quasi RJ-MCMC method.

Parameters:
max_tcpint

Maximum number of trend change points to be detected.

max_scpint

Maximum number of season change points to be detected.

trend_orderint, optional

Order of trend segments that used for decomposition

Defaults to 1.

max_harmonic_orderint, optional

Maximum order of harmonic waves within seasonal segments.

Defaults to 10.

min_periodint, optional

Minimum possible period within seasonal segments.

Defaults to 1.

max_periodint, optional

Maximum possible period within seasonal segments.

Defaults to half of the data length.

random_seedint, optional

Indicates the seed used to initialize the random number generator:

  • 0: Uses the system time.

  • Not 0: Uses the provided value.

Defaults to 0.

max_iterint, optional

BCPD is iterative, the more iterations, the more precise will the result be rendered.

Defaults to 5000.

interval_ratiofloat, optional

Regulates the interval between change points, which should be larger than the corresponding portion of total length.

Defaults to 0.1.

Examples

>>> bcpd = BCPD(max_tcp=5, max_scp=5)
>>> tcp, scp, period, components = bcpd.fit_predict(data=df)
>>> tcp.collect()
>>> scp.collect()
>>> period.collect()
>>> components.collect()

Methods

fit_predict(data[, key, endog, features])

Detects change-points of the input data.

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

Detects change-points of the input data.

Parameters:
dataDataFrame

Input time-series data for change-point detection.

keystr, optional

Column name for time-stamp of the input time-series data.

If the index column of data is not provided or not a single column, and the key of fit_predict function is not provided, the default value is the first column of data.

If the index of data is set as a single column, the default value of key is index column of data.

endogstr, optional

Column name for the value of the input time-series data. Defaults to the first non-key column.

featuresstr or a list of str, optional (deprecated)

Column name(s) for the value(s) of the input time-series data.

Returns:
DataFrame 1

The detected the trend change-points of the input time-series data.

DataFrame 2

The detected the season change-points of the input time-series data.

DataFrame 3

The detected the period within each season segment of the input time-series data.

DataFrame 4

The decomposed components.

Inherited Methods from PALBase

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