Machine Learning Fundamentals interview question · Most asked

How do you split data for training, validation and testing, and what is cross-validation?

How you'd do it Asked in Machine Learning Engineer interviews

Members can save this page, take notes and track progress. See membership · Sign in

Summary

Train on one part, tune choices on a validation part, and report final performance once on a held-out test part. k-fold cross-validation rotates the validation fold through the training data so every row is used for both training and validation, giving a more stable estimate on small datasets.

Longer Answer

  • Typical splits: 70/15/15 or 80/10/10; with lots of data, the validation and test sets can be smaller in percentage.
  • Stratify classification splits so class proportions match.
  • Time series: split by time (train on the past, validate on the future), never randomly; TimeSeriesSplit or walk-forward validation.
  • Groups: keep all rows from one user, patient or session in the same split (GroupKFold) to avoid leakage.
  • Fit preprocessing (scalers, encoders, imputers) on the training fold only, ideally inside a pipeline.

Key Points

  • Train, tune on validation, report once on test.
  • k-fold for stable estimates on small data.
  • Stratify classes; split time series by time; group related rows.
  • Fit preprocessing only on training data.

Explanation

What interviewers look for

Knowing when random splits are wrong (time, groups) and how preprocessing leaks.

More Machine Learning Fundamentals questions

← All Machine Learning Fundamentals questions

Last reviewed · By the ByteCamel team · How we write content

Was this page helpful?

Report a mistake