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

Dataset shift

Watch a model that tests well fail when serving data moves away.


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.04 · SHIFT BAYTRAIN 94% · 32 ORDERS
01
Stage 1 of 6 · Train the model
Logistic regression learns a line from 32 training orders. Above the line, it predicts late.
Explain it simply

Each dot is a food order: its hour and its road distance. A filled dot came late, and a ring came on time. The dashed curve is the world's rule: later in the day, traffic makes shorter trips late. The blue line is the model's guess at that rule.

32 training orders between 8:00 and 13:30. The model line splits late from on time. 30 of 32 are right.

order (filled = late)the world's rulemodel line, accuracywrong, gap, flagserving code change
training ordersmonitor8:0012:0016:0020:0002468order hourdistance (km)8:0012:0016:0020:0002468order hourdistance sent (km)modelruletrain94%training ordersmonitor8:0012:0016:0020:0002468order hourdistance (km)8:0012:0016:0020:0002468order hourdistance sent (km)modelruletrain94%
Toy: 32 training, 24 test, 24 serving orders · rule 6 − 0.03(h − 8)² km plus noise · logistic regression
STAGE 1 / 6
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
p(late)=σ(wh h+wd d+b)\sy{p}{out}{p(\text{late})} = \sigma(\sy{w}{param}{w_h}\,\sy{h}{data}{h} + \sy{w}{param}{w_d}\,\sy{d}{data}{d} + \sy{w}{param}{b})
p=σ(0.42 h+4.08 d−28.05);acctrain=30/32=94%p = \sigma(0.42\,h + 4.08\,d - 28.05);\quad \mathrm{acc}_{\text{train}} = 30/32 = 94\%

The model turns the hour and the distance into a chance of late.

Common mix-ups

MYTHA high test accuracy means the model works after launch.

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

Predict, then reveal
3 CHECKS · PRO
Q01With covariate shift, the size goes from small to large. Does serving accuracy rise or fall?

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.