How to use the Train Test Split Calculator
- 1. Enter total rowsType how many rows your dataset has.
- 2. Set percentagesChoose test and validation shares; training gets the rest.
- 3. Add classes and kOptionally enter class counts and k to plan stratified and k-fold splits.
How the rows are counted
Test and validation sizes are rounded up and training gets whatever is left: test = ⌈N × test%⌉, validation = ⌈N × validation%⌉, train = N − test − validation. This matches how scikit-learn's train_test_split sizes the test set.
Worked example: 1,000 rows with 20% test and 10% validation give 200 test rows, 100 validation rows and 700 training rows. With 5-fold cross-validation each fold holds 200 rows, and each training round uses about 800.
Choosing a split
- Small data (under a few thousand rows): prefer k-fold cross-validation so every row is used for both training and testing.
- Large data: a single split is fine, and the test share can be small; 1% of a million rows is still 10,000.
- Imbalanced classes: stratify so each set keeps the same class mix. Enter class counts above to see the expected rows per class.
- Time series: never shuffle. Train on the past and test on the most recent period.
Keep the test set locked until the very end. Tuning against it, or scaling features using all rows, leaks information and makes results look better than they are. In code: train_test_split(X, y, test_size=0.2, stratify=y, random_state=42). After training, evaluate with the confusion matrix calculator.
Frequently asked questions
Do I always need a validation set?
You need one when tuning hyperparameters. Cross-validation on the training set can replace a fixed validation split.
Why are stratified counts decimals?
They show the expected share. Real splitters round each class to whole rows.
Is the Train Test Split Calculator free?
Yes, the Train Test Split Calculator is free. The first time you see your first result, you are asked for your name and WhatsApp number once. After that, this and every other Uncodemy tool opens straight away without the form.