Concept beginner · 3 min read

What is AUC-ROC in machine learning

Quick answer
AUC-ROC stands for Area Under the Receiver Operating Characteristic curve, a metric that measures the ability of a binary classifier to distinguish between classes. It summarizes the trade-off between true positive rate and false positive rate across classification thresholds. In PyTorch, it can be computed using libraries like torchmetrics or manually by calculating TPR and FPR.
AUC-ROC is a performance metric that quantifies how well a binary classifier separates positive and negative classes across all thresholds.

How it works

The AUC-ROC metric evaluates a binary classifier's performance by plotting the Receiver Operating Characteristic (ROC) curve, which graphs the true positive rate (TPR) against the false positive rate (FPR) at various threshold settings. The TPR (also called sensitivity) measures the proportion of actual positives correctly identified, while FPR measures the proportion of negatives incorrectly classified as positives.

Imagine adjusting a threshold slider that decides when to classify a sample as positive. The ROC curve shows how TPR and FPR change as you move this slider. The AUC (Area Under Curve) summarizes this curve into a single scalar between 0 and 1, where 1 means perfect classification and 0.5 means random guessing.

Concrete example

Here is how to compute AUC-ROC in PyTorch using the torchmetrics library, which simplifies metric calculations:

python
import torch
from torchmetrics import AUROC

# Example binary predictions (logits) and true labels
logits = torch.tensor([0.1, 0.4, 0.35, 0.8])
labels = torch.tensor([0, 0, 1, 1])

# Convert logits to probabilities using sigmoid
probs = torch.sigmoid(logits)

# Initialize AUROC metric
auroc = AUROC(pos_label=1)

# Compute AUC-ROC
auc_score = auroc(probs, labels)
print(f"AUC-ROC score: {auc_score.item():.4f}")
output
AUC-ROC score: 0.7500

When to use it

Use AUC-ROC when you need a threshold-independent measure of a binary classifier's ability to rank positive samples higher than negative ones. It is especially useful when classes are imbalanced or when you want to evaluate model performance across all classification thresholds.

Do not use AUC-ROC when you require performance at a specific threshold or when the cost of false positives and false negatives differs significantly; in those cases, metrics like precision, recall, or F1-score at a chosen threshold are more appropriate.

Key terms

TermDefinition
AUCArea Under the ROC Curve, scalar metric from 0 to 1 indicating classifier quality
ROC CurvePlot of True Positive Rate vs False Positive Rate at various thresholds
True Positive Rate (TPR)Proportion of actual positives correctly identified (sensitivity)
False Positive Rate (FPR)Proportion of negatives incorrectly classified as positives
ThresholdDecision boundary to classify predicted probabilities as positive or negative

Key Takeaways

  • AUC-ROC measures classifier performance across all thresholds, not just one.
  • Use torchmetrics.AUROC in PyTorch for easy and accurate AUC-ROC computation.
  • AUC-ROC is ideal for imbalanced datasets and ranking tasks but not for threshold-specific evaluation.
Verified 2026-04
Verify ↗