Recall
- class dtaianomaly.evaluation.Recall[source]
Computes the Recall score.
Recall measures the model’s ability to correctly identify all actual anomalies. It tells us the proportion of true anomalies that were successfully detected by the model. In an anomaly detection system, recall answers the question: “Of all the anomalies that occurred, how many did the model detect?” A high recall is especially important when missing actual anomalies (false negatives) could have severe consequences.
Mathematically, recall is the ratio of true positives (correctly identified anomalies) to all actual positives, which includes both true anomalies and false negatives (missed anomalies). It can be expressed as:
\[\text{Recall} = \frac{\text{True Anomalies}}{\text{True Anomalies} + \text{False Negatives}}\]A high recall ensures that most anomalies are detected, but it doesn’t account for how many false positives (normal events incorrectly flagged as anomalies) were generated, which is handled by precision.
Examples
>>> from dtaianomaly.evaluation import Recall >>> metric = Recall() >>> 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) 1.0
- 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.