Machine Learning · Chapter 27 of 40
ROC Curve & AUC
The ROC CURVE plots True Positive Rate vs False Positive Rate across all thresholds. AUC is the area under it — one number summarising ranking quality.
AUC 0.5 = random. AUC 1.0 = perfect.
Example 1 (python)
from sklearn.metrics import roc_auc_score
proba = model.predict_proba(X_test)[:, 1]
print(roc_auc_score(y_test, proba))Output
0.92Feed probabilities, not predictions.
Example 2 (python)
# For heavily imbalanced data, prefer PR AUC over ROC AUCPR curve highlights the positive-class problem better.
Key points
- ROC plots TPR vs FPR.
- AUC 0.5 = random, 1.0 = perfect.
- Uses predicted probabilities.
- For imbalance, prefer PR AUC.
💡 Note: AUC is threshold-independent — great for comparing models, less useful when you must pick one threshold.
