Train / Validation / Test Split Calculator
Plan your ML dataset splits with precision. Calculate sample counts per split, check class distribution, configure k-fold cross-validation, and get warnings when splits are too small.
Dataset Configuration
Enter the total number of labeled examples in your dataset.
Class Distribution
Cross-Validation
Time Series Data
Random split is wrong for time series data
- Random splits allow the model to "see the future" during training, causing data leakage.
- Validation metrics will be over-optimistic and won't reflect real deployment performance.
- Use temporal split instead: train on earlier data, validate and test on strictly later data.
- Example: Train on months 1–8, Validate on months 9–10, Test on months 11–12.
- For rolling evaluation, use walk-forward validation (expanding or sliding window).
- Add a gap period between train and val to match your real prediction horizon.
Split Results
Scientific Standards Reference
| Dataset Size | Recommended Split | Validation Strategy | Notes |
|---|---|---|---|
| < 500 | 80 / 0 / 20 | Leave-one-out or 5-fold CV | Every sample counts; skip fixed val set |
| 500 – 5,000 | 60 / 20 / 20 | 5-fold or 10-fold CV on train | Larger val/test for reliable metrics |
| 5,000 – 50,000 | 70 / 15 / 15 | Fixed val set or 5-fold CV | Classic split, widely accepted |
| 50,000 – 500,000 | 80 / 10 / 10 | Fixed val set | 10% still gives 5,000–50,000 val/test samples |
| > 500,000 | 90 / 5 / 5 | Fixed val set | 5% = 25,000+ samples; diminishing returns on more val data |
| Time series (any) | Temporal order | Walk-forward validation | Never use random splits; preserve chronology |
Frequently Asked Questions
What is the standard train/validation/test split ratio?▼
The most common split for general-purpose datasets is 70/15/15 (train/val/test) or 80/10/10. For very large datasets (100K+ samples), you can use 90/5/5 since even 5% gives thousands of examples. For small datasets (<1,000 samples), 80/20 (train/test only) with cross-validation on the training set is often preferred. The key principle: your test set must stay completely unseen until final evaluation to give an honest estimate of generalization performance.
What is stratified splitting and when is it necessary?▼
Stratified splitting ensures each split has the same class distribution as the full dataset. For example, if 10% of your data is class A and 90% is class B, a stratified split keeps that 10/90 ratio in train, validation, and test sets. It is essential for imbalanced datasets — without it, a random split might give your test set zero examples of a rare class. Most ML libraries (scikit-learn's train_test_split with stratify=y, sklearn's StratifiedKFold) support this. Always use stratification for classification tasks unless your dataset is perfectly balanced and very large.
What is k-fold cross-validation and when should I use it?▼
K-fold cross-validation divides the training data into k equal folds, trains k models (each time using k-1 folds for training and 1 fold for validation), then averages the validation metrics. It makes maximum use of limited data — every sample is used for both training and validation across different folds. Use k=5 or k=10 as defaults. K-fold is especially valuable when your dataset is small (<5,000 samples) or when you need a reliable estimate of model performance. Keep a separate held-out test set for final evaluation — never use cross-validation folds as your test set.
Why can't I use random splits for time series data?▼
Random splits for time series data cause data leakage: your model trains on future data and predicts the past, which is impossible in production but makes validation metrics look artificially good. Instead, use temporal splits — train on earlier data, validate/test on later data, preserving chronological order. For example, train on months 1-8, validate on months 9-10, test on months 11-12. For rolling evaluation, use walk-forward validation: train on t=1..n, predict t=n+1, then expand the window. The gap between train and validation sets should match your real deployment lag.
What is the minimum recommended sample count per split?▼
As a rule of thumb: at least 30 samples per class per split for basic statistical validity. For reliable model evaluation, aim for 100+ samples per class in your validation/test sets. With fewer than 30 samples in a class per split, your metrics (accuracy, F1, AUC) will have very high variance and may not be trustworthy. For very small datasets, k-fold cross-validation is preferable to a fixed split. If you have fewer than 10 samples per class in the full dataset, consider data augmentation, transfer learning, or few-shot methods instead of traditional train/test splits.
Related Products
on GumroadDeveloper Productivity Bundle
Stop rebuilding the same setup every project. 51 VSCode snippets, 40 Git aliases, 5 Docker Compose stacks, 5 GitHub Actions workflows, 5 README templates, and a dotfiles kit. Set up a professional dev environment in under an hour.
Buy on Gumroad →AI Prompt Engineering Toolkit
58 structured prompt templates for Claude, ChatGPT, and Gemini — organized by use case. Code Review, Debugging, Documentation, Architecture, and 10 model-specific tips. Stop writing prompts from scratch.
Buy on Gumroad →Developer Cheat Sheet Bundle
10 print-ready cheat sheets for the tools developers use every day: Git, Docker, Linux CLI, SQL, Regex, HTTP Status codes, VS Code shortcuts, Bash scripting, jq/JSON, and Markdown.
Buy on Gumroad →You Might Also Need
Fake Data Generator
Generate realistic fake user data for testing and development. Choose locale (en/zh-TW/ja), count (1-100), fields to include, and output format (JSON/CSV/SQL INSERT). 100% browser-based.
Open free tool →
YAML Validator Pro
Advanced YAML validator with line-number error reporting, JSON preview, and schema hints for common YAML pitfalls. Free, runs in your browser.
Open free tool →
YAML to JSON Converter
Convert YAML to JSON and JSON to YAML online. Bidirectional conversion with syntax highlighting, error detection, and formatted output. Supports multi-document YAML and complex nested structures.
Open free tool →
More Free Tools
Related Articles
Pydantic v2 Complete Guide: Validation, Settings & Data Modeling
Master Pydantic v2 in 2025. BaseModel validation, field validators, model settings, custom types, serialization, and performance improvements over v1 with code examples.
The Rust Ecosystem in 2026: Frameworks, Libraries, and Community
Explore the vibrant Rust ecosystem in 2026 covering web frameworks like Actix and Axum, async runtimes including Tokio, WebAssembly tools, database drivers, CLI libraries, game development with Bevy, and machine learning frameworks.
DSPy: Building Self-Optimizing LLM Pipelines in 2026
DSPy 2026: build self-optimizing LLM pipelines with signatures, modules, and teleprompters. Real-world examples vs manual prompting for developers.
LLM Fine-tuning Complete Guide: When to Fine-tune vs RAG vs Prompting (2026)
A practical guide to LLM fine-tuning in 2026: when fine-tuning actually makes sense, step-by-step PEFT/LoRA and QLoRA walkthrough, OpenAI fine-tuning API, cost estimates, and how to evaluate if it worked.
LLM Fine-tuning Guide 2026: LoRA, QLoRA & PEFT for Production
Complete guide to LLM fine-tuning in 2026: LoRA vs QLoRA vs PEFT techniques, Hugging Face training, cost comparison with RAG, practical use cases, and production deployment of fine-tuned models.
Enjoying this tool? Get more like it.
Weekly developer tool guides, productivity playbooks & AI tricks. Free. No spam.
Unlock AI-Powered Dev Tools
- ⚡ AI Code Review, Doc Generator & SQL Builder
- ⚡ All premium templates & early access
- ⚡ Member discounts on Gumroad products
$9/mo after trial · Cancel anytime
Want the full toolkit?
Get DevPlaybook Pro
Every template, guide, boilerplate, and automation script in one bundle. 13 premium products — grab them all at once and save big.
MIT licensed · Instant download · No subscription
See what's included → Browse all deals →