kats.detectors.outlier module¶

Module with generic outlier detection models. Supports a univariate algorithm that treates each metric separately to identify outliers and a multivariate detection algorithm that determines outliers based on joint distribution of metrics

class kats.detectors.outlier.MultivariateAnomalyDetector(data: kats.consts.TimeSeriesData, params: kats.consts.Params, training_days: float, model_type: kats.detectors.outlier.MultivariateAnomalyDetectorType = <MultivariateAnomalyDetectorType.VAR: 'var.VARModel'>)[source]¶

Bases: kats.detectors.detector.Detector

Detector class for Multivariate Outlier Detection. Provides utilities to calculate anomaly scores, get anomalous datapoints and anomalous metrics at those points.

data¶

Input metrics TimeSeriesData

params¶

Parameter class for multivariate VAR/ BVAR model

training_days¶

num of days of data to use for initial training. If less than a day, specify as fraction of a day

model_type¶

The type of multivariate anomaly detector (currently ‘BAYESIAN_VAR’ and ‘VAR’ options available)

detector()pandas.core.frame.DataFrame[source]¶

Fit the detection model and return the results

Returns

DataFrame with colums corresponding to individual anomaly scores of each metric and the overall anomaly score for the whole timeseries

get_anomalous_metrics(t: datetime.datetime, top_k: Optional[int] = None)pandas.core.frame.DataFrame[source]¶

Find top k metrics with most anomalous behavior at time t

Parameters
  • t – time instant of interest (same type as TimeSeriesData.time)

  • top_k – Top few metrics to return. If None, returns all

Returns

DataFrame with metrics and their corresponding anomaly score

get_anomaly_timepoints(alpha: float)List[source]¶

Helper function to get anomaly timepoints based on the significance level

Parameters
  • alpha – significance level to consider the timeperiod anomalous

  • plot() to help choose a good threshold (Use) –

Returns

List of time instants when the system of metrics show anomalous behavior

plot()[source]¶

Plot overall anomaly score of system of metrics at each instant. Useful for threshold selection

class kats.detectors.outlier.MultivariateAnomalyDetectorType(value)[source]¶

Bases: enum.Enum

An enumeration.

class kats.detectors.outlier.OutlierDetector(data: kats.consts.TimeSeriesData, decomp: str = 'additive', iqr_mult: float = 3.0)[source]¶

Bases: kats.detectors.detector.Detector

This univariate outlier detection algorithm mimics the outlier detection algorithm in R

data¶

TimeSeriesData object with the time series

decomp¶

‘additive’ or ‘multiplicative’ decomposition

iqr_mult¶

iqr_mult * inter quartile range is used to classify outliers

detector()[source]¶

Detects outliers and stores in self.outliers