range_precision¶
- range_precision(y_true: ndarray, y_pred: ndarray, alpha: float = 0, cardinality: str = 'reciprocal', bias: str = 'flat') float [source]¶
Compute the range-based precision 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 precision is the average precision of each predicted anomaly range. For each predicted continuous anomaly range the overlap size, position, and cardinality is considered. 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. Because precision by definition emphasizes on prediction quality, there is no need for an existence reward and this value should always be set to 0.
- cardinality{‘reciprocal’, ‘one’, ‘udf_gamma’}
Cardinality type.
- bias{‘flat’, ‘front’, ‘middle’, ‘back’}
Positional bias type.
- Returns:
- float
Range-based precision
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.