kats.detectors.bocpd_model module¶
This file implements the Bayesian Online Changepoint Detection algorithm as a DetectorModel, to provide a common interface.
- class kats.detectors.bocpd_model.BocpdDetectorModel(serialized_model: Optional[bytes] = None, slow_drift: bool = False, threshold: Optional[float] = None)[source]¶
Bases:
kats.detectors.detector.DetectorModel
Implements the Bayesian Online Changepoint Detection as a DetectorModel.
This provides an unified interface, which is common to all detection algorithms.
- serialized_model¶
json containing information about stored model.
- slow_drift¶
Boolean. True indicates we are trying to detect trend changes. False indicates we are trying to detect level changes.
Typical Usage: level_ts is an instance of TimeSeriesData >>> bocpd_detector = BocpdDetectorModel() >>> anom = bocpd_detector.fit_predict(data=level_ts)
- fit(data: kats.consts.TimeSeriesData, historical_data: Optional[kats.consts.TimeSeriesData] = None) → None[source]¶
fit can be called during priming. It’s a noop for us.
- fit_predict(data: kats.consts.TimeSeriesData, historical_data: Optional[kats.consts.TimeSeriesData] = None) → kats.detectors.detector_consts.AnomalyResponse[source]¶
Finds changepoints and returns score.
Uses the current data and historical data to find the changepoints, and returns an AnomalyResponse object, the scores corresponding to probability of changepoints.
- Parameters
data – TimeSeriesData object representing the data
historical_data – TimeSeriesdata object representing the history. Dats
start exactly where the historical_data ends. (should) –
- Returns
AnomalyResponse object, representing the changepoint probabilities. The score property contains the changepoint probabilities. The length of the object is the same as the length of the data.
- predict(data: kats.consts.TimeSeriesData, historical_data: Optional[kats.consts.TimeSeriesData] = None) → kats.detectors.detector_consts.AnomalyResponse[source]¶
predict is not implemented