Beginner Topic 6 of 51 AI & Machine Learning
Training and Test Sets
Separating data used to learn from data used to evaluate.
How it works
To estimate how a model will perform on new data, the dataset is split into a training set used to fit parameters, often a validation set used to tune hyperparameters and choose models and a test set held out until the end for an unbiased final estimate. Typical splits are 70/15/15 or 80/10/10, with stratification to keep class proportions and time-based splits for temporal data. The test set must never influence training or tuning decisions.
Step-by-step walkthrough
- Split the data before training.
- Fit the model on the training set.
- Tune settings on the validation set.
- Evaluate once on the untouched test set.
- This estimates how it will perform on new data, and test leakage gives falsely good scores.
Where it is used
Every machine-learning project uses splits to detect overfitting and to compare models honestly. Competitions use hidden test sets to maintain integrity.
Common pitfall
Data leakage, where information from the test set sneaks into training through preprocessing fitted on all data, duplicates across splits or future information, gives overly optimistic results. Repeatedly tuning on the test set turns it into a validation set. Random splits fail for grouped or time-series data. Fit scalers and encoders on training data only and keep the test set untouched.
Where it fits in the course
Training and Test Sets is topic 6 of 51 in AI & Machine Learning, rated Beginner. It follows Reinforcement Learning Basics. The next topic is Features and Labels.
Practice and explore
- Open the interactive lesson, with a mini quiz.
- Take the AI & Machine Learning quiz.
How to study this topic
- Read the explanation above and restate the definition in your own words.
- Open the interactive lesson and answer its mini quiz.
- Read the common pitfall, then write a short example that avoids it.
- Check your understanding in the AI & Machine Learning quiz, and revisit the topic if you miss a question.
Frequently asked questions
What is Training and Test Sets?
Where do people use Training and Test Sets?
What is the most common mistake with Training and Test Sets?
What should I learn before this topic?
How can I practice it?
Is Training and Test Sets hard to learn?
How long does it take to learn Training and Test Sets?
Which topics are related to Training and Test Sets?
What should I study after Training and Test Sets?
Related topics
- Reinforcement Learning Basics (AI & Machine Learning)
- Features and Labels (AI & Machine Learning)
- Unsupervised Learning (AI & Machine Learning)
- Linear Regression (AI & Machine Learning)
- Sets and Set Operations (Theory & Discrete Math)
- Test-Driven Development (Software Engineering)
- Sets (Programming Fundamentals)