Locked evaluation and uncertainty
Quick answer
Locked evaluation measures a selected model on data not used to fit or choose it. Record the split IDs, metric, candidate set and decision rule before inspecting the holdout. Objective: Calculate held-out MAE and paired uncertainty without reopening model selection. Examples are local, synthetic and not verified in ByteMind.
Calculate paired improvements
actual=[10,20,30]baseline=[15,15,15]model=[11,18,31]print([abs(y-b)-abs(y-p) for y,b,p in zip(actual,baseline,model)])Expected output (locally tested): [4, 3, 14]. Positive differences favor the candidate.
How it works
The chronological order is training 0–159, validation 160–219, final stable test 220–279 and drift replay 280–319. Each target is available before the next row decision; real overlapping horizons may require a purge gap. MAE has target units: e_i=|y_i-p_i| and mean(e_i). For comparing two models on identical rows, calculate paired improvement d_i=|y_i-b_i|-|y_i-p_i|; positive means the candidate improves absolute error. Resample whole pairs with replacement, compute the mean for each resample, and take 2.5th and 97.5th percentiles for an approximate 95% percentile bootstrap interval. The capstone uses 2,000 resamples of the 60 independent synthetic stable rows and seed 6101. This describes conditional sampling variability for fixed fitted models under the fixture assumptions; it omits training variability and cannot guarantee future coverage. Real dependent time series need suitable block or group resampling and a justified dependence model. Nested evaluation is an alternative: tune inside each outer training fold, never on its outer holdout. Temporal folds must honor availability. Inspect large errors after evaluation for a report, not to silently re-tune the same test.
Enforce a temporal gap
train_label_times=[1,4,7]first_validation_decision=9print(max(train_label_times)<first_validation_decision)Expected output (locally tested): True. The latest training label precedes the validation decision.
Common mistakes
Do not report a confidence interval for the mean as a prediction interval for individual rows. Do not resample baseline and candidate errors separately when the observations are paired. Do not claim a locked test is still independent after repeated tuning.
Practice and next steps
Calculate paired differences by hand for three rows. Record the largest absolute errors and a plausible explanation as a hypothesis, then propose a new test without changing the existing result.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Locked evaluation and uncertainty — knowledge check
Apply locked evaluation and uncertainty to scenarios and small examples.
What makes the final stable test locked?
A positive paired improvement means what?
What does the bootstrap interval estimate here?
How should dependent time-series rows be resampled?
What happens if test results drive another tuning round?