Skip to content

    ROC Curve & AUC

    Machine Learning · Intermediate

    Definition

    The ROC curve plots true-positive rate against false-positive rate across thresholds; AUC summarizes it.

    Compares classifiers independent of a single threshold.

    Diagram

    AUC 0.5 randomAUC 1.0 perfect

    Flowchart

    Get predicted probabilitiesVary thresholdCompute TPR and FPRPlot and measure area

    Example: AUC by pair ranking

    pos, neg = [0.9, 0.7], [0.6, 0.8]
    wins = sum(p > n for p in pos for n in neg)
    print(wins / (len(pos) * len(neg)))

    Output: 0.75

    Key points

    • AUC = probability a random positive ranks above a random negative
    • Use PR curves for heavy imbalance

    Interview questions

    What does AUC 0.5 mean?

    The model ranks no better than random guessing.

    More Machine Learning topics