liveBook · Manning

Area under the curve

As explained in Outlier Detection in Python

AUROC is the area under the receiver operating characteristic curve, measuring a scoring model's ability to rank positive cases above negative cases across classification thresholds.

AUROC measures how well a scoring model ranks positive cases above negative cases across classification thresholds. A perfect ranking scores 1.0; random ranking scores 0.5. It evaluates scores, not the quality of any single threshold or its binary labels. section 8.5.2

Use AUROC to compare rankings, while keeping its evaluation conditions in view:

  • Evaluation requires ground-truth labels. In outlier detection, synthetic data made by modifying real records can provide approximate labels, but doped records may not rank above every real record. section 8.5.2 section 8.5.3
  • Compare detectors and parameter choices using AUROC, then select useful decision thresholds for the intended context. A strong ranking does not by itself determine the best binary labels. section 8.5.2
  • Test robustness across settings: AUROC can vary with training-set size, and extreme training values can sharply reduce some detectors’ scores. section 8.5.4 section 8.5.5

Network-event detection

On the KDD Cup dataset, Isolation Forest scores produced an AUROC of about 0.95, with repeated runs varying because the detector is stochastic. The scores were evaluated against known attack labels; the result measures ranking, not whether every flagged record is an attack. section 5.2.2

Listing 8.9 Evaluating detectors using AUROC
from sklearn.metrics import roc_auc_score
 
test_df = pd.concat([df, doped_df])
y_true = [0]*len(df) + [1]*len(doped_df)
 
clf = IForest()
clf.fit(clean_df)
y_pred = clf.decision_function(test_df)
if_auroc = roc_auc_score(y_true, y_pred)
 
clf = LOF()
clf.fit(clean_df)
y_pred = clf.decision_function(test_df)
lof_auroc = roc_auc_score(y_true, y_pred)

The listing calculates AUROC for Isolation Forest and LOF on labeled original and doped records. section 8.5.3

How Outlier Detection in Python covers it

How deep it goes
Defines ranking performance with perfect and random benchmarks, then connects AUROC to detector comparison and threshold selection.
Examples
Uses KDD Cup network events, doped data, detector comparisons, and training-size tests as evaluation examples.
What it assumes
Requires ground-truth labels for evaluation, which synthetic modifications of real data can approximate in outlier detection.
What you can do after
Evaluate detector rankings against labeled data and compare detectors or parameter settings using AUROC.
How it connects
Links AUROC to ROC curves, outlier detection, binary classification metrics, and precision at k.

Also explained in

Compare how 12 books explain area under the curve →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Outlier Detection in Python. The section links point to the parts of the book it draws on.