rp_rr_auc_score¶
- rp_rr_auc_score(y_true: ndarray, y_score: ndarray, max_samples: int = 50, r_alpha: float = 0.5, p_alpha: float = 0, cardinality: str = 'reciprocal', bias: str = 'flat') float [source]¶
Compute the AUC-score of the range-based precision-recall curve.
Computes the area under the precision recall curve when using the range-based precision and range-based recall metric introduced by Tatbul et al. at NeurIPS 2018 [1]. This implementation uses the community package prts as a soft-dependency.
This metric only considers the top-k predicted anomaly ranges within the scoring by finding a threshold on the scoring that produces at least k anomalous ranges. If k is not specified, the number of anomalies within the ground truth is used as k.
- Parameters:
- y_truenp.ndarray
True binary labels of shape (n_instances,).
- y_scorenp.ndarray
Anomaly scores for each point of the time series of shape (n_instances,).
- max_samples: int
The implementation of the range-based precision and recall metrics is quite slow because it relies on the non-optimized
prts
-package. To prevent long runtimes caused by scorings with high precision (many thresholds), just a specific amount of possible thresholds is sampled. This parameter controls the maximum number of thresholds; however, too low numbers degrade the metrics’ quality.- r_alphafloat
Weight of the existence reward for the range-based recall.
- p_alphafloat
Weight of the existence reward for the range-based precision. For most - when not all - cases, p_alpha should be set to 0.
- cardinality{‘reciprocal’, ‘one’, ‘udf_gamma’}
Cardinality type.
- bias{‘flat’, ‘front’, ‘middle’, ‘back’}
Positional bias type.
- Returns:
- float
Area under the range-based precision-recall curve.
References
[1]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.