Overview

Outlier Detection: Outliers only exist in the training data

Novelty Detection: Anomalies only exist in new data

Statistical Methods

See Anomaly Detection - Statistical Methods.

Machine Learning Methods

Isolation Forest

K-Nearest Neighbors (KNN)

Only uses the distance between instances.

Project Implementation

See Anomaly Detection - Project Implementation.

Evaluation Metrics

Precision

Definition: Of all the trips your model flagged as anomalies, how many were actually anomalies?

Formula:

High precision means that when your model says something is an anomaly, it’s very likely to be correct.

Recall

Definition: Of all the true anomalies that actually exist in the dataset, how many did your model successfully find?

Formula:

High recall means your model is good at finding most of the existing anomalies.

Average Precision (AP)

The Average Precision (AP) score is the area under the Precision-Recall curve.

Key Points:

  • Provides a single value that summarizes the curve’s performance across all thresholds
  • A perfect model that achieves 100% precision at all levels of recall would have an AP score of 1.0
  • A random model would have an AP score close to the fraction of positive samples in the dataset
    • Example: If 1% of your data is anomalous, the random AP score would be ~0.01

References

  • DataCamp course materials