Level 3 In-Depth AI · ML Engineering and Production
The ML Project Lifecycle
A machine learning project is a loop, not a straight line. Frame the problem, build a dumb baseline, get data, iterate on what the errors tell you, ship, watch, and go round again. Most projects fail on the steps around the model, not on the model itself.
- Level
- ●●●●● Beginner
- Reading
- 12 min
- To learn it well
- 40 minutes to read, an afternoon to practise
- Builds on
- 4 concepts →
- Quiz
- 5 questions ↓
Read first
Supervised LearningThe full path from zero — 4 concepts before this one
- What Is AI?
- How Machines Learn
- Supervised, Unsupervised and Reinforcement Learning
- Supervised Learning
- The ML Project Lifecycle
Read them roughly in this order. See it on the concept map →
Why it matters
Courses teach you to train a model on a clean dataset and report its accuracy. A real project starts with a vague wish ("can AI reduce customer churn?") and ends, if it ends well, with a system that runs every day, makes decisions people act on, and keeps working as the world changes. The model is one box in the middle of that journey.
Industry surveys have repeatedly found that many machine learning prototypes never reach production. The exact percentages quoted online are poorly sourced, but practitioners broadly agree on why projects fail, and it is rarely because the algorithm was not clever enough:
- The team solved the wrong problem, or a problem nobody would act on.
- Success was measured with a number that didn't track what the business cared about.
- The data was not available at prediction time, or was quietly different in production.
- Nobody compared the model against a simple rule, which turned out to be nearly as good.
- The model shipped and then decayed unnoticed.
The ML project lifecycle is the sequence of stages a project goes through, from framing to monitoring, and the loops back between them. Knowing it lets you spend effort where it matters. This chapter is the map for the rest of this part of the guide: Experiment Tracking and Reproducibility, Data Pipelines and Datasets, Deploying Models and Monitoring and Data Drift each zoom into one stage.
The intuition
Think of opening a restaurant rather than inventing a recipe. The recipe matters, but you also have to decide what kind of restaurant the street needs, find reliable suppliers, check that the dish can be cooked in ten minutes during a rush, open the doors, read the reviews, and change the menu when tastes shift. A brilliant recipe in a restaurant nobody visits is a failure.
An ML project has the same shape. It is a loop:
Two features of the picture matter more than the boxes.
- It is a loop. You go round many times. The first lap should be fast and crude: a simple model on whatever data you have, shipped to a small audience, just to learn where the real difficulties are.
- The arrows go backwards too. Error analysis sends you back to collect more data. Monitoring tells you the world changed. Sometimes deployment reveals that you framed the problem wrong, and you start again from the top.
Key idea Get a crude end-to-end system working first, measure it with a number the business cares about, and only then make the model clever. Most of the gain comes from better framing and better data, not a fancier algorithm.
How it works
Stage 1: frame the problem
Problem framing means turning a wish into a precise prediction task. "Reduce churn" is a wish. A framing is: each Monday, for every active subscriber, predict the probability they cancel within 30 days, so the retention team can phone the 10% most at risk.
A good framing answers five questions:
- What exactly is predicted? The target ("cancels within 30 days"), and for whom.
- When is the prediction made, and with what information? Only data available at that moment can be used. A feature like "number of calls to the cancellation line" is useless if it is only recorded after the customer leaves. Using it is data leakage.
- What action follows? If no one will act differently because of the prediction, stop here.
- What does an error cost? Missing a churner (false negative) costs a lost customer. Calling a happy one (false positive) costs a few minutes of an agent's time. These costs decide your threshold and your metric.
- Does it need ML at all? If a hand-written rule gets you 90% of the value, ship the rule. Google's Rules of Machine Learning opens with exactly this advice: don't be afraid to launch a product without machine learning.
Stage 2: choose the metric
Two kinds of metric matter, and confusing them is a classic failure.
- The business metric is what the organisation actually cares about: customers retained, revenue, minutes saved, fraud losses avoided.
- The proxy metric is what you can compute offline on a test set: accuracy, precision, recall, AUC, RMSE (Evaluation Metrics). It is a stand-in for the business metric, and it is only useful if improving it improves the business metric.
Pick the proxy that mirrors the decision. In the churn example, the team phones a fixed 10% of customers, so the natural offline metric is: of all customers who will leave, what share are among the 10% we call? Accuracy is useless here. About 89% of customers stay, so a model that says "nobody leaves" is 89% accurate and saves nobody.
Stage 3: baselines before models
A baseline is the simplest thing that could possibly work, measured on the same test set with the same metric. Build several, in increasing order of effort:
- Random or constant. Predicting at random tells you what "no skill" looks like.
- A rule a domain expert would write. "Call the customers with the most support tickets this month."
- A simple model, such as Logistic Regression, on a handful of obvious features.
- Only then, a more powerful model such as Gradient Boosting: XGBoost and LightGBM or a neural network.
Baselines tell you whether the problem is learnable, how much ML adds over common sense, and whether a complex model is worth its maintenance cost. Here is the ladder for a synthetic churn dataset (the code is below):
Notice two things. The rules nearly double the random baseline at almost no cost. And the fancier model, gradient boosting, did worse than logistic regression on this data. Without the ladder you would never know.
Stage 4: data
Most of the time in a real project goes into data: finding it, joining it, cleaning it (Data Cleaning and Preparation), labelling it, and checking that training data looks like what the model will see in production. Data Pipelines and Datasets covers this stage. Two rules carry most of the weight:
- Split by time when the future is what you predict. Train on January to June, test on July. A random split lets the model peek at the future (Training, Validation and Test Sets).
- Check that every feature exists at prediction time, computed the same way in training and in production. A mismatch between the two is called training–serving skew and is one of the most common silent bugs.
Stage 5: iterate with error analysis
Once a baseline works, improve it by looking at its mistakes, not by trying random algorithms. Take 50–100 wrong predictions, read them, and sort them into groups: "new customers with no history", "labels that are simply wrong", "customers on the old pricing plan". Count each group. The biggest group tells you what to do next: more data of that kind, a new feature, cleaner labels. Andrew Ng's courses call this error analysis, and it is the single highest-leverage habit in applied ML.
Keep a record of every attempt: which data, which code, which settings, which score. Experiment Tracking and Reproducibility is about doing that systematically.
Stage 6: deploy
Deployment means putting the model where its predictions are used: a nightly batch job that writes scores to a database, or a web service that answers within milliseconds (Deploying Models). Roll out carefully: run it in shadow mode (predicting but not acting) to compare it with the current system, then to a small share of users (a canary release), then to everyone.
Stage 7: monitor and loop
After launch, the world keeps moving. Customers change, products change, competitors change. The input data drifts away from the training data and the model quietly gets worse (Monitoring and Data Drift). Monitoring catches this. Its alerts send you back round the loop: new data, retraining, sometimes a new framing.
The practice of running this whole loop reliably — versioned data and code, automated training and testing, deployment and monitoring — is called MLOps (machine learning operations), by analogy with DevOps in software engineering.
Where the effort goes
A famous 2015 paper from Google, Hidden Technical Debt in Machine Learning Systems (Sculley et al.), drew real ML systems as a small box labelled "ML code" surrounded by much larger boxes: data collection, feature extraction, configuration, serving infrastructure, monitoring. Its point was that the model is a small fraction of the code, and that ML adds new kinds of technical debt — shortcuts that save time now and cost much more later. Examples include features nobody remembers adding, models that consume another model's output, and thresholds tuned by hand and never revisited.
In code
The baseline ladder from the picture, end to end. The data is synthetic so the example runs anywhere, but the workflow is the real one: define the business metric first, then climb from random to rules to models.
import numpy as np
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression
from sklearn.ensemble import HistGradientBoostingClassifier
# A made-up churn problem: 10,000 customers, about 1 in 10 leave.
rng = np.random.default_rng(0)
n = 10_000
tenure = rng.exponential(24, n) # months as a customer
tickets = rng.poisson(1.0, n) # support tickets last month
price = rng.normal(30, 8, n) # monthly bill
logit = -2.0 - 0.08 * tenure + 0.8 * tickets + 0.05 * (price - 30)
churn = rng.random(n) < 1 / (1 + np.exp(-logit))
X = np.column_stack([tenure, tickets, price])
X_tr, X_te, y_tr, y_te = train_test_split(X, churn, test_size=0.3,
random_state=0, stratify=churn)
# The business metric: the retention team can phone 10% of customers.
# What share of the customers who will leave do we reach?
def churners_reached(scores, budget=0.10):
k = int(len(scores) * budget)
top = np.argsort(-scores)[:k]
return y_te[top].sum() / y_te.sum()
print(f"churn rate {churn.mean():.3f} accuracy of 'nobody leaves' {1 - y_te.mean():.3f}")
print(f"0. random calls {churners_reached(rng.random(len(y_te))):.3f}")
noise = rng.random(len(y_te)) * 1e-3 # break ties at random
print(f"1. rule: most tickets {churners_reached(X_te[:, 1] + noise):.3f}")
print(f"2. rule: newest first {churners_reached(-X_te[:, 0]):.3f}")
lr = LogisticRegression().fit(X_tr, y_tr)
print(f"3. logistic regression {churners_reached(lr.predict_proba(X_te)[:, 1]):.3f}")
gb = HistGradientBoostingClassifier(random_state=0).fit(X_tr, y_tr)
print(f"4. gradient boosting {churners_reached(gb.predict_proba(X_te)[:, 1]):.3f}")
# churn rate 0.111 accuracy of 'nobody leaves' 0.889
# 0. random calls 0.135
# 1. rule: most tickets 0.231
# 2. rule: newest first 0.263
# 3. logistic regression 0.386
# 4. gradient boosting 0.335
The "nobody leaves" model scores 88.9% accuracy and reaches zero churners, which is why accuracy was the wrong metric. Calling 10% of customers can reach at most about 90% of the churners here (there are slightly more churners than calls), so 38.6% leaves plenty of room. The next step would be error analysis on the churners the model ranks low.
Common pitfalls
- Starting with the model. Weeks spent tuning a deep network before anyone has checked that the label means what you think, or that a rule is not already good enough.
- Optimising the wrong number. Accuracy on imbalanced data, offline AUC when the business only acts on the top 1%, or a metric nobody outside the team understands.
- Leakage. A feature that is a consequence of the target, or a random split on time-ordered data. The tell-tale sign is a test score that looks too good to be true. It usually is.
- No owner after launch. The model ships, the team moves on, and a year later nobody knows how it was trained or why it misbehaves.
- Comparing models on different test sets. Fix the test set early and change it only deliberately, recording the change.
- Ignoring who the errors fall on. A model can be accurate on average and systematically wrong for one group of users (Bias and Fairness). Slice your metrics by meaningful groups.
Watch out A model that is excellent offline can be useless or harmful in production if the data it sees there differs from the test set. Before you trust any offline number, check that each feature is available at prediction time and computed the same way as in training.
Where it leads
Each stage of the loop has its own chapter:
- Experiment Tracking and Reproducibility: recording runs so that results can be reproduced and compared.
- Data Pipelines and Datasets: collecting, labelling, validating and versioning data.
- Deploying Models: turning a trained model into a service or batch job.
- Monitoring and Data Drift: noticing when the world changes under the model.
For projects built on large language models the loop is the same, but "train a model" is often replaced by "write a prompt and pick a model", and evaluation becomes the hard part. See Building AI Products and Evaluating LLM Applications.
A bit of history
Data mining teams wrote down the lifecycle idea long before "MLOps" existed. CRISP-DM (Cross-Industry Standard Process for Data Mining), developed by a consortium of companies in the late 1990s, described six phases — business understanding, data understanding, data preparation, modelling, evaluation, deployment — arranged in a loop. It is still a fair summary.
As companies such as Google ran ML in production at scale, the hard-won lessons were published. Martin Zinkevich's Rules of Machine Learning collected Google's practical advice, and Sculley and colleagues' 2015 NeurIPS paper on hidden technical debt showed how much of an ML system is not the model. The word MLOps spread from about 2018, along with tools for tracking, pipelines and model serving. In 2021 Andrew Ng began promoting data-centric AI: hold the model fixed and improve the data, which is what most of the loop is about.
Try it
- Run the code, then change
budget=0.10to0.05and0.20. How does the gap between the best rule and logistic regression change?- Add a leaky feature:
cancel_calls = churn * rng.poisson(2, n)as a fourth column. Retrain. What happens to the score, and why would this model fail in production?- Write a one-paragraph framing (target, timing, action, error costs, metric) for a problem at your own work or in your daily life.
Hint for 2: the feature is only recorded after a customer decides to leave, so at prediction time it would always be zero.
Learn more
Hand-picked courses, books, videos and tutorials for going deeper. See all resources →
Rules of Machine Learning: Best Practices for ML Engineering
43 hard-won rules from building production ML at Google, with a long section on features, training–serving skew and when to add complexity.
Designing Machine Learning Systems
The practical guide to data, features, deployment, monitoring and iteration in production ML.
Made With ML
How to design, develop, deploy and iterate on ML systems in production.
Machine Learning in Production
Scoping, data definition, error analysis, deployment and concept drift, taught through the full lifecycle of a project.
Full Stack Deep Learning
Lectures on taking deep learning and LLM projects from idea to production.
Facts checked as of 30 November 2026. Fast-moving details (products, prices, laws) change often. · Source: content/entries/mlops/ml-project-lifecycle.md