Shifting Sands
Robo's ice-cream model learned from summer days: warm and dry means kids buy ice cream. Now it is out in the real world, guessing for every kid who walks by. But the world keeps changing. Will Robo notice?
Press Play to start the stream of kids. Then use Change the world to bring a heat wave, a cold snap or a price rise, and watch my accuracy and the drift light.
Kid 0 of 2400
Top: each dot is one kid, placed by the temperature that day. The dashed line is Robo's rule: warmer than this and Robo guesses "buys". Bottom: how many of the last 200 guesses were right.
Challenges
What just happened?
- Robo learned from summer. When new kids stop looking like the training kids, that is called drift.
- A heat wave brought days hotter than any Robo had seen. On really hot days kids stay inside, but Robo never learned that, so it got lots wrong.
- A cold snap made the drift light go red, yet Robo was still right: "too cold, no ice cream" was easy. An alarm does not always mean trouble.
- When the price doubled, the days looked exactly the same, so the light stayed green. But the rule changed! Only checking real answers caught it, and those answers arrive late.
- Retraining on recent kids fixes Robo, but it costs something each time. Retraining at every wobble, like when the seasons turn, can even make things worse.
How it works
- Train a model once on summer days: temperature, weekend or not, rain or not. It learns a simple rule.
- Every new kid gets a guess right away. Their real answer (bought or not) shows up later.
- Drift check: sort temperatures into 10 buckets and compare how full each bucket is for training days and for the last 200 kids. Big differences add up to a big PSI.
- Accuracy check: of the last 200 kids whose answers have arrived, how many did Robo get right?
- If things look bad, retrain on the 300 most recent kids with answers. Those kids become the new "normal" for the drift check.
For grown-ups: what's really going on
A logistic regression on (standardised temperature, weekend, rain) is trained on 400 "summer" rows. True labels come from logit = 0.75·(min(T,31) − θ) − 1.6·max(0, T − 31) + 1.2·weekend − 2.2·rain with θ = 22°C, so the summer data never reveals the "too hot" downturn. The stream then serves one row per tick, generated with a seeded RNG.
- Covariate shift changes
P(x)but notP(y|x). Heat wave: T ~ N(36.5, 2.5) exposes the unseen part ofP(y|x)(extrapolation failure). Cold snap: T ~ N(12, 4) is a big shift that barely hurts, because the model is right far from its boundary. - Concept drift changes
P(y|x): "Price doubles" moves θ to 29°C. Feature monitors (PSI, KS) cannot see it; only labelled performance can, delayed by the label-delay slider. "Seasons" is a recurring shift (T mean ± 11°C, period 700 ticks). Sudden = a step; gradual = a 300-tick linear blend of all parameters. - PSI
= Σk (ak − ek) ln(ak/ek)over 10 reference-quantile bins (two bins for the binary features), shares floored at 10⁻⁴. Rule of thumb: < 0.1 stable, 0.1–0.25 moderate, > 0.25 major. With finite samples PSI is biased upward: under no driftE[PSI] ≈ (B − 1)(1/n + 1/m), about 0.07 here, which is why the amber light needs PSI > 0.1 and a significant KS test. - Two-sample KS:
D = supx |Fref(x) − Frecent(x)|, with the large-sample 5% critical value1.358·√((n+m)/(nm)). With big windows KS flags tiny, harmless shifts; with small ones it misses real ones. - Retraining refits on the most recent 300 labelled rows and resets the drift reference to them. Accuracy-triggered retraining reacts to concept drift but lags by the label delay; PSI-triggered retraining reacts fast but fires on harmless shifts. Seasonal drift punishes a short sliding window: better to train on a full cycle or add season features.
Further reading: Gama et al. (2014), A Survey on Concept Drift Adaptation; Rabanser, Günnemann and Lipton (2019), Failing Loudly: An Empirical Study of Methods for Detecting Dataset Shift.