The ML lifecycle
ML is a loop, not a project: frame the problem, get labeled data, build features, train, evaluate, deploy, monitor and retrain. The model code is the small part; the pipeline around it is the system.
Analogy: A restaurant isn't its recipe. Sourcing, prep, line cooks, health inspections and tasting the dish every night are what keep the food good long after opening day.
How it works
- Frame the problem first: the decision it drives, the metric and a non-ML baseline. Often a heuristic is enough.
- Collecting and labeling data is usually the slowest, costliest step of the loop.
- Evaluate offline per slice against the current model, then deploy from a registry via shadow, canary or A/B.
- Monitor inputs, predictions and outcomes, and retrain on a schedule or a trigger; without that, quality decays unnoticed.
- Google's maturity levels: 0 = manual notebooks, 1 = automated retraining pipeline, 2 = CI/CD ships the pipeline itself.
Check yourself
Answer to mark it learned; your answers aren't scored.
Your retraining pipeline produced a fraud model whose overall AUC beats production by 0.01, but on new users its AUC dropped 4 points. The PM says ship it, since the overall number is up. What do you do?
Go deeper
Full explanation
The ML lifecycle is the loop that turns data into a model in production and keeps it good as the world changes:
- Frame the problem: the decision it drives, the metric, a non-ML baseline. Often a heuristic is enough.
- Collect and label data: usually the slowest, costliest step.
- Build features: turn raw data into model inputs, identically for training and serving (Training–serving skew).
- Train and track every run (Experiment tracking & reproducibility).
- Evaluate offline against the current model, per slice, not just on average.
- Deploy from a Model registry & versioning via shadow, canary or A/B.
- Monitor inputs, predictions and outcomes (Data drift & concept drift).
- Retrain on a schedule or a trigger, and go around again.
Hidden Technical Debt in Machine Learning Systems (Sculley et al., NeurIPS 2015) drew the model code as a tiny box surrounded by configuration, data collection and verification, feature extraction, serving and monitoring. ML adds its own debt: changing anything changes everything, glue code, pipeline jungles and hidden feedback loops.
Google's MLOps maturity levels measure how much of the loop is automated:
- Level 0: manual notebooks; a person hands a model file to engineering.
- Level 1: the training pipeline is deployed and retrains automatically (continuous training), with data and model validation.
- Level 2: CI/CD tests and ships the pipeline itself.
Code A level-1 continuous-training pipeline with gates
# Level 1 MLOps: you deploy this PIPELINE, not a model file.
# It runs weekly or on a drift alert and promotes only a proven winner.
# load_window, validate_schema, build_features, train, evaluate, registry
# are your own pipeline steps.
def continuous_training(run_date: str) -> None:
raw = load_window(end=run_date, days=90)
report = validate_schema(raw, expected="schemas/orders_v7.json")
if report.anomalies: # bad data must stop the line, not train a bad model
raise RuntimeError(f"data validation failed: {report.anomalies[:3]}")
X, y = build_features(raw) # the same code the serving path imports
model = train(X, y, params="configs/gbm.yaml")
champion = registry.load("fraud-scorer", stage="production")
slices = ["country", "new_user"]
cand = evaluate(model, holdout="last_14_days", slices=slices)
prod = evaluate(champion, holdout="last_14_days", slices=slices)
# Promote only if better overall AND no slice regresses by > 1 point
if cand.auc > prod.auc and cand.worst_slice_drop(prod) < 0.01:
registry.register(model, name="fraud-scorer", stage="staging",
metadata={"data_end": run_date, "auc": cand.auc})Real example
A fraud team ships a gradient-boosted model at level 0: a data scientist trains in a notebook, hands over a pickle, and engineers wrap it in a service. Six months later fraudsters have changed tactics and precision has slid from 0.82 to 0.64. Nobody noticed, because nothing monitored outcomes, and retraining means two weeks of re-running notebooks. At level 1 they deploy the training pipeline instead: weekly retrains on 90 days of data, schema validation, a champion–challenger gate per country, and an alert on chargeback rate. Retraining becomes a non-event, and the next tactic shift is caught in days.
Trade-offs +3 · −3
+ You gain
- Makes the hidden costs visible: data, validation and monitoring get owners and budgets.
- Continuous training turns model decay from an incident into a routine job.
- Levels 0/1/2 give a shared vocabulary to scope platform investment honestly.
− You pay
- Level 2 is real platform work: months of engineering rarely pay off for a single model.
- More moving parts: pipelines, registries and validators need their own maintenance and on-call.
- Automated retraining will faithfully learn from bad labels or a broken feedback loop.
Use it when
Any model that will live longer than a quarter or whose inputs change. Automate in proportion to how often you retrain and how costly a silent failure is.
Avoid it when
A one-off analysis or a stable batch model retrained yearly: a documented level-0 process plus monitoring is enough. Skip ML entirely when a heuristic meets the bar.
Numbers to know 4
- Google's maturity levels: 0 = manual, 1 = automated continuous training, 2 = CI/CD of the pipeline itself.
- Google's level-0 description: a new model version is deployed only a couple of times per year.
- Sculley et al. (NeurIPS 2015): ML code is only a small fraction of a real-world ML system.
- Rules of ML #1: don't be afraid to launch a product without machine learning.
Common pitfalls 4
- Deploying the model file instead of the pipeline that produced it: nobody can retrain it six months later.
- Evaluating only the average metric; regressions hide in slices like new users or one country.
- Monitoring latency and errors but not prediction quality: the model fails silently behind HTTP 200.
- Skipping framing: optimizing AUC when the decision needs calibrated probabilities at one threshold.
Interview questions 2
Answer out loud first, then reveal.
What's the difference between MLOps level 0, 1 and 2?Show answer
It's about what is automated. At level 0 a person trains in a notebook and hands a model artifact to engineering; releases are rare and nothing watches quality. At level 1 we deploy the training pipeline itself, so it retrains on new data automatically, with data validation, model validation against the champion, and a registry. Level 2 adds CI/CD for the pipeline code, so changing features or the algorithm is tested and shipped like any service. I move a model to level 1 once it needs retraining more than quarterly; level 2 pays off across many models or a platform team.
What does "Hidden Technical Debt in ML Systems" argue, and what do you do about it?Show answer
That ML erodes the boundaries normal software relies on. A model entangles all its inputs, so shifting one feature changes everything; data dependencies are undeclared and harder to track than code; models create feedback loops with the users they influence; and most of the code is glue around a small core. What I do: budget for data validation, monitoring and pipeline ownership from day one, version data and configs like code, and treat the model as the cheap part to write and the expensive part to keep correct.