segment_anomaly_precision#

segment_anomaly_precision(intervals_true: ArrayLike, intervals_pred: ArrayLike) float[source][source]#

Compute detection precision for segment anomalies.

The fraction of predicted anomalous intervals that overlap with a true anomalous interval (greedy matching). Higher is better.

Returns 1.0 when there are no predicted intervals (no false alarms).

Parameters:
intervals_truearray-like of shape (n_true, 2)

True anomalous intervals, as returned by predict_segment_anomalies(). Each row is a [start, end) index pair.

intervals_predarray-like of shape (n_pred, 2)

Predicted anomalous intervals, as returned by predict_segment_anomalies(). Each row is a [start, end) index pair.

Returns:
float

Precision in [0, 1].

Examples

>>> segment_anomaly_precision([[10, 20]], [[12, 22]])
1.0