Exercises — Model retraining pipelines
Every symbol used here is built in the parent note; where a new idea appears I re-anchor it in plain words so you never meet a symbol cold.
Level 1 — Recognition
(Can you name the parts and read the numbers off correctly?)
Exercise 1.1 — Name the drift
A spam filter suddenly sees a flood of emails written in a new language it was never trained on. The definition of "spam" (unwanted mail) has not changed at all. Which kind of drift is this — data drift or concept drift?
Recall Solution
Think of the two probabilities from the parent note:
- = "what do inputs look like?"
- = "given this input, what is the correct label?"
The inputs changed drastically (new language = new word distribution), so shifted. But "unwanted mail is spam" — the rule — is unchanged. Answer: data drift (covariate shift). == changed, stayed.==
See Data drift and concept drift for the full taxonomy.
Exercise 1.2 — Read the PSI table
You compute for a feature. Using the parent's rule of thumb, what is the status, and what action does it call for?
Recall Solution
Rule of thumb: stable, – moderate, significant. sits in → moderate shift — "watch". Action: investigate / monitor, do not auto-trigger a retrain yet. PSI is an input-drift signal, not a performance signal (Model monitoring and observability).
Exercise 1.3 — Match trigger to situation
Ground-truth labels arrive 6 months late (loan defaults). Which trigger type is most appropriate: scheduled, performance-based, drift-based, or data-volume-based?
Recall Solution
Performance-based triggers need fast labels to measure accuracy — you don't have them (6-month delay). By the time accuracy drops, you're 6 months too late. Answer: drift-based (PSI or the KS test on inputs, both defined above). It catches an input shift before accuracy visibly falls, which is exactly the case when labels are delayed.
Level 2 — Application
(Plug into the formulas from the parent note.)
Exercise 2.1 — Compute PSI (2 bins)
Expected , Actual . Compute PSI to 4 decimals and classify.
Recall Solution
Recall .
Why this exact form? We want a number that is when the two distributions match and grows as they differ. The log ratio measures how many times bigger production bin is than training bin — it is when they are equal, positive when the bin grew, negative when it shrank. Multiplying by does two jobs at once: it weights the log by how much probability mass actually moved, and it guarantees a non-negative term, because and always share a sign (both positive if the bin grew, both negative if it shrank). Their product is therefore in every bin, so the whole sum is iff everywhere — exactly what a distance-like drift score must do.
Bin 1: Bin 2:
Sum: . → stable (barely). Both terms positive, as required.
Exercise 2.2 — Cost logic: is retraining worth it?
A model loses accuracy per week. Each accuracy \approx \8{,}000C_r=$1{,}200$ (one-time) and fully restores accuracy. You are deciding at week 5 of drift. Assume the fresh model then runs for at least one more week. Over a one-week horizon, should you retrain?
Recall Solution
To compare a one-time cost with a recurring benefit fairly, we must fix a horizon. Here we compare over one week going forward: the retrain costs once, and it recovers the accumulated accuracy loss for (at least) the next week of running.
Step — accumulated accuracy lost by week 5. Why? This is the staleness cost made concrete — it grew over the weeks since the last retrain. Lost .
Step — one-week revenue benefit of recovering it. Why? Restoring accuracy buys back worth of weekly revenue, and we count it over our one-week horizon. 0.75 \times \8{,}000 = $6{,}000$ recovered over the week.
Step — compare over the same horizon. Benefit \6{,}000\gg C_r=$1{,}200$ (one-time). Answer: retrain. Even a single week's recovered revenue dwarfs the one-time job cost — and every additional week the fresh model runs only widens the gap.
Exercise 2.3 — Champion–challenger gate
Champion AUC . Challenger AUC . Noise band . Promote or not?
Recall Solution
Gate: promote . Difference . → promote the challenger. The improvement clears the noise band, so it is unlikely to be random wiggle. See Champion-Challenger and A-B testing.
Level 3 — Analysis
(Now reason about why, edge cases, and consequences.)
Exercise 3.1 — The daily-retrain trap
Using Exercise 2.2's numbers (loss per week, \8{,}0001%C_r=$1{,}2007\times$ per week). Show numerically that this is a net loss over a one-week horizon, and state the general rule.
Recall Solution
We compare cost and benefit over one week so the units match.
Step — weekly cost of daily retraining. 7 \times C_r = 7 \times \1{,}200 = $8{,}400$ per week.
Step — weekly benefit. Daily retraining keeps accuracy near-perfect, so it recovers at most one week's worth of drift: 0.15\% \times \8{,}000 = $1{,}200$ recovered per week.
Step — net over the week. \1{,}200 - $8{,}400 = -$7{,}200 per week. **Net loss of \7,200 per week.**
General rule: retraining frequency must match the drift rate. Recall = one-time retrain cost and = staleness cost accumulated over time . Paying over and over to recover a tiny (because was kept small) is wasteful. This is the parent's cost inequality read in reverse: when is forced small, never climbs above , so the retrain never pays for itself.
Exercise 3.2 — High PSI, healthy model
PSI on your main feature jumps to (significant). Yet live F1 is unchanged at . Should you ship a freshly retrained model purely because PSI is high? Explain in terms of vs .
Recall Solution
PSI measures input drift — a change in only. It says nothing directly about , the input→output rule. Here inputs shifted ( moved, PSI ) but the rule is stable ( unchanged), and the model is robust to the new input region — hence F1 held at . Answer: do NOT ship purely on PSI. Treat PSI as an early-warning trigger to investigate, then confirm with actual performance before promoting. Shipping a retrain here risks replacing a working champion with an unproven challenger.
Exercise 3.3 — Degenerate PSI bins (both empty cases)
In a PSI computation you hit two degenerate bins on different features: (a) a production bin has while (nothing landed there this month); (b) a training bin has while (a brand-new input region the model never saw in training). For each, show what breaks in the formula, and give the standard fix.
Recall Solution
(a) Empty production bin, . Term . , so the term is . PSI blows up.
(b) Empty training bin, . Term . , so the term is . PSI blows up here too — the symmetric failure: a division by zero inside the log instead of a .
Standard fix — floor BOTH sides. Replace any zero (whether in or ) with a tiny , e.g. , before computing the ratio; or merge sparse bins so no bin is empty. Flooring only one side (a common bug) still leaves case (b) — or case (a) — divergent. Empty bins on either distribution are the degenerate case you must guard against.
Level 4 — Synthesis
(Assemble multiple stages into one coherent pipeline decision.)
Exercise 4.1 — Order the pipeline stages
You are given these five stages in scrambled order: (A) promote if it passes the gate, (B) ingest fresh data, (C) evaluate challenger vs champion, (D) validate the data, (E) re-train the candidate. Put them in the correct order and explain why each precedes the next.
Recall Solution
Correct order: B → D → E → C → A.
- B ingest first — no data, nothing to do.
- D validate before training — the parent's rule: never train on garbage. If validation fails you stop here.
- E re-train on validated data → produces the challenger.
- C evaluate challenger vs champion on a temporally held-out recent slice.
- A promote only if the gate passes, else roll back.
The whole point of ordering is that each stage can fail independently; a failure early stops the flow before you waste compute or ship a bad model.
Exercise 4.2 — Design triggers for two products
Product X has instant labels (ad click: yes/no in seconds). Product Y has 6-month-delayed labels (loan default). For each, choose the primary trigger and give the one-line justification.
Recall Solution
- Product X → performance-based trigger. Labels are instant, so you can watch live accuracy and retrain exactly when it drops — saving compute (retrain only when needed).
- Product Y → drift-based trigger (PSI or KS on inputs). Labels are 6 months late, so you cannot wait for accuracy; detect the input shift early as a proxy. Optionally add a scheduled safety net (e.g. quarterly).
This matches the parent's trigger table: the label delay is the deciding variable.
Exercise 4.3 — When does a data-volume trigger fire?
A fraud model was trained on transactions. Your team's policy is: retrain once accumulated new, validated transactions reach of the original training size. New validated transactions arrive at per day. (a) How many new transactions trigger a retrain? (b) After how many days does the data-volume-based trigger fire? (c) Why is "enough new data" a sensible trigger at all?
Recall Solution
(a) Threshold. of new validated transactions.
(b) Days to fire. .
(c) Why it works. New data = new information worth learning. Once a meaningful fraction of fresh, validated examples has accumulated, retraining lets the model absorb patterns that simply did not exist in the old snapshot — even if PSI has not yet crossed a drift threshold. It is a volume proxy for "there is now enough signal to be worth the retrain cost ." Note the word validated: the trigger counts only data that already passed stage D, so it never fires on garbage.
Level 5 — Mastery
(Everything at once: derive, decide, and defend under a limiting case.)
Exercise 5.1 — PSI is symmetric; KL is not
Using the KL divergence defined at the top of this page, show numerically with , that swapping the roles of and leaves PSI unchanged but changes the KL divergence . This is why the parent symmetrised KL into PSI.
Recall Solution
PSI, original direction (): . Bin1 Bin2 .
PSI, swapped (): each term becomes . Bin1 Bin2 Swapped — identical. Why identical algebraically: and , so the two minus signs cancel in every bin. PSI is symmetric. ✓
KL divergence, : .
KL the other way, : .
→ KL is asymmetric. That asymmetry (only , or only , weights the terms) is exactly why PSI multiplies by the symmetric factor : it forces both symmetry and per-bin non-negativity. See KL divergence.
Exercise 5.2 — Full decision under conflicting signals
A pipeline reports: PSI (significant input drift), challenger F1 , champion F1 , noise band , and the challenger's evaluation set overlaps the training data by 20%. Walk through the correct decision.
Recall Solution
Process each signal in order:
- PSI → significant input drift. This is an investigate trigger, not a ship order (Ex 3.2 logic).
- Evaluation set overlaps training by 20% → train–serve leakage! The F1 numbers are inflated and untrustworthy. Fix first: re-evaluate on a temporally held-out, unseen slice.
- Gate on trustworthy numbers: even taking at face value, → inside the noise band.
Decision: do NOT promote. The leaked eval invalidates the comparison, and even the leaked gap fails the gate. Correct action: fix the eval split, re-run on unseen recent data, then re-apply the gate. Log everything (lineage).
Exercise 5.3 — Limiting behaviour of the cost rule
Let staleness cost be (linear, r=\1{,}500C_r=$3{,}000t^{\star}t\to 0t\to\infty$.
Recall Solution
Retrain when benefit cost: . Interpretation:
- (just retrained): → you should never retrain immediately; you'd pay the full one-time to recover almost nothing (this is precisely the daily-retrain trap of Ex 3.1).
- : → drift always eventually justifies a retrain. Staleness cost grows without bound, so waiting forever is never optimal either. The only real question is when, and the answer is the crossover .
This closes the loop: the whole "how often to retrain" debate reduces to comparing the drift slope against the fixed job cost . Steeper drift (larger ) pushes earlier; a cheaper job (smaller ) does the same.
Wrap-up recall
Recall One-line answers to the whole ladder
- Language flood on a spam filter ::: data drift ( moved, rule stable)
- PSI status at ::: moderate — watch, don't auto-retrain
- Trigger for 6-month-delayed labels ::: drift-based
- What the KS statistic measures ::: the biggest vertical gap between the two input CDFs
- What and mean ::: one-time retrain cost; staleness cost accumulated over time
- Days for a -of- volume trigger at per day ::: days
- Break-even week when ::: weeks
- Why symmetrise KL into PSI ::: KL is asymmetric; factor forces symmetry and per-bin non-negativity
- Two degenerate PSI cases ::: gives ; gives — floor BOTH sides
- Correct move under high PSI but stable F1 ::: investigate, don't ship
- What kills the champion–challenger gate ::: train–serve leakage in the eval set