Train/Test Split Calculator
Compute train, val, and test set sizes from ratios.
About this tool
Enter the number of samples and the test and validation ratios, and get the size of each split. It only calculates sizes. To split an actual CSV file, use the train-test split tool.
How to use
How it works
Test = round(n × test ratio) and validation = round(n × val ratio). Train is the rest. The two ratios must add up to less than 1. The result shows counts and percentages in the order train / val / test.
test = round(n·r_test); val = round(n·r_val); train = n − test − val
Worked example
10,000 samples
- Input
- n = 10,000; test ratio 0.2; validation ratio 0.1
- Output
- 7000 / 1000 / 2000 (train / val / test)
- Walkthrough
- 2,000 go to test, 1,000 to validation, and the remaining 7,000 are for training. With a validation ratio of 0 and n = 1,000 you get 800 / 0 / 200.
Limitations
- Sizes only; it does not shuffle or split data.
- No stratification advice for imbalanced classes.
- Rounding can make the sizes differ slightly from the exact ratios on small datasets.
Questions
What is a good train/validation/test split?
How do I split an actual dataset?
Do I need a validation set?
Why do my sizes not add up exactly to the ratios?
Features
- Train, val, test sizes
- Percentages shown
- Runs in your browser
Related resources
Guides and videos from around the web—opens on YouTube or the publisher’s site.
Mean, Variance and Standard Deviation
StatQuest with Josh Starmer
Stats foundations behind many ML metrics tools.
Watch on YouTubeTensorFlow 2.0 Complete Course
freeCodeCamp.org
Practical ML stack context next to AI utilities.
Watch on YouTube
- DeepLearning.AI
DeepLearning.AI
Courses and explainers for modern AI tooling.
- Data Index
Math is Fun
Stats primers when reading ML evaluation outputs.