PPristone AcademyDiagnose · Build · Transfer

Related service: Machine Learning Tutoring

Machine learning projects

Machine Learning Project Roadmap: 8 Leakage-Safe Steps

A useful ML project is not a notebook with the highest score. It is a chain of evidence showing that the target is meaningful, the evaluation is honest, and the result can survive new data.

Written and reviewed by Edward Mabonga15 minute read
At a glance

The eight-stage machine learning project workflow.

The stages are sequential enough to protect evaluation, but the work is still iterative. An error pattern can send you back to the label definition; a deployment constraint can change the features; a weak baseline can show that the project does not yet need a complex model.

At every stage, produce a small artifact that another person can inspect. That evidence makes the project reproducible and prevents a polished notebook from hiding an invalid assumption.

Eight stages and the evidence each should produce
StagePrimary questionConcrete output
1. FrameWhat decision will the prediction inform?Target, prediction unit, observation time, and success criterion
2. Audit dataCan the available data support that promise?Source, access, label-quality, privacy, and missingness notes
3. SplitHow will genuinely new data arrive?Random, grouped, or time-aware split rule fixed in advance
4. ExploreWhat does training data reveal about quality and structure?Training-only EDA with distributions, missing values, outliers, and label checks
5. BaselineDoes learning beat a simple alternative?Rule or dummy model measured with the primary metric
6. PipelineCan preprocessing and training be repeated safely?Versioned transformations, model, validation, and experiment record
7. EvaluateWill the result support the real decision?Final test result, threshold, slice analysis, uncertainty, and limitations
8. DeliverWhat must remain true after launch?Inference contract, monitoring signals, fallback, and retraining trigger
Before the model

Define the decision, prediction unit, and observation time.

Begin with the action a prediction would inform. Then define one row of data, the target attached to that row, when the features become available, and when the label becomes knowable. This turns a broad goal into a testable prediction contract.

The timing questions matter. A feature created after the prediction moment may look powerful in a notebook while being unavailable in real use. Write the prediction moment explicitly before exploring correlations.

  • Decision: what action could change because of the output?
  • Unit: what does one prediction represent?
  • Features: what is genuinely known at prediction time?
  • Label: how and when is the outcome observed?
Data audit and EDA

Inspect the data without teaching yourself the test set.

Document where the data came from, whether it can be used for the intended purpose, how labels were created, what one row represents, and which populations or time periods are missing. Check duplicates, missingness, impossible values, class balance, and label consistency before interpreting model performance.

After reserving the holdout, conduct exploratory analysis on the training portion. Use that exploration to propose transformations and features, then place learned preprocessing inside the validation pipeline. Repeatedly examining the final test set turns it into another validation set and weakens the final claim.

  • Record provenance, permissions, collection window, and prediction population.
  • Check whether duplicate or related observations cross a proposed split.
  • Inspect missingness and label quality—not just feature distributions.
  • Keep the final holdout unavailable during feature and model decisions.
Baseline

Prove that learning adds value before optimizing it.

A baseline gives the project a floor. For classification it might be the majority class or a simple rule; for regression it might be a mean, median, or existing operational estimate. The baseline should be evaluated with the same split and metric as the candidate model.

Without a baseline, a complicated model can appear impressive while failing to improve the decision. Keep the first comparison deliberately simple and record what additional complexity buys.

Split first

Design the split around how new data will arrive.

A random split is not automatically appropriate. Time-dependent problems often need past-to-future evaluation. Repeated observations from the same person, device, account, or site may need group-aware splitting so closely related rows do not appear on both sides.

Reserve final test data before model selection. Use training data to fit model parameters and preprocessing; use validation or cross-validation to compare choices; use the untouched test set once for the final estimate. The split is part of the problem definition, not housekeeping at the end.

Pipeline

Fit every learned transformation on training data only.

Imputation, scaling, feature selection, dimensionality reduction, and encoding can all learn from data. If they are fit before the split or on the full data set, the held-out set has already influenced the model-building process.

A pipeline keeps preprocessing and estimation together so each cross-validation fold learns its transformations from that fold's training portion. This is one of the most practical defenses against accidental leakage and inconsistent preprocessing.

  • Split before fitting preprocessing statistics.
  • Fit and transform training data; only transform held-out data.
  • Keep feature selection inside the validation pipeline.
  • Version code, dependencies, data definitions, and random seeds.
Evaluate

Choose the metric and threshold from the decision cost.

Accuracy is useful only when its errors reflect the real problem. If missing a positive case is much more costly than reviewing a false alarm, recall may deserve more weight. If false alerts overwhelm a limited team, precision and workload at a chosen threshold matter.

For regression, MAE communicates a typical absolute error while RMSE gives larger errors more influence. Do not choose a metric because it is conventional; state which failure it penalizes and why that failure matters.

Error analysis

Inspect where the model fails, not only its average score.

Review false positives, false negatives, and large regression errors. Look for label problems, missing context, unstable features, and meaningful slices where performance differs. A single average can hide a model that works well for common cases and poorly for the cases that carry the most risk.

Turn each pattern into a testable next step: repair a label rule, remove a future-looking feature, collect a missing variable, change the threshold, or accept that the data cannot support the original promise.

Delivery

Write the inference contract before calling the project complete.

Document required inputs, preprocessing, output meaning, threshold, expected latency, dependency versions, and fallback behavior. The production path must perform the same transformations as evaluation.

Plan monitoring around both system health and model behavior: missing or shifted inputs, score distribution, latency, failures, and delayed outcome quality when labels become available. Deployment changes the evidence you need; it does not end the experiment.

What to carry into your next experiment

  • Define the prediction moment before selecting features.
  • Split before learning any transformation from the data.
  • Treat evaluation and deployment as part of the model, not afterthoughts.

Frequently asked questions

Data leakage occurs when information that would not be available at prediction time influences model training or selection. It can make validation results look stronger than performance on genuinely new data.
Define deterministic cleaning rules as needed, but any transformation that learns values from the data—such as scaling, imputation, feature selection, or PCA—should be fit on training data only, ideally inside a pipeline.
Use validation data or cross-validation for model and hyperparameter choices. Keep the test set untouched until the workflow is fixed, then use it for the final performance estimate.

Official technical references

Workflow and evaluation guidance was checked against current first-party Google and scikit-learn documentation on August 13, 2026.

Machine learning diagnostic

Find the first weak link in your ML workflow.

A paid diagnostic reviews the problem definition, data, pipeline, evaluation, error analysis, and explanation before recommending a pathway.

Book an ML diagnostic