Train/test split calculator

Enter the number of samples and the shares for test and validation. The calculator gives the exact sizes — rounded the way scikit-learn rounds them — the fold sizes for k-fold cross-validation on the non-test data, and how many batches one epoch takes.

%
%
Training samples700
Validation samples100
Test samples200
Samples for cross-validation (all but test)
800
Larger fold size
160
Smaller fold size
160
Folds of the larger size
0
Training samples per round, at least
640
Training samples per round, at most
640
Batches per epoch
22
Samples in the last batch
28

Runs in your browser: nothing you enter is sent anywhere.

How to use it

  1. Enter the number of samples.
  2. Enter the test and validation shares in percent (0 for no validation set).
  3. Enter the number of folds and the batch size.
  4. Read the set sizes, the fold sizes and the batches per epoch.

Formulas

  • Test = ⌈N × test share⌉, validation = ⌈N × validation share⌉, training = N − test − validation
  • Cross-validation pool P = N − test
  • Fold sizes ⌊P ÷ k⌋ and ⌈P ÷ k⌉; P mod k folds have the larger size
  • Training per round = P − fold size
  • Batches per epoch = ⌈training ÷ batch size⌉; the last batch holds the remainder

Worked example

1000 samples, 20 % test, 10 % validation, 5 folds, batch size 32:

  • test 200, validation 100, training 700;
  • cross-validation pool: 1000 − 200 = 800, so each of the 5 folds has 160 samples and each round trains on 640;
  • 700 ÷ 32 = 21.875, so an epoch takes 22 batches and the last one holds 700 − 21 × 32 = 28 samples.

Tips

  • Shuffle before splitting, and for classification use a stratified split so every set keeps the class proportions.
  • Split by group when samples are related — several rows per patient or user — or the test score will be too optimistic.
  • If the last batch is tiny, consider drop_last or a batch size that divides the training set more evenly.

Frequently asked questions

How are the split sizes rounded?

Like scikit-learn's train_test_split: the test set gets the share rounded up, n_test = ⌈N × test share⌉, and the training set gets the rest. The validation set is rounded up the same way. With 1234 samples and 25 % test, that is ⌈308.5⌉ = 309 test and 925 training samples.

How big is each fold in k-fold cross-validation?

P samples split into k folds give folds of ⌊P ÷ k⌋ or ⌈P ÷ k⌉ samples; as in scikit-learn's KFold, the first P mod k folds get one extra. 925 samples in 10 folds make five folds of 93 and five of 92. Each round trains on all folds but one.

Which data is used for cross-validation?

Everything except the test set: the training and validation samples together. The test set stays untouched until the very end; cross-validation then replaces the single validation split.

What split ratio should I use?

80/20 or 70/15/15 are common starting points for a few thousand samples. With millions of samples, 1–2 % for validation and test is often enough. For small datasets, k-fold cross-validation (k = 5 or 10) uses the data better than one fixed split.

More in Developer

All tools in this category: Developer ·Updated November 7, 2026

Privacy choices

Google Analytics shows us which tools are used and whether they work. It may set cookies. Your choice is kept in this browser.