Log inStart free
LESSON 4.56 · 6 STAGES · 2 CONTROLS · 3 CHECKSPRO · PREVIEW

Class imbalance remedies

Watch four remedies move a fraud detector's line toward the rare class.


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.56 · IMBALANCE BAY64 NORMAL · 8 FRAUD · 1:8
01
Stage 1 of 6 · Imbalanced data
The training set has 64 normal squares and 8 fraud dots. This class imbalance is 1:8.
Explain it simply

Each square is a normal card payment, and each dot is a fraud. There are 8 squares for every dot. That gap is called class imbalance. Fraud is rare in real life too, so the test set has the same mix.

A plane with 64 normal squares in the lower left and 8 fraud dots in the upper right. Two bars count each class.

square: normal payment, dot: frauddropped rowSMOTE linkcopies, class weight sdecision boundary, test scores
x₁x₂0551010rows in the lossnormal64fraud8training rows on the plane64 normal : 8 fraud = 1 : 8x₁x₂0551010rows in the lossnormal64fraud8training rows on the plane64 normal : 8 fraud = 1 : 8
Toy: 64 normal payments, 16, 8 or 4 frauds, seeded
STAGE 1 / 6
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
r=n0n1\sy{r}{data}{r} = \frac{\sy{n0}{data}{n_0}}{\sy{n1}{data}{n_1}}
r=648=8r = \frac{64}{8} = 8

The imbalance is the number of normal rows per fraud row.

Common mix-ups

MYTHHigh accuracy means the model catches the fraud.

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

Predict, then reveal
3 CHECKS · PRO
Q01At 1:16, does the plain model catch more or fewer test frauds than at 1:8?

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.