Back to models
Detector

StatThresholdAnomaliser

Anomaly detection by thresholding segment statistics.

Quickstart

python
from sktime.detection.stat_threshold import StatThresholdAnomaliser

estimator = StatThresholdAnomaliser(change_detector, stat=<function mean>, stat_lower=-1.0, stat_upper=1.0)

Parameters(4)

change_detectorBaseDetector
Change-point detector used to segment the data.
statcallable, default=np.mean
Statistic applied per segment. Must accept a 1-D array and return a scalar.
stat_lowerfloat, default=-1.0

Lower threshold — segments with stat < stat_lower are anomalous.

stat_upperfloat, default=1.0

Upper threshold — segments with stat > stat_upper are anomalous.

Examples

>>> from sktime.detection.stat_threshold import StatThresholdAnomaliser
>>> from sktime.detection.moving_window import MovingWindow
>>> import numpy as np, pandas as pd
>>> rng = np. random. default_rng (42)
>>> X = pd. DataFrame (rng. standard_normal ((100, 1)))
>>> X. iloc [40: 60 ] += 10.0
>>> detector = StatThresholdAnomaliser (
... change_detector = MovingWindow (bandwidth = 5),
... stat_lower =- 2.0,
... stat_upper = 2.0,
... )
>>> detector. fit_predict (X)