PointAdjustedPrecision
- class dtaianomaly.evaluation.PointAdjustedPrecision[source]
Compute the point-adjusted precision.
For given binary anomaly predictions and ground truth anomaly labels, point-adjusting will treat any sequence of consecutive ground truth anomalies as anomalous events. If any of the observations in such an event has been detected, then we say that the anomaly has been detected. In this case, all predictions in the anomalous event are set to 1, thereby indicating that the method predicted an anomaly.
Warning
It is known that the point-adjusted metrics heavily overestimate the performance of anomaly detectors. It is therefore not recommended to solely rely on those metrics to evaluate a model. These metrics were implemented for reproducibility of existing works.
See also
PrecisionCompute the standard, not point-adjusted precision.
Examples
>>> from dtaianomaly.evaluation import PointAdjustedPrecision >>> metric = PointAdjustedPrecision() >>> y_true = [0, 0, 0, 1, 1, 0, 0, 0] >>> y_pred = [1, 0, 0, 1, 1, 1, 0, 0] >>> metric.compute(y_true, y_pred) 0.5
- compute(y_true: ndarray, y_pred: ndarray, **kwargs) float
Compute the performance score.
Evaluate how closely the given anomaly scores align to the ground truth anomaly scores.
- Parameters:
- y_truearray-like of shape (n_samples)
Ground-truth labels.
- y_predarray-like of shape (n_samples)
Predicted anomaly scores.
- **kwargs
Additional arguments used for computing the evaluation metric.
- Returns:
- float
The alignment score of the given ground truth and prediction, according to this score.
- Raises:
- ValueError
When inputs are not numeric “array-like”s
- ValueError
If shapes of y_true and y_pred are not of identical shape
- ValueError
If y_true is non-binary.
- ValueError
If y_pred is non-binary.