Elysia Tools

Browse tools, examples, visual explainers, and topic guides from one clear workspace.

Top Categories

Hubs

Language
ZHDERUPTENFRES

Elysia Tools

Navigation

Data Analysis

Train/Test Split with Stratification

· Last updated:2026-08-21

Class-stratified train/validation/test split or stratified k-fold for CSV/JSON datasets — seeded, reproducible, with distribution reports, leakage checks, SMOTE preview and CSV export.

Details

What this tool helps you do

Implements sklearn-style semantics in pure TypeScript: per-class seeded shuffle (mulberry32 + Fisher–Yates) with largest-remainder allocation across splits (or StratifiedKFold round-robin for k-fold), per-split class-share tables with deviation bars, cross-split duplicate-leakage checks, rare-class guards (classes with fewer than 2 members cannot stratify — sklearn raises the same error; k > smallest class is rejected like sklearn's nsplits error), and a SMOTE preview (Chawla et al. 2002: xnew = xi + λ·(xneighbor − xi) with one λ per synthetic sample, over the 5 nearest minority neighbors, numeric columns only) applied to the training split only. Exports train/validation/test (or per-fold) CSVs plus a splitreport.json manifest in a ZIP.

Execution

Run this tool

Fill in the form, run the tool, and review the result in one place.

Samples

Examples that match this tool

Related

Continue with connected tools and hubs

Written by the Elysia Tools team

Tool usage guide

Learn when to use this tool, what it supports, and how real users apply it.

Key facts

Category
Data Analysis
Input types
file, textarea, text, select, number, checkbox
Output type
html
Sample coverage
4
API ready
Yes

Overview

Train/Test Split with Stratification partitions CSV and JSON tabular datasets into train, validation, and test subsets or stratified k-fold splits while preserving exact target class proportions. Using seeded pseudo-random shuffling, largest-remainder allocation, cross-split duplicate-leakage checks, and optional training-only SMOTE oversampling previews, it generates balanced partitions and downloads ready-to-use CSV files packaged in a ZIP archive.

When to use

  • When preparing imbalanced classification datasets where random splitting might underrepresent or omit minority classes in validation or test subsets.
  • When setting up reproducible, seeded k-fold cross-validation folds that require proportional class representations across every fold.
  • When auditing dataset splits for data leakage, cross-split duplicate rows, and class-share distribution deviations before model training.

How it works

  1. 1Upload a CSV or JSON file (or paste raw CSV text) and specify the target column name containing your class labels.
  2. 2Choose between a standard train/validation/test percentage split or stratified k-fold cross-validation, then configure your random seed, shuffle options, and split ratios.
  3. 3The tool performs seeded Mulberry32 shuffling per class, calculates largest-remainder or round-robin allocations, checks for rare-class constraints, and screens for duplicate row leakage.
  4. 4Review the interactive class distribution reports with deviation bars, inspect the optional SMOTE training oversampling preview, and download the split CSV files with a summary manifest in a ZIP archive.

Use cases

  • Machine learning engineers partitioning tabular churn or fraud data into stratified 70/15/15 train, validation, and test splits.
  • Data scientists generating 5-fold or 10-fold cross-validation datasets with preserved class balance and zero duplicate row leakage.
  • Researchers balancing imbalanced classification benchmarks using training-split SMOTE oversampling previews and distribution reports.

Compare alternatives

  • Forecast future periods from CSV or JSON time-series data and inspect trend, seasonal, and residual decomposition in one report

  • Infer a relational schema from CSV data and generate create-table plus ALTER migration plans for PostgreSQL, MySQL, SQLite, or SQL Server

  • Turn CSV or Excel rows into Schema.org JSON-LD for articles, products, or events, with validation-ready output for SEO workflows

Who it's for

Best for

  • Convert CSV files in the browser.
  • Workflows where Split mode matters, such as Train / validation / test or Stratified k-fold cross-validation.
  • The “Stratified 70/15/15 split of a small sentiment dataset” workflow, done in one pass.

Not ideal for

  • Fully automated batch jobs — this page is built for interactive use; use the API endpoint for scripts.
  • Files in formats this tool does not accept — it works with .csv, .json input.

Edge cases & common failures

  • Byte-order mark (BOM)

    A UTF-8 BOM at the start of the file can appear as odd characters in the first header name.

  • Very large files

    Large files take longer and can hit browser memory limits — try a smaller sample first.

  • Skipping the output check

    Compare the first rows or pages of the output with the input before using it in production.

Examples

1. Stratified 70/15/15 Split for Sentiment Classification

NLP Engineer

Background

A team has a small labeled sentiment dataset with uneven positive, negative, and neutral classes that must be split without losing minority class representation in the test set.

Problem

Random splitting can cause severe class distribution drift or leave validation sets with zero instances of rare classes.

How to use

Paste the sentiment CSV data, set the target column to 'label', select 'Train / validation / test' mode with 70% train and 15% validation, set the random seed to 42, and ensure stratification is checked.

targetColumn: "label", splitMode: "standard", trainPercent: 70, valPercent: 15, randomSeed: 42, stratify: true, shuffle: true, exportZip: true

Outcome

Generates train.csv, validation.csv, test.csv, and split_report.json in a ZIP file, keeping class shares aligned across all splits.

2. Stratified 4-Fold Cross-Validation for Tabular Risk Scoring

Risk Analyst

Background

An analyst needs to validate a credit default scoring model across 4 balanced evaluation folds.

Problem

Unstratified folds lead to inconsistent default rates across folds, distorting cross-validation performance metrics.

FAQ

How does stratified splitting handle imbalanced class labels?

It groups rows by the target column, shuffles each class independently using the random seed, and distributes members across splits using largest-remainder allocation so each split matches the original class distribution.

What is the difference between standard split and k-fold cross-validation mode?

Standard split divides data into fixed train, validation, and test sets based on percentage ratios, whereas k-fold splits data into k non-overlapping validation folds with round-robin stratified assignment.

How does the SMOTE preview work?

SMOTE creates synthetic samples exclusively for minority classes in the training split by interpolating between nearest minority neighbors across numeric feature columns.

What happens if a class has fewer samples than the number of splits or folds?

Classes with fewer than two samples trigger rare-class guards, and requesting more folds (k) than the sample count of the smallest class is rejected to prevent invalid cross-validation partitions.

What files are included in the downloaded ZIP archive?

The ZIP export contains partitioned CSV files (e.g., train.csv, validation.csv, test.csv, or fold-specific CSVs) along with a split_report.json manifest detailing distribution stats and configurations.

Hub

Classification Dataset Stratified Split Review and Handoff

Prepare independent classification records, freeze a seeded stratified split, review class coverage and leakage limits, and deliver verified partitions with a reproducibility ledger.

Home
Tools3212
Samples593
Visualizations471
Viewers103
Hubs239
Tags333
Images, Audio & Video657

Image, audio, and video processing, conversion, and optimization tools

Math, Date & Finance647

Calculators, numerics, date logic, statistics, and finance tools

Design & Color298

Color, layout, graphics, visual styling, and design helper tools

Text & Writing209

Writing, cleanup, formatting, extraction, and text analysis tools

Developer & Web193

Developer utilities, networking, web debugging, and automation helpers

Conversion & Encoding175

Format, file, archive, unit, and encoding conversion tools

Lead Generation Quiz Launch and Contact Handoff
Memorial Drafts: Family Review and Print Handoff
Private Habit Records: Backup, Restore and Sharing Review
Article to X and LinkedIn Drafts: Fact Review and Handoff
Markdown Interactive Deck Review and Offline Handoff

© 2026 Elysia Tools. All rights reserved.

DocsPricingAboutTerms of ServicePrivacy PolicyCookiesContact
Data

CSV Samples

Sample CSV files with various data types, sizes, and complexity levels

Programming Languages

Python Samples

Essential Python code examples and Hello World demonstrations

Web Technologies

WebRTC Real-Time Communication Samples

Comprehensive WebRTC samples for peer-to-peer audio/video communication, data channels, screen sharing, and signaling server implementation

Observability

Distributed Tracing Samples

Comprehensive distributed tracing examples using Jaeger, OpenTelemetry, and other modern observability tools for microservices architecture

Data Analysis

Time Series Forecast & Seasonality Analyzer

Forecast future periods from CSV or JSON time-series data and inspect trend, seasonal, and residual decomposition in one report

Data Processing

CSV to Database Migration Planner

Infer a relational schema from CSV data and generate create-table plus ALTER migration plans for PostgreSQL, MySQL, SQLite, or SQL Server

Security

CSV/JSON Data Watermarker

Inject visible or signature-style watermark fields into CSV or JSON exports so shared datasets can be traced later

Data Analysis

Dataset Imbalance Detector & Resampler

Detect class imbalance in CSV or JSON datasets, compare resampling strategies, and preview a balanced output dataset

How to use

Upload the risk dataset CSV, specify the target class column, choose 'Stratified k-fold cross-validation' with 4 folds, and generate the partitioned folds.

targetColumn: "default_flag", splitMode: "kfold", kFolds: 4, randomSeed: 42, stratify: true, shuffle: true, exportZip: true

Outcome

Produces 4 paired train and validation CSV files with identical class proportions per fold and distribution deviation reports.

Time Series Forecast & Seasonality Analyzer
CSV to Database Migration Planner
JSON-LD Generator from CSV