Math · Machine learning · Dataset splits
Train test split calculator.
Turn split percentages into exact sample counts for training, validation and test sets, rounded the way scikit-learn's train_test_split rounds.
A 1,000-sample dataset split 70 / 15 / 15 gives 700 training, 150 validation and 150 test samples. An 80 / 20 split of 5,001 samples gives 4,000 train and 1,001 test, because the test size is rounded up.
Inputs
Your result
Fill the form and press Calculate.
The rounding rule
In scikit-learn's train_test_split, a float test_size is the proportion of the dataset in the test split. In its source (_validate_shuffle_split) the test count is ceil(test_size × n_samples), a float train_size uses floor, and when only test_size is given the training set is n_samples − n_test. This page follows that: test = ceil(test% × n), validation is rounded up the same way, and training is whatever remains, so the three always add to n. Products within a billionth of a whole number are treated as exact, to avoid floating-point noise pushing 7% of 100 up to 8.
Worked example
Documented by scikit-learn: 5 samples with test_size = 0.33 gives 2 test and 3 train samples (ceil(1.65) = 2). With 1,000 samples at 15% test and 15% validation: ceil(150) = 150 test, 150 validation, 700 training. With 5,001 samples at 20% test: ceil(1,000.2) = 1,001 test and 4,000 training.
Three-way splits and caveats
scikit-learn has no single three-way function; the common approach is to call train_test_split twice. The validation count here is defined as a percentage of the whole dataset, which is this calculator's convention, not a scikit-learn rule. Stratified or grouped splits can shift counts slightly because each class must be divided. Small datasets are better served by cross-validation than by one holdout. The right percentages depend on your data size and how precise your estimate must be, so treat 80/20 or 70/15/15 as starting points, not rules.
Sources, opened 15 October 2026: scikit-learn train_test_split; scikit-learn source, sklearn/model_selection/_split.py (_validate_shuffle_split).
Frequently asked questions
How do I calculate train and test sizes?
Multiply the dataset size by the test share and round up to get the test count, then subtract it from the total for the training count. For 1,000 samples and a 20% test share that is 200 and 800.
Why does the test set round up?
scikit-learn's train_test_split uses ceil for a float test_size and puts the remainder in training, so a 33% test share of 5 samples gives 2 test and 3 train.
What is a good train/validation/test split?
There is no universal answer. 80/20 and 70/15/15 are common starting points. Larger datasets can afford a smaller test percentage; very small datasets usually need cross-validation.
Do the validation and test shares add to the whole dataset?
Yes. On this page both shares are percentages of the full dataset, and training gets the rest.
Does this handle stratified splits?
No. It computes overall counts. Stratification divides each class separately, so per-class counts and the totals can differ by a sample or two.
Learning and planning aid
Results are computed in your browser from the numbers you enter and the formulas described above. Check them against your own evaluation code before relying on them in a paper or a production decision.