How should data be split for machine learning?
Data should be split in a way that lets the model learn from one portion while being evaluated on separate, representative examples.
There is no single split ratio that is correct for every machine learning problem. The right approach depends on dataset size, class balance, time structure, grouping, and how the model will be used.
A common starting point
For many datasets, a reasonable starting point is:
- Training data: about 70–80%
- Validation data: about 10–15%
- Test data: about 10–15%
For example:
70% training
15% validation
15% testThese percentages are guidelines, not rules. Large datasets may need a smaller percentage for validation and testing because even a small fraction can still contain many examples.
Keep the roles separate
- Training set: used to fit the model.
- Validation set: used to compare and tune model-development choices.
- Test set: kept untouched until the final evaluation.
Make the splits representative
Each split should reflect the kind of data the model will encounter in practice.
For ordinary independent observations, random splitting is often suitable.
If the target classes are imbalanced, stratified splitting can help preserve similar class proportions across the splits.
If multiple rows belong to the same person, device, account, or other group, related rows should often stay in the same split so nearly identical information does not appear in both training and evaluation data.
For time-dependent data, the split should usually follow time order rather than randomly mixing past and future records.
Prevent leakage
Any preprocessing step that learns information from the data should be fitted using the training data only.
For example, values used for imputation, scaling, feature selection, or other learned transformations should not be calculated using the test set.
Choose the split based on the real prediction scenario
The most important principle is that validation and test data should realistically simulate the unseen data the model will receive after deployment.
In short, split data into separate training, validation, and test portions while preserving the structure of the real problem and preventing information from evaluation data from leaking into training.
Learning Sequence
Machine Learning Curriculum
Explore Related Questions
Deepen your understanding across related Machine Learning topics.