AreaUnderROC
- class dtaianomaly.evaluation.AreaUnderROC[source]
Compute the Area Under the Receiver Operating Characteristic Curve (AUC-ROC) score.
The AUC-ROC is a widely used metric to evaluate the performance of a binary classifier, especially in anomaly detection. The ROC-curve plots the true positive rate (recall) against the false positive rate across different classification thresholds. The AUC-ROC represents the likelihood that the model ranks a randomly chosen anomaly higher than a randomly chosen normal instance. AUC-ROC provides a single number summarizing the model’s ability to distinguish between normal and anomalous instances. A value of 1.0 indicates perfect discrimination, while 0.5 implies the model performs no better than random guessing. It is especially useful when anomalies are rare, as it considers the trade-off between detecting true anomalies (high recall) and minimizing false positives.
See also
AreaUnderPRCompute the Area Under the PR-Curve.
Examples
>>> from dtaianomaly.evaluation import AreaUnderROC >>> metric = AreaUnderROC() >>> 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.833...
- 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.