The Machine Learning Workflow
ML projects fail less from bad algorithms than from broken workflow: leaking the test set, tuning on the wrong metric, or shipping a model that nobody can retrain. The workflow below is the standard sequence, and it is also the sequence of this tutorial. Memorize the order; almost every bug in a real project is a step skipped or run in the wrong place.
The Sequence
1. Problem definition - what decision does this model feed? what is the label?
2. Data acquisition - collect or connect the data; document its source
3. Exploration (EDA) - distributions, missingness, outliers, relationships
4. Cleaning - fix types, missing values, duplicates, units
5. Feature engineering - encode categoricals, scale, build derived features
6. Split - train / validation / test, stratified, done ONCE
7. Model selection - baseline first (logistic regression / simple tree)
8. Train + validate - fit on train, score on validation
9. Tune - hyperparameters on train+validation via CV
10. Final evaluation - score the tuned model on the untouched test set
11. Ship + monitor - deploy, track drift, retrain on a schedule
The shape that matters: everything between steps 5 and 9 can loop as much as you like - that iteration is the job. Step 6 happens once, before any modeling, and step 10 happens once, after all tuning stops. Violating either rule corrupts the final number.
The Three Sets
- Train: the data the model learns from.
- Validation: the data used to choose among models and hyperparameters during development. It is peeked at repeatedly, so it is only "semi-honest."
- Test: the data that measures final performance. Touched once, at the end. If you tune until the test score is good, the test set has quietly become a validation set.
With small data, cross-validation plays the validation role (every sample serves as validation in turn), and a held-out test set is still reserved for the final number if you can spare it.
Artifacts at Each Step
| Step | Artifact to keep |
|---|---|
| Problem definition | a one-paragraph spec: input, output, metric, cost of error |
| EDA / cleaning | the notebook or script that reproduces the clean dataset |
| Features | the transformation code, not just the columns |
| Model choice | baseline score + tuned score + the test-set score, all recorded |
| Ship | the serialized model + the pipeline that made it + the data version |
The artifacts are the difference between a result and a system. A score in a notebook is a moment; a model plus its pipeline plus its data version is something a second engineer can rebuild, and something monitoring can compare future data against.
Where Workflows Break
- Leakage: a feature that could not exist at prediction time (the outcome itself, a post-event timestamp) inflates every score.
- Scaling on the wrong data: fitting the scaler on train+test leaks test statistics into training.
- Metric mismatch: optimizing accuracy on imbalanced data while the business cares about recall.
- Retraining without a plan: the model decays when the data drifts, and nobody notices until the metric does.
Summary
Run the project in the fixed order: define, acquire, explore, clean, engineer, split once, baseline, tune on validation, evaluate on test once, ship with monitoring. Keep an artifact at every step, treat the test set as a single exam, and remember that the iteration loop between modeling and validation is where the actual work happens - the workflow exists to keep that loop honest.