- Published on
- 2 min read
Evaluate an ML model with the data it would really see
- Authors
- Name
- Ritenta
A course team predicts next week's enrolment so it can schedule tutors. Its first model scores well on a random holdout, but early-term forecasts miss repeatedly. Before changing the model, reproduce the conditions of a real forecast. The team must decide on Friday afternoon, using only information it has at that time.
Reconstruct the prediction boundary
Use a timestamp for the decision and another for feature availability. A row labeled Friday might contain a field computed on Sunday. A retrospective warehouse query can expose the value even when the live service could never have known it. For each feature, record when it was available and join the latest eligible value before the cutoff. For weekly aggregates, check whether the aggregation window includes the target week.
Evaluate on later weeks after training on earlier ones. Fit transformations on the training slice of each fold. A scaler trained once on the full dataset can carry information about future values even though it never sees labels. Put learned preprocessing and the estimator in one pipeline and refit them in each fold. Choose a gap when feature windows or label availability make adjacent slices overlap. scikit-learn on data leakage · TimeSeriesSplit
Match the metric to the decision
Suppose teams review 30 forecast alerts each week. Evaluate precision among the alerts they can actually review and recall among all capacity incidents identified after the fact. With 18 true positives in 30 alerts and 45 real incidents, alert precision is 60% and incident recall is 40%. Raising a threshold often changes both the size and the mix of the reviewed queue. Record counts by workload and compare against a simple baseline.
For actual enrolment estimates, report the size and direction of forecast errors, and review errors for small and large courses separately. A single aggregate can hide consistent underprediction on the courses that are hardest to staff. Define slices before comparing models and report their sample counts. scikit-learn model evaluation
Keep a decision record
Record training cutoff, data and feature versions, the next untouched evaluation window, baseline, metric definitions and the intended action. Test a few problematic rows end to end with the feature service. Carry the same habit into vision and audio: keep related samples together when their shared source could leak information across evaluation boundaries.
This lesson follows the ML foundations phase of AI Engineering from Scratch. The forecasting scenario and figures are illustrative.
Practise what you read
Answer questions based on this article in Ritenta.
Open practice