IidChangePointDetector Class
This transform detects the change-points in an i.i.d. sequence using adaptive kernel density estimation and martingales.
- Inheritance
-
nimbusml.internal.core.timeseries._iidchangepointdetector.IidChangePointDetectorIidChangePointDetectornimbusml.base_transform.BaseTransformIidChangePointDetectorsklearn.base.TransformerMixinIidChangePointDetector
Constructor
IidChangePointDetector(confidence=95.0, change_history_length=20, martingale='Power', power_martingale_epsilon=0.1, columns=None, **params)
Parameters
- columns
see Columns.
- confidence
The confidence for change point detection in the range [0, 100]. Used to set the threshold of the martingale score for triggering alert.
- change_history_length
The length of the sliding window on p-value for computing the martingale score.
- martingale
The type of martingale betting function used for
computing the martingale score. Available options are {Power
,
Mixture
}.
- power_martingale_epsilon
The epsilon parameter for the Power
martingale if martingale is set to Power
.
- params
Additional arguments sent to compute engine.
Examples
###############################################################################
# IidChangePointDetector
import pandas as pd
from nimbusml.timeseries import IidChangePointDetector
# Create a sample series with a change
input_data = [5, 5, 5, 5, 5, 5, 5, 5]
input_data.extend([7, 7, 7, 7, 7, 7, 7, 7])
X_train = pd.Series(input_data, name="ts")
cpd = IidChangePointDetector(confidence=95, change_history_length=4) << {'result': 'ts'}
data = cpd.fit_transform(X_train)
print(data)
# ts result.Alert result.Raw Score result.P-Value Score result.Martingale Score
# 0 5 0.0 5.0 5.000000e-01 0.001213
# 1 5 0.0 5.0 5.000000e-01 0.001213
# 2 5 0.0 5.0 5.000000e-01 0.001213
# 3 5 0.0 5.0 5.000000e-01 0.001213
# 4 5 0.0 5.0 5.000000e-01 0.001213
# 5 5 0.0 5.0 5.000000e-01 0.001213
# 6 5 0.0 5.0 5.000000e-01 0.001213
# 7 5 0.0 5.0 5.000000e-01 0.001213
# 8 7 1.0 7.0 1.000000e-08 10298.666376 <-- alert is on, predicted changepoint
# 9 7 0.0 7.0 1.328455e-01 33950.164799
# 10 7 0.0 7.0 2.613750e-01 60866.342063
# 11 7 0.0 7.0 3.776152e-01 78362.038772
# 12 7 0.0 7.0 5.000000e-01 0.009226
# 13 7 0.0 7.0 5.000000e-01 0.002799
# 14 7 0.0 7.0 5.000000e-01 0.001561
# 15 7 0.0 7.0 5.000000e-01 0.001213
Remarks
IIDChangePointDetector
assumes a sequence of data points that are
independently sampled from one
stationary distribution. Adaptive kernel density estimation
is used to model the distribution.
This transform detects change points by calculating the martingale score for the sliding window based on the estimated distribution. The idea is based on the Exchangeability Martingales that detects a change of distribution over a stream of i.i.d. values. In short, the value of the martingale score starts increasing significantly when a sequence of small p-values are detected in a row; this indicates the change of the distribution of the underlying data generation process.
Methods
get_params |
Get the parameters for this operator. |
get_params
Get the parameters for this operator.
get_params(deep=False)
Parameters
- deep