← Back to Classic ML Mind Map
📊 Classic MLID: roc-auc

ROC-AUC

🎯Core Definition
sweeping every classification threshold, plot the true positive rate TPR=TPTP+FNTPR = \frac{TP}{TP+FN} (= recall) on the y-axis against the false positive rate FPR=FPFP+TNFPR = \frac{FP}{FP+TN} (= 1 - specificity) on the x-axis; AUC is the area under this curve. As the threshold drops, TPR rises monotonically while FPR grows too; key points: (0,0) = predict all negative, (1,1) = predict all positive, and the diagonal TPR=FPRTPR = FPR is random guessing (AUC = 0.5). Probabilistic interpretation: AUC = the probability that a randomly chosen positive scores higher than a randomly chosen negative, AUC=P(s+>s−)AUC = P(s_{+} > s_{-}) — threshold-free and class-ratio-free, a pure ranking metric. Hand computation: 4 samples with scores [0.9, 0.7, 0.5, 0.3] and labels [+, -, +, -]: there are 2×2=42 \times 2 = 4 positive–negative pairs, and 3 of them (0.9, 0.7), (0.9, 0.3), (0.5, 0.3) are correctly ordered while only (0.5, 0.7) is inverted, so AUC=3/4=0.75AUC = 3/4 = 0.75.
💡Use Cases
binary classification and ranking-quality evaluation (credit, recsys, search); interview staple “how is AUC computed and interpreted”; also used for model selection and tuning since it needs no fixed threshold.
⚡Key Problems Solved
accuracy and PR require a chosen threshold to compare models, while AUC decouples ranking quality from the threshold — one number summarizing all thresholds; however, under extreme imbalance the FPR denominator FP+TNFP+TN is inflated by the huge negative population, so a few false positives barely move FPR and the ROC curve looks over-optimistic — switch to the PR curve (sensitive to the P=ρP = \rho baseline, exposing models whose ranking is polluted by negatives); AUC is class-ratio insensitive because it is rank-based, and it does not tell you the operating point — pair it with the threshold curve to pick TPR/FPR.
🎯Core Interview Exam Points
Fundamentals · Production Scenarios · Deep Dive
Core Def
Explain the core definition, underlying mechanism/math, and key principles of ROC-AUC.
Use Cases
In production engineering, what are the primary use cases for ROC-AUC and what core pain points does it solve?
🔥 High-Frequency Deep-Dive Questions
1
Hand-compute AUC: 4 samples with scores [0.9, 0.7, 0.5, 0.3] and labels [+, -, +, -], counting positive–negative pairs.
2
What is the probabilistic interpretation of AUC? Why is random guessing AUC ≈ 0.5 and a perfect ranking AUC = 1?
3
How to draw the ROC curve from model scores (threshold sweep updating TPR/FPR each step)? How is AUC computed by the trapezoid rule?
4
Why prefer the PR curve over ROC under extreme class imbalance, and why is AUC insensitive to the class ratio?
5
How to pick an operating threshold for a model with AUC = 0.75? Why doesn't AUC directly give a TPR/FPR working point?
Updated 2026-08-12
🎯
Verify Mastery: Practice Exam Questions for "ROC-AUC"
Take pitfall multiple-choice questions with derivation options; mistakes are automatically logged.
🚀 Start Card Practice ➔
← Previous CardPrecision, Recall & F1Next Card →NDCG

🔗 More Classic ML Knowledge Cards

引用出处: TalentMe 450+ 工业级 AI 架构考点知识库 (Tech Vault) · 遵循 CC-BY-4.0 知识共享协议
URL: https://talentme.airsota.com/resources/tech/roadmap/mindmap/ML/card/roc-auc
中文速览与面试要点

ROC-AUC (ROC-AUC)

定义: 遍历所有分类阈值, 以真正率 TPR = TPTP+FN (= Recall) 为纵轴、假正率 FPR = FPFP+TN (= 1 - 特异度) 为横轴画曲线, AUC = 曲线下的面积。阈值降低时 TPR 单调上升, FPR 也随之增大; 关键点: (0,0) = 阈值无穷大全判负, (1,1) = 阈值负无穷全判正, 对角线 TPR = FPR 对应随机猜测 (AUC = 0.5)。AUC 的概率解释: 随机抽一个正样本的分数高于随机抽一个负样本分数的概率, AUC = P(s_+ > s_-), 与阈值、类别比例无关, 是纯排序指标。手算例: 4 个样本分数 [0.9, 0.7, 0.5, 0.3], 标签 [+, -, +, -], 正负对共 2 2 = 4 对, 分数正确的对: (0.9, 0.7)、(0.9, 0.3)、(0.5, 0.3) 共 3 对, 只有 (0.5, 0.7) 反序, 故 AUC = 3/4 = 0.75。 使用场景: 二分类与排序能力评估 (信贷、推荐、搜索), 面试必问“AUC 怎么算、怎么解释”; 也常用于模型选择与超参调优, 因为 AUC 不依赖具体阈值。 解决的问题: 准确率、PR 都需要指定阈值才能比较, 而 AUC 把“排序质量”与阈值解耦, 一个数字综合所有阈值下的表现; 但正负类极度不平衡时, FPR 分母 FP+TN 被海量负类撑大, 少数假阳性对 FPR 几乎无影响, ROC 曲线显得过于乐观, 此时应改用 PR 曲线 (PR 对基线 P = 敏感, 能暴露排序被负类污染的模型); AUC 基于排序故对类别比例不敏感, 且它不直接给出业务关心的“某阈值下的 TPR/FPR 点”——需要结合阈值曲线一起选点。

核心要点

  • 手算 AUC: 4 个样本分数 [0.9, 0.7, 0.5, 0.3]、标签 [+, -, +, -], 用正负对计数求 AUC?
  • AUC 的概率解释是什么? 为什么随机猜测 AUC ≈ 0.5、完美排序 AUC = 1?
  • 如何从模型分数画出 ROC 曲线 (阈值扫描, 每步更新 TPR/FPR)? AUC 如何用梯形法计算?
  • 类别极不平衡时为什么用 PR 曲线而不用 ROC? 为什么 AUC 对类别比例不敏感?
  • AUC = 0.75 的模型如何选实际业务阈值? AUC 为什么不能直接给出 TPR/FPR 工作点?