What is the ROC Curve, and how is it plotted?
Answer
The ROC (Receiver Operating Characteristic) curve is a graphical tool for evaluating a binary classifier by plotting the true positive rate against the false positive rate at every classification threshold. Because models output scores rather than hard labels, a threshold decides what counts as positive; sweeping that threshold from strict to lenient traces out the curve. To plot it: train the binary classifier, generate probability scores for the positive class, compute TPR and FPR at many threshold values, then plot TPR versus FPR. Reading the curve: points near the top-left corner mean high TPR with low FPR: excellent performance; the diagonal is random guessing; curves below the diagonal are worse than random (and can be flipped to beat it); a perfect classifier sits at the single point (0, 1).
(1) Axes: Y is TPR (recall, sensitivity); X is FPR (1 − specificity); both sweep with the threshold.
(2) How It Is Built: Score the data, then recompute the confusion counts at every candidate threshold and connect the points.
(3) Reading It: Closer to the top-left corner is better; the diagonal is random; (0, 1) is perfect.

Figure 1: Reference ROC curves: the further a model bows toward the top-left corner, the better it ranks positives above negatives.
Mathematical Formulation:
Where:
is the classification threshold; varying it from 1 down to 0 traces the curve.
,
,
, and
are the confusion-matrix counts at threshold
.
is the true positive rate (same as recall) and
is the false positive rate, the curve’s two axes.



