5.3.1MLOps & Deployment

ML project lifecycle

2,554 words12 min readdifficulty · medium

WHY does a lifecycle exist at all?

The canonical stages (Google/Andrew Ng framing):

  1. Scoping — define the problem, metrics, feasibility, value.
  2. Data — collect, label, clean, establish a baseline.
  3. Modeling — train, error-analyze, iterate.
  4. Deployment — serve predictions to real users/systems.
  5. Monitoring & Maintenance — detect drift, retrain, loop back.
Figure — ML project lifecycle

Stage 1 — Scoping (the highest-leverage 20%)

HOW (checklist):

  • Identify the business/user problem and the decision it drives.
  • Choose a north-star metric and a satisficing metric (e.g. maximize accuracy subject to latency <100< 100 ms).
  • Estimate feasibility (is human-level performance possible? is signal in the data?) and value (does a 2% lift matter?).

Stage 2 — Data


Stage 3 — Modeling

Model-centric ("improve the model on fixed data") vs data-centric ("improve the data for a fixed model") — modern practice leans data-centric because clean data generalizes better.


Stage 4 — Deployment

Deployment patterns (each reduces blast radius):

  • Shadow deployment — model runs on live traffic but its output is not used; you compare silently.
  • Canary deployment — route a small % (e.g. 5%) of traffic, watch, then ramp up.
  • Blue-green deployment — two full environments, switch traffic instantly, roll back instantly.

Degrees of automation: Human only → Shadow → AI assist → Partial autonomy → Full autonomy.


Stage 5 — Monitoring & Maintenance


Worked Examples


Common Mistakes (Steel-manned)


Active Recall

Recall Quick self-test (hide answers, forecast first)
  • Name the 5 stages in order.
  • What is the difference between data drift and concept drift?
  • Given HLP 1%, Train 5%, Dev 6% — where do you focus?
  • Why is shadow deployment safer than canary for a first rollout?
  • Write the expected-value-of-project formula and name each term.
  • What does it mean if TrainErr comes out below HLP?
Recall Feynman: explain to a 12-year-old

Imagine you train a puppy (the model) using treats from last summer. You define what "good behavior" means (scoping), collect treats and show examples (data), teach the puppy (modeling), then let it loose at a party (deployment). But people at the party act differently than in practice, so you keep watching and go back to re-teach when it messes up (monitoring). You never stop watching — that's why it's a loop, not a one-time trick.


Connections


What are the 5 stages of the ML project lifecycle in order?
Scoping → Data → Modeling → Deployment → Monitoring & Maintenance.
Why is the ML lifecycle a loop rather than a line?
Because deployment reveals drift and errors that feed back into earlier stages (data/modeling) for retraining.
What is the difference between data drift and concept drift?
Data drift = P(x) changes; concept drift = P(y|x) changes (same input, different correct label).
Define avoidable bias and how it's computed.
Avoidable bias = TrainErr − Human/Bayes level; large positive value → improve model/features.
Define variance in the error-decomposition sense.
Variance = DevErr − TrainErr; large value → get more/cleaner data or regularize.
Is HLP/Bayes error a strict lower bound on TRAINING error?
No. An overfit model can achieve training error below HLP/Bayes; HLP only floors the best achievable generalization (dev/test) error.
What does it signal if TrainErr < HLP?
Overfitting — the model memorizes noise; avoidable bias becomes negative/meaningless, so focus on the variance (generalization) gap.
What does shadow deployment do?
Runs the model on live traffic but ignores its outputs, letting you compare it to the current system safely.
What does canary deployment do?
Routes a small fraction of traffic to the new model, monitors, then gradually ramps up.
Write the expected-value-of-project formula.
E[Value] = p_success · V_success − C_build − C_maintain.
Why can a lower-accuracy model be the better deployment choice?
Because the north-star is a business metric under constraints (latency, cost, fairness), not raw accuracy.
What is a baseline and why establish one early?
A simple reference (human level / heuristic / trivial model) that shows whether the real model adds value and how much headroom exists.
Data-centric vs model-centric AI?
Data-centric improves the data for a fixed model; model-centric improves the model on fixed data.

Concept Map

iterative stages

then

then

then

then

feedback retrain

triggers

causes model rot

quantified by

defines

establishes

compared against

ML Lifecycle Loop

Scoping

Data

Modeling

Deployment

Monitoring & Maintenance

Data Drift

Expected Value E of Project

Baseline

North-star & Satisficing Metrics

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Dekho, ML project ek "ek baar train karo aur bhool jao" wali cheez nahi hai — ye ek loop hai. Sochoo farming ki tarah: plant karo, ugao, kaato, phir season badalta hai to dubara plant karo. Paanch stages hote hain: Scoping (problem aur metric decide karo), Data (data collect, label aur clean karo, ek baseline set karo), Modeling (train karo aur error analysis karo), Deployment (real users tak model pahuchao), aur Monitoring (drift pakdo, retrain karo, wapas loop me jao).

Sabse important baat: scoping sabse high-leverage stage hai. Agar tum galat metric optimize kar rahe ho to 99% accuracy bhi bekaar hai. Expected value formula E[Value]=psuccessVCbuildCmaintainE[Value] = p_{success}\cdot V - C_{build} - C_{maintain} isliye hai taaki decide kar sako project banana worth hai ya nahi. Aur bias/variance split (TrainErr − HLP vs DevErr − TrainErr) batata hai ki tumhe model improve karna hai ya zyada/clean data laana hai — ye 80/20 decision hai. Ek dhyan ki baat: HLP/Bayes error training error ke liye pakka lower bound nahi hai — agar model overfit ho jaye to TrainErr HLP se bhi neeche ja sakta hai (noise memorize karke). Us case me "avoidable bias" negative ho jata hai aur matlab yahi ki overfitting ho rahi hai — tab variance/generalization gap par focus karo.

Deployment me seedha full rollout mat karo — pehle shadow (output use nahi hota, sirf compare), phir canary (thoda sa traffic), phir ramp up. Aur deploy karne ke baad kaam khatam nahi hota: duniya ka data change hota rehta hai, isko drift kehte hain (data drift = input badla, concept drift = same input par sahi answer badla). Isiliye monitoring lagakar rakhna zaroori hai, warna 2 baje raat ko model chup-chaap fail ho jayega. Yaad rakho: ye cycle hai, line nahi.

Go deeper — visual, from zero

Test yourself — MLOps & Deployment

Connections