Trusting the result / 5 of 7
Training, validation, and test sets
What you’ll learn
- Explain the main idea of “Training, validation, and test sets” in your own words.
- Trace a concrete example and identify the assumptions behind it.
- Apply the principle in a practice problem and recognize a common failure.
The idea, intuitively
Training fits parameters. Validation supports choices such as model size and learning rate. The test set estimates final performance after those decisions. Repeatedly checking the test set turns it into part of development.
Think of the dataset as a sample from a larger environment. A useful model must transfer beyond that sample. Keep training choices separate from final evaluation, and compare against a simple baseline. Before selecting an algorithm, inspect what the labels mean and which errors matter to the user.
Under the hood
Split before fitting preprocessing. Fit scalers and imputers only on training data. Use grouped or temporal splits when examples share users, documents, or time dependence; a random split can leak near-duplicates.
Data leakage can occur through preprocessing even when labels are not directly copied.
A worked example
For forecasting, train on older dates and evaluate on later dates. Randomly mixing future records into training overstates deployment quality.
How to use this way of thinking
Define the target, split the data, fit preprocessing only on training examples, and evaluate a baseline. Inspect individual failures alongside aggregate metrics. Change one major choice at a time and use validation evidence to decide whether the additional complexity earns its place.
Try it yourself
Two rows are different photos of the same patient. How should they be split?
Key takeaways
- Only the training split
- Data leakage can occur through preprocessing even when labels are not directly copied.
- Check the assumptions with a small example before applying this idea to a larger system.
Check your understanding
Use feedback to learn. Quiz scores and lesson completion are tracked separately.
Go to lesson completionFurther reading
Original papers and reference material for this school. External resources may be in English and require internet access.
Google Machine Learning Crash Course (opens a new tab)scikit-learn user guide (opens a new tab)Finish this lesson
Mark this lesson complete when you’re ready to continue.