roc curve and auc
The ROC curve and its summary, AUC, answer a question every binary classifier raises: a model outputs a continuous score, but you must pick a threshold to turn scores into yes/no decisions — so how good is the model independent of where you set that threshold? Instead of committing to one cutoff, the ROC curve shows the model's behavior at every possible threshold at once, and AUC condenses that whole curve into a single threshold-independent number.
The ROC (Receiver Operating Characteristic) curve plots the true positive rate (TPR = recall = TP/(TP+FN), the fraction of real positives you catch) on the vertical axis against the false positive rate (FPR = FP/(FP+TN), the fraction of real negatives you wrongly flag) on the horizontal axis. As you sweep the threshold from strict to lenient, you trace a curve from the bottom-left (catch nothing, no false alarms) to the top-right (catch everything, all false alarms). A model that perfectly separates the classes hugs the top-left corner; a model guessing at random follows the diagonal line TPR = FPR.
AUC, the Area Under this Curve (often AUROC), squeezes the curve into one number between 0 and 1. AUC = 0.5 is random guessing; AUC = 1.0 is perfect; below 0.5 means the model is anti-correlated (you could flip its decisions). AUC has a beautiful probabilistic meaning: it is exactly the probability that the model assigns a higher score to a randomly chosen positive example than to a randomly chosen negative one. In other words, AUC measures ranking quality — how well the scores order positives above negatives — without caring about any specific threshold or about calibration of the actual probability values.
That threshold independence is AUC's strength and also its blind spot. Because the FPR denominator includes all the true negatives, ROC can look optimistically flattering under severe class imbalance: a handful of false positives barely moves FPR when negatives are abundant, even though those false positives may swamp the few true positives in absolute terms. In that regime the precision–recall curve and its area (average precision) give a more honest picture. Use ROC-AUC for roughly balanced ranking problems or to compare separability across models; switch to PR-AUC when positives are rare and false positives are costly.
High AUC does not mean the model's probabilities are trustworthy. AUC only judges ordering, so a model can rank perfectly (AUC = 1) yet output systematically over-confident scores; trustworthiness of the numbers themselves is a separate property measured by calibration.