download

When does PR AUC tell you more than ROC AUC?

Machine learning~12 minReviewed 29 Oct 2026Free · No sign-in

Question

A fraud model scores 1,000 payments, and 10 of them are fraud. The 10 frauds score above 940 legit payments but below the other 50.

Its ROC AUC is about 0.95, and the team calls it excellent.

  1. Flag enough payments to catch all 10 frauds. How many are flagged? What share of legit payments is flagged, and what share of flags is fraud?
  2. Which metric shows the problem better, ROC AUC or PR AUC?
  3. Legit traffic grows 10 times, with the same score mix. What happens to each metric?
Show hints (3)
  1. "TWO DENOMINATORS"

    The false positive rate divides false alarms by all 990 legit payments. Precision divides by the payments you flagged. Which one makes 50 false alarms look small?

  2. "AT FULL RECALL"

    To catch all 10 frauds, you also flag the 50 legit payments that score above them. That is 60 flags. What share of them is fraud?

  3. "TEN TIMES THE TRAFFIC"

    With 9,900 legit payments, 500 score above the frauds. The false positive rate stays 50 / 990. Precision falls to 10 / 510.

Show checked explanation

When positives are rare and you care about the top of the list. ROC AUC divides false alarms by all negatives, so many easy negatives hide them. Here ROC AUC is 0.95, yet catching every fraud costs 50 false alarms for 10 frauds. Average precision (PR AUC) is 0.097. A random model gets near the 1% fraud rate.

"SOLUTION · PYTHON"
import numpy as np
from sklearn.metrics import average_precision_score, roc_auc_score

fraud = np.linspace(0.90, 0.81, 10)  # scores of the 10 frauds
legit = np.r_[np.linspace(0.99, 0.91, 50),  # 50 legit above every fraud
              np.linspace(0.80, 0.00, 940)]  # 940 legit below

for copies in (1, 10):  # then 10 times more legit traffic
    y = np.r_[np.ones(10), np.zeros(990 * copies)]
    scores = np.r_[fraud, np.tile(legit, copies)]
    roc = roc_auc_score(y, scores)
    ap = average_precision_score(y, scores)
    print(f"{990 * copies} legit: ROC AUC={roc:.3f} AP={ap:.3f}")
"OUTPUT"
990 legit: ROC AUC=0.949 AP=0.097
9900 legit: ROC AUC=0.949 AP=0.011

Code run on CPython 3.12 with scikit-learn 1.9 against the examples above. Checked by an editor other than the author.

Walkthrough

ROC AUC is the chance that a random fraud scores above a random legit payment. Each fraud beats 940 of the 990 legit payments, so ROC AUC = 940 / 990 = 0.949.

To catch all 10 frauds, you flag every payment that scores 0.81 or more:

990 legit9,900 legit
flagged60510
recall10 / 1010 / 10
false positive rate50 / 990 = 5.1%500 / 9,900 = 5.1%
precision10 / 60 = 17%10 / 510 = 2%
ROC AUC0.9490.949
average precision0.0970.011

The ROC curve plots recall against the false positive rate, which divides by all legit payments. 5% sounds small, but it is 50 false alarms, five for every fraud. The PR curve plots precision against recall. Precision divides by what you flagged, so every false alarm counts.

Average precision (AP) is scikit-learn's usual PR AUC: the mean precision at each fraud, going down the list. Here the first fraud comes after 50 legit payments, so precision is 1/51, then 2/52, up to 10/60. The mean is 0.097.

Now grow the legit traffic 10 times with the same scores. Each fraud still beats the same share of legit payments, so ROC AUC doesn't move. But the false alarms grow 10 times, and AP drops to 0.011.

A model that scores at random gets ROC AUC 0.5 at any fraud rate, but its AP is about the fraud rate: 0.01 here. So judge AP against the fraud rate, not against 0.5.

Common mistakes

  • Reading ROC AUC 0.95 as "95% of flags are right". It measures ranking only. Here, at full recall, 50 of the 60 flags are wrong.
  • Comparing AP across datasets with different fraud rates. The same model gets 0.097 and 0.011. Compare models on the same data, and report the fraud rate next to AP.
  • Computing PR AUC as auc(recall, precision) and calling it AP. The trapezoid rule joins points with straight lines and gives another number, 0.088 here. average_precision_score uses steps.

Follow-up questions

  • "So is ROC AUC useless for fraud?" No. It checks ranking fairly, and a change in the fraud rate alone doesn't move it. But it can't tell you how many false alarms the review team will get. Report AP too, plus precision and recall at the threshold you will use.
  • "Can two models with the same ROC AUC have different AP?" Yes. AP cares most about the top of the list. Put 5 frauds above every legit payment and the other 5 below 100 legit payments. ROC AUC stays 0.949, but AP rises from 0.097 to 0.54, because the first five flags are all fraud.

What a strong answer covers

Explains that the false positive rate divides by all negatives and precision by flags. Shows it with counts at a real threshold. Knows that ROC AUC ignores the positive rate, while AP and its random baseline follow it.

Open in interactive practice deck →

Original OfferVibe question. Topic idea from Inside the Machine Learning Interview (Peng Shao, 2023); text, examples and code are our own.
© 2026 OfferVibe · Text CC BY-NC-SA 4.0 · code MITFree to share and adapt with credit, not for commercial use. Code samples are free for any use.