A model fθ is fit to minimise error over a training distribution Ptrain(X,Y). In production it sees Pserve(X,Y). Performance degrades when these diverge. There are two flavours:
WHY this distinction matters: if only P(X) shifted, sometimes reweighting/collecting more data fixes it. If P(Y∣X) shifted, you MUST retrain — the old labels no longer describe reality.
We want a scalar that says "the distributions differ." One classic is Population Stability Index (PSI), derived from the same idea as KL divergence.
Split a feature into k bins. Let ai = fraction of expected (training) samples in bin i, bi = fraction of actual (recent production) samples in bin i.
Why this form? We want a term that is 0 when ai=bi and grows as they differ, symmetrically. Start from KL: ∑biln(bi/ai). That is asymmetric. PSI symmetrises it:
What are the two types of drift, and which forces retraining?
Why is every PSI term guaranteed ≥0?
Why can retraining too often be a net loss?
What does the champion–challenger gate protect against?
Why must the eval set be temporally held out?
Recall Feynman: explain to a 12-year-old
Imagine you learned all the popular songs in your class last year, so you're great at guessing what your friends like. But this year new kids joined and everyone likes new songs — your old guesses start missing! A retraining pipeline is like a helper robot that keeps an eye on the class, notices when the songs have changed a lot, and quietly re-learns the new favorites. But it's careful: before trusting its new guesses, it plays a little game against its old self, and only switches if the new version really guesses better. That way it never gets worse by accident.
An automated, repeatable workflow that ingests fresh data, validates it, retrains, evaluates the candidate vs production, and promotes only if it passes quality gates (else rolls back).
Covariate (data) drift vs concept drift?
Covariate: P(X) changes, P(Y∣X) same. Concept: P(Y∣X) itself changes — this one forces retraining.
Write the PSI formula.
PSI=∑i(bi−ai)ln(bi/ai), over binned expected fractions ai and actual fractions bi.
Why is every PSI term non-negative?
(bi−ai) and ln(bi/ai) always share the same sign, so their product ≥0; the sum is 0 iff distributions match.
Champion = current prod model; challenger = freshly retrained candidate. Promote challenger only if it beats champion by margin δ on recent held-out data.
Why not retrain every hour?
Retraining has fixed cost Cr; if drift (staleness cost) is small, benefit < cost → net loss. Match frequency to drift rate.
Four common retraining triggers?
Scheduled (cron), performance-based, drift-based (PSI/KS), and data-volume-based.
Why must the evaluation set be temporally held out?
To avoid train–serve leakage and to mimic real production; reusing seen data inflates metrics and hides rot.
Does high PSI mean the model is broken?
No — PSI measures input drift, not accuracy. Confirm with actual performance before deciding.
Why version data + code + params together?
To reproduce and debug a model; the artifact alone can't tell you what produced it (lineage).
Dekho, ek trained model basically duniya ka ek photo hai jo training ke waqt liya gaya tha. Par duniya toh badalti rehti hai — users badalte hain, fraud ke tareeke badalte hain, prices badalte hain. Isko hum drift kehte hain. Do type ke hote hain: covariate drift (input P(X) badla par rule same) aur concept drift (asli rule P(Y∣X) hi badal gaya — yahan retrain karna zaroori hai). Retraining pipeline ek automatic machine hai jo yeh drift detect karti hai aur fresh model safely banati hai, bina baar-baar haath se notebook chalaye.
Drift ko measure karne ka ek simple tool hai PSI (∑(bi−ai)ln(bi/ai)). Iska mazaa yeh hai ki har term hamesha positive ya zero hota hai (kyunki (bi−ai) aur ln(bi/ai) ka sign hamesha same rehta hai), isliye jab distributions match karti hain toh PSI =0. Rule: <0.1 theek hai, >0.25 matlab "bhai retrain socho".
Sabse important cheez: kabhi bhi naya model bina check kiye deploy mat karo. Naya data corrupt ya seasonal noise ho sakta hai. Isliye champion vs challenger game khelo — purana model (champion) aur naya model (challenger) dono ko recent held-out data pe compare karo, aur naya tabhi promote karo jab woh purane se meaningfully behtar ho (margin δ se). Aur retrain har ghante mat karo — retraining ka cost hota hai; jab drift ka nuksaan retraining ke kharche se zyada ho, tabhi retrain karo. Yehi 80/20 hai: drift detect karo, gate lagao, lineage save karo — baaki sab detail baad mein.