The interview question

“How would you choose a validation strategy for this model?”

The split defines the question your evaluation answers. Predicting another random observation, a new customer, and next month's traffic are different generalization tasks. Choose the split before comparing algorithms.

01. Understand what K-fold estimates

K-fold cross-validation divides the data into K held-out folds. Each run fits the learning procedure on the other folds and evaluates on the held-out fold. Aggregate scores to compare procedures, keeping preprocessing inside each training run.

The fold scores are not independent measurements because training sets overlap. Their standard deviation is a useful stability diagnostic, but it is not automatically a valid confidence interval for future production performance.

scikit-learn's cross-validation guide describes splitters for different structures. No splitter can repair a future-derived feature or a mismatched target.

02. Match the split to the task

Deployment questionCandidate strategyRisk to check
New independent examples from a stable populationRandom or stratified foldsDuplicates and hidden dependence.
Previously unseen customersGroup split by customerGroups crossing train and validation.
Future eventsChronological holdout or rolling evaluationOverlapping label windows and future features.
New regions or organizationsHold out the relevant deployment groupToo few groups to estimate transfer reliably.

Suppose each patient has ten visits. A random visit split may test on patients already seen in training. That can be appropriate for some future-visit tasks, but it does not establish performance on new patients. State the target population explicitly.

03. Separate tuning from final assessment

Imagine comparing 50 model configurations on the same validation data. The winner benefits from both true performance and chance. Reporting its tuning score as an unbiased final result overstates the evidence.

Use a separate final holdout, or nested cross-validation when appropriate: inner folds choose settings, outer folds evaluate the selection procedure. This can be expensive, so match the rigor and computation budget to the decision.

Fit imputers, encoders, feature selectors, and resampling steps only on each training fold. Threshold and calibration selection also belong in the model-development process, not in the final test evaluation.

04. Design a temporal evaluation

For a monthly fraud model, fit on earlier mature transactions, validate on a later period, and test on a subsequent untouched period. Use an embargo or gap when label windows or features would otherwise overlap in a way that leaks information.

Rolling-origin evaluations reveal whether a result holds across several historical deployment dates. Keep label maturity and retraining cadence consistent with the intended production workflow.

After selecting settings, refit according to the chosen procedure and report what data was used. Refitting on more data does not justify secretly revising settings based on the final test results.

05. Answer the follow-up

“Does stratification solve class imbalance?”

It helps preserve class proportions across folds. It does not change the model, fix an inappropriate metric, or remove temporal dependence.

Self-review

Say what future population the score represents, what information was available, and which decisions were made before the final evaluation.

Sources & further reading

scikit-learn: cross-validation. Scenarios above are original examples.

Read next

Audit what crosses the split ↗

Check feature availability and preprocessing boundaries.

Continue your preparation

Choose a connected learning path or browse more ML fundamentals questions. Read our editorial method and attribution policy.