range_f_score¶
- range_f_score(y_true: ndarray, y_pred: ndarray, beta: float = 1, p_alpha: float = 0, r_alpha: float = 0.5, cardinality: str = 'reciprocal', p_bias: str = 'flat', r_bias: str = 'flat') float[source]¶
Compute the F-score using the range-based recall and precision metrics.
Range-based metrics were introduced by Tatbul et al. at NeurIPS 2018 [1].
The F-beta score is the weighted harmonic mean of precision and recall, reaching its optimal value at 1 and its worst value at 0. This implementation uses the range-based precision and range-based recall as basis.
- 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,).
- betafloat
F-score beta determines the weight of recall in the combined score. beta < 1 lends more weight to precision, while beta > 1 favors recall.
- p_alphafloat
Default is 0 = no existence reward for precision.
- r_alphafloat
Weight of the existence reward. If 0: no existence reward, if 1: only existence reward.
- cardinality{‘reciprocal’, ‘one’, ‘udf_gamma’}
Cardinality type.
- p_bias{‘flat’, ‘front’, ‘middle’, ‘back’}
Positional bias type.
- r_bias{‘flat’, ‘front’, ‘middle’, ‘back’}
Positional bias type.
- Returns:
- float
Range-based F-score
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.