November 3, 2026 · krey

Machine Learning Model Evaluation Without Data Leakage

Model evaluation is the part of a machine learning project where attractive results are most easily made misleading. A trustworthy evaluation imitates how the model will receive unseen data and keeps information from the future out of training.

Define the decision and metric

Start with what a prediction will be used for. Accuracy may be unsuitable when one class is rare. Precision matters when false positives are expensive; recall matters when missing a positive case is costly. For regression, compare error metrics with the scale and consequences of the target.

Split before fitting

Separate training and evaluation data before learning imputation values, scaling parameters, encodings or feature-selection rules. If the transformation sees the full dataset first, information from the evaluation set has leaked into training. Use a pipeline to keep preprocessing and model fitting together.

Use a baseline

A baseline gives context. Predicting the majority class, the previous value, or a simple average may be surprisingly strong. A complex model should beat a reasonable baseline consistently, not just once on a convenient split.

Inspect errors, not only scores

Look at false positives, false negatives, residuals and performance across meaningful subgroups. Investigate whether a high score is caused by an identifier, a post-outcome field, duplicate records or a time-dependent feature that would not exist at prediction time.

Document uncertainty and limits

Cross-validation can estimate variability across folds, but it does not fix a biased dataset or an invalid target. Record the split strategy, random seed where relevant, metric definitions, threshold choice and known limitations. Evaluation is part of the product, not an afterthought.

References

Define the prediction moment

Leakage is easier to detect when you write down exactly when a prediction would be made and what information would be available at that instant. Any feature created after that moment is unavailable, even if it is present in the historical table. Examples include a later payment status, a post-outcome support label, or an aggregate calculated using future records.

Separate preparation from evaluation

Fit imputers, encoders, scalers and feature selectors only on the training data. Use a pipeline so the same order is applied during validation and inference. For grouped or repeated observations, use a group-aware split. For time-dependent questions, use chronological validation rather than a random split that lets the future influence the past.

Inspect errors, not only metrics

Choose a threshold based on the action that follows a prediction. Review false positives and false negatives by meaningful segment, data quality flag and confidence range. A model with a strong average score can still be unusable for a group that has too few examples or a different error cost. Record these findings in the evaluation report.

Keep a final test set sacred

Use validation results to choose the workflow, features and threshold. Evaluate the final locked workflow once on the held-out test set. If you repeatedly inspect and tune against that result, it is no longer an unbiased estimate. Document the experiment history so future improvements can be compared fairly.