The Stages of a Machine Learning Project From Question to Monitoring
Walk through every stage of a machine learning project, what each one should produce and the checks that tell you whether to continue or go back.
Key takeaways
- Each stage should end with something concrete: a written question, a data description, a baseline score, an evaluated model or a monitoring plan.
- Set the success measure and the held-out test data before experimenting, so you cannot adjust them to suit the result.
- Build the simplest full pipeline early, then improve whichever part limits performance.
- Stopping a project that cannot meet its goal is a legitimate and valuable outcome.
- Deployment starts a new phase in which data, behavior and the world keep changing.
A machine learning project moves through framing the question, gathering data, building a baseline, training and evaluating models, analyzing errors, deploying and then monitoring. Training is one stage among many, and often not the longest. Much of the work is deciding what to predict and making sure the data can be trusted.
The stages are a loop more than a line. What you learn from errors sends you back to the data, and what you learn in production sends you back to the question.
The loop at a glance
| Stage | Main output | Question to pass |
|---|---|---|
| Framing | One-page problem statement | Will a prediction change a decision? |
| Data | Described, versioned dataset and splits | Can we get these inputs at prediction time? |
| Baseline | End-to-end score | Does the pipeline run and make sense? |
| Modeling | Candidate model and experiment log | Does it beat the baseline by enough? |
| Evaluation | Test report with slices | Is it safe and useful enough to release? |
| Deployment | Running service or batch job | Can we roll it back? |
| Monitoring | Alerts and an owner | Who acts when something changes? |
Framing the question
Start with the decision. Who will act, on what, and when? Define the target precisely, including the time window, and name what is known at the moment of prediction. Choose a metric that reflects the cost of different mistakes.
Then ask whether you need machine learning at all. A rule or a dashboard may serve. Consider who could be harmed by wrong outputs, whether you may lawfully use the data, and what a person can do to contest a result. The method for this stage is covered in turning a question into a learning problem.
Getting and understanding data
Find where each field comes from, who maintains it and when it is written. Look at raw rows. Count missing values, duplicates and impossible entries. Check that labels mean what you think they mean, since a field named "closed" may cover several very different events.
Split off a test set now, before you grow attached to any idea. Split by time if you will predict the future, and keep related records, such as all rows for one customer, on the same side. An exploratory checklist helps you look systematically.
This stage frequently overturns the plan. You may discover that the label was only recorded for a subset of cases, or that a key input arrives a week late.
A baseline and a thin pipeline
Next, connect everything end to end with the least effort that works: load data, apply minimal preprocessing, fit a trivial predictor and a simple model, compute the metric, and produce an output in the form the user needs.
This thin pipeline surfaces integration problems early, and gives a score that later work has to beat. Put it under version control. Record the data snapshot, code version, settings and result of every run, as described in experiment tracking. A spreadsheet is acceptable if you actually keep it.
Modeling and experiments
Now improve. Change one thing at a time and write down what you expected before running it. Better data and features often give more than a fancier algorithm, though that depends on the problem.
Use validation data or cross-validation to compare options. Fit every preprocessing step, such as scaling or imputation, on training folds only. After a round of experiments, read the mistakes. Error analysis tells you which improvement has the most room to pay off, and a learning curve tells you whether more data is likely to help.
Set a time box. If a month of reasonable effort leaves you far from the target, report that and the likely reasons.
Gates that let you stop early
Each arrow in the loop is also a chance to stop. Deciding in advance what would end the project makes that conversation far easier than discovering sunk cost months later.
After framing, stop if nobody can say what they would do differently with a prediction. After data inspection, stop or redesign if the target cannot be observed, if essential inputs are unavailable at prediction time or if you lack the right to use them. After the baseline, stop if a simple rule already meets the need. After modeling, stop if the gain over that rule does not cover the cost of running a model. After evaluation, hold the release if an important group is served badly, even when the average looks fine.
A stopped project still produces value when you record why. A short note stating that the label was unreliable, with examples, may prompt the logging change that makes the project possible next year. Without the note, someone is likely to start again from the same assumptions and hit the same wall.
Final evaluation and sign-off
When you have chosen a model, score it once on the test set. Report the metric with an uncertainty estimate, the baseline beside it, and results for the slices that matter, such as regions or device types.
Test behavior as well as averages. What happens with missing fields, extreme values or an unseen category? How long does a prediction take, and how much memory does it need? Document intended use, known weaknesses and the data used.
For consequential areas such as health, hiring or lending, a good test score is only the beginning. Domain experts, legal review and further validation are needed, and rules differ by jurisdiction.
Deployment
Decide how predictions reach users: a nightly batch table, a real-time service or a model embedded in a device. Make sure preprocessing in production matches training exactly, ideally by shipping them together as one artifact. Be careful with serialized Python objects: loading an untrusted pickle file can run arbitrary code.
Release gradually. In a shadow deployment the new model predicts alongside the old system without affecting anything. In a canary release it handles a small share of real traffic. Both are discussed in shadow and canary releases. Keep a way to return to the previous version quickly.
Monitoring and maintenance
Once live, watch four layers: whether the service is up and fast, whether inputs look like training inputs, whether outputs have shifted, and whether predictions prove right once outcomes arrive. The last is the most informative and usually the slowest.
Each alert needs an owner and an agreed response. Decide when you will retrain, how a retrained model gets approved and when the system should be retired. A model can also change the data it later learns from, for example when blocked transactions never reveal whether they were fraudulent. Monitoring after launch goes further.
Going back is normal
Expect to revisit earlier stages. Some typical return paths:
- Errors cluster around mislabeled rows: return to data.
- A feature turns out to be unavailable in production: return to framing and features.
- Offline scores are good but users ignore the output: return to the decision and the interface.
- Live inputs drift away from training data: return to collection and retraining.
None of these means the team failed. Skipping the return, and shipping anyway, is the expensive choice.
Who does what, and how long
Small teams combine roles; larger ones split them among domain experts, data engineers, modelers, software engineers and the people who use the output. Whatever the arrangement, involve the users from framing onward. They know which errors hurt and which fields are unreliable.
Time estimates vary too widely to give a rule. Plan in short stages with a decision at the end of each: continue, change direction or stop. Share a plain written update at each gate, including what you tried that did not work. That record saves the next person, possibly you, from repeating it.
Habits that apply at every stage
A few practices pay off throughout. Keep data, code and configuration versioned together, so any reported number can be regenerated. Write tests for data assumptions, such as allowed ranges and required columns, and let them fail loudly. Fix random seeds while debugging, then vary them to see how much results depend on chance.
Protect people's information from the start. Collect only the fields you need, limit who can read them, set a retention period and remove direct identifiers from experiment files where you can. Retrofitting these controls after copies have spread across laptops and notebooks is painful.
Finally, keep a running decision log: the date, the choice, the alternatives and the reason. Memories of why a filter was added or a segment excluded fade within weeks. The log also gives reviewers and newcomers a fast route into the project, and it exposes choices that were made for convenience and later hardened into assumptions nobody remembers testing.
A short walk-through
Imagine a hypothetical library that wants to remind people before books become overdue. Framing yields a target: will this loan be returned late, predicted three days before the due date. Data inspection shows that renewals overwrite the original due date, so history must be rebuilt from the event log.
The baseline is "remind anyone who returned late last time." A linear model beats it modestly. Error analysis shows first-time borrowers are handled poorly, since they have no history, so the team adds a simple fallback for them. The model runs as a nightly batch, first in shadow mode. Monitoring tracks late returns among reminded and a small unreminded group, where policy allows, because reminders themselves change the outcome the model predicts.