ROC Curve and AUC: Decode Model Ranking in 4 Steps

The ROC curve and its summary number, AUC, answer a question the other classification metrics cannot: how good is my model across every possible threshold, not just one? Precision, recall and F1 are all computed at a single decision threshold. ROC-AUC steps back and evaluates the model’s ranking ability as a whole.

roc curve and auc chart

📌
In one line. AUC is the probability that your model scores a random positive higher than a random negative — a single, threshold-free measure of ranking quality from 0.5 (random) to 1.0 (perfect).

The threshold problem

A classifier usually outputs a probability, which you turn into a class by comparing it to a threshold (commonly 0.5). But that choice is arbitrary — and, as the precision–recall trade-off shows, moving the threshold changes every metric. The ROC curve sidesteps the problem by plotting performance at all thresholds at once.

What the ROC curve plots

ROC stands for Receiver Operating Characteristic. The curve plots two rates, both taken from the confusion matrix as the threshold sweeps from 1 down to 0:

TPR (y-axis) = TP / (TP + FN) = recall  •  FPR (x-axis) = FP / (FP + TN)

Each point on the curve corresponds to one threshold. As you lower the threshold, both TPR and FPR rise; the shape of that climb describes how well the model separates the two classes.

Reading the ROC curve

  • A curve that hugs the top-left corner is excellent — high true positive rate with a low false positive rate.
  • The diagonal line (bottom-left to top-right) represents random guessing.
  • A curve below the diagonal is worse than random — usually a sign your labels or probabilities are inverted.

What is AUC?

AUC is the Area Under the ROC Curve — a single number from 0 to 1 that summarises the whole curve:

1.0Perfect
0.9+Excellent
0.7–0.8Acceptable
0.5Random

AUC has an elegant interpretation: it is the probability that the model ranks a randomly chosen positive example higher than a randomly chosen negative one. An AUC of 0.9 means that 90% of the time, a true positive gets a higher score than a true negative. Because it measures ranking, AUC is threshold-independent — reading the AUC alongside the shape of the ROC curve tells you both how well the model ranks and where it separates classes. See the Wikipedia ROC curve article for the formal treatment.

Why the ROC curve is popular

The ROC curve earns its place in almost every binary-classification report for three reasons:

  • Threshold-free — compare models before committing to an operating point.
  • Single, interpretable number — easy to report and rank models by.
  • Scale-invariant — depends on the ranking of predictions, not their absolute values.
⚠️
When ROC-AUC misleads. On heavily imbalanced data, AUC can look reassuringly high even when the model performs poorly on the rare positive class, because FPR has a huge negative denominator. Prefer the Precision–Recall curve and its area (average precision) when positives are rare.

Computing ROC-AUC in Python

from sklearn.metrics import roc_auc_score, roc_curve

y_true  = [0, 0, 1, 1]
y_score = [0.1, 0.4, 0.35, 0.8]   # predicted probabilities

print("AUC:", roc_auc_score(y_true, y_score))
fpr, tpr, thresholds = roc_curve(y_true, y_score)
💡
Watch the input. roc_auc_score takes predicted probabilities or scores, not hard 0/1 labels — the ranking is the whole point.

Frequently asked questions

What is a good AUC score?
As a rough guide: 0.5 is random, 0.7–0.8 is acceptable, 0.8–0.9 is good, and above 0.9 is excellent — but always compare to a baseline and consider class balance.
What is the difference between ROC-AUC and F1?
F1 is measured at one fixed threshold and focuses on the positive class; ROC-AUC summarises performance across all thresholds and reflects ranking quality. They answer different questions and are often reported together.
Should I use ROC-AUC or PR-AUC?
Use ROC-AUC for balanced problems; prefer PR-AUC (average precision) when the positive class is rare, because ROC-AUC can stay high even when precision is poor.

Related guides

Scroll to Top