range_recall

range_recall(y_true: ndarray, y_pred: ndarray, alpha: float = 0, cardinality: str = 'reciprocal', bias: str = 'flat') float[source]

Compute the range-based recall metric.

Range-based metrics were introduced by Tatbul et al. at NeurIPS 2018 [1]. This implementation uses the community package prts as a soft-dependency.

Range recall is the average recall of each real anomaly range. For each real anomaly range the overlap size, position, and cardinality with predicted anomaly ranges are considered. In addition, an existence reward can be given that boosts the recall even if just a single point of the real anomaly is in the predicted ranges. For more details, please refer to the paper [1].

Parameters:
y_truenp.ndarray

True binary labels of shape (n_instances,).

y_prednp.ndarray

Anomaly scores for each point of the time series of shape (n_instances,).

alphafloat

Weight of the existence reward. If 0: no existence reward, if 1: only existence reward. The existence reward is given if the real anomaly range has overlap with even a single point of the predicted anomaly range.

cardinality{‘reciprocal’, ‘one’, ‘udf_gamma’}

Cardinality type.

bias{‘flat’, ‘front’, ‘middle’, ‘back’}

Positional bias type.

Returns:
float

Range-based recall

References

[1] (1,2)

Tatbul, Nesime, Tae Jun Lee, Stan Zdonik, Mejbah Alam, and Justin Gottschlich. “Precision and Recall for Time Series.” In Proceedings of the International Conference on Neural Information Processing Systems (NeurIPS), 1920–30. 2018. http://papers.nips.cc/paper/7462-precision-and-recall-for-time-series.pdf.