Log inStart free
LESSON 4.C7 · 6 STAGES · 2 CONTROLS · 3 CHECKSPRO · PREVIEW

ROC vs PR under class imbalance

Watch one classifier at two class balances: the ROC curve holds, the PR curve falls.


Pro lesson. Stage 1 is free to watch. Pro opens all 6 stages, 2 controls and 3 checks, in this lesson and every other.

Go Pro · $8.25/mo
EXPLAINER · 4.C7 · EVALUATION BAYT 0.5 · TP 40 · FN 10 · FP 12 · TN 38
01
Stage 1 of 6 · Scores, threshold
One classifier scores 100 samples. The threshold t = 0.5 sorts them into a confusion matrix.
Explain it simply

Each mark is one test sample. Here 50 dots are class 1 and 50 squares are class 0. Every mark at or right of the threshold line is called class 1. The red marks are the wrong calls.

50 dots and 50 squares on a score axis from 0 to 1. The threshold at 0.5 gives 40 true positives, 10 false negatives, 12 false positives and 38 true negatives.

samples: dot class 1, square class 0wrong callsthreshold trates, curves, areasguessing, random
t = 0.500.10.20.30.40.50.60.70.80.91scoreclass 1 · 50class 0 · 50predicted 1predicted 0actual 1actual 0TP40FN10FP12TN38accuracy = (40 + 38)/100 = 78%F1 = 2·40/(2·40 + 12 + 10) = 0.78specificity = 38/50 = 0.76confusion matrix · 4.48scores · threshold · confusion matrix · 50/50t = 0.500.10.20.30.40.50.60.70.80.91scoreclass 1 · 50class 0 · 50predicted 1predicted 0actual 1actual 0TP40FN10FP12TN38accuracy = (40 + 38)/100 = 78%F1 = 2·40/(2·40 + 12 + 10) = 0.78specificity = 38/50 = 0.76confusion matrix · 4.48scores · threshold · confusion matrix · 50/50
Toy: the 100 test samples of 4.48, one seeded classifier
STAGE 1 / 6
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
TP+FN+FP+TN=n\sy{tp}{data}{TP} + \sy{fn}{grad}{FN} + \sy{fp}{grad}{FP} + \sy{tn}{data}{TN} = n
40+10+12+38=10040 + 10 + 12 + 38 = 100

The four cells count every sample once.

Common mix-ups

MYTHA high ROC-AUC means most flagged samples are real.

The fix, and 1 more mix-up with the diagram to show them, come with Pro.

Predict, then reveal
3 CHECKS · PRO
Q01Switch the balance to 95/5. Which curve drops?

Make your guess, then test it in the diagram. All 3 checks come with Pro.

PRO LESSON · YOU WATCHED STAGE 1 OF 6
Unlock the full explainer
  • 5 more stages and 2 live controls
  • 2 mix-up cards and 3 predict-then-reveal checks
  • Watch it as a narrated video, in three voices
  • Every Pro lesson and capstone · 656 in total

$99 a year, or $15 a month. Cancel any time.