Stratified Shuffle Split#
Repeated random splits that preserve class proportions in each split.
Important
✨ AI-generated content. This page was written with the assistance of an AI language model and is provided as a learning aid. Despite careful review, it may still contain mistakes, omissions, or out-of-date information. Whether you are new to the topic, a team lead, or a senior practitioner, treat it as a starting point rather than an authoritative reference: read it critically and independently verify anything you act on (code, commands, figures, and factual claims) against official documentation and primary sources before relying on it.
What it is#
Stratified Shuffle Split repeatedly carves a dataset into random train/test splits while preserving the class distribution. Unlike k-fold, it does not partition into fixed folds — it reshuffles and resamples as many times as you ask, each split a fresh random draw with the original class ratios intact.
How it works#
Set n_splits (how many reshuffles) and a train/test size; for each split, shuffle, partition keeping the class proportions, and evaluate — then average across splits. Because test sets can overlap between splits (they are independent draws), it is not a partition the way k-fold is.
Example#
For 1,000 samples at 80% class A, 20% class B with test_size=0.2 over 5 splits, each
split yields train = 800 (A=640, B=160) and test = 200 (A=160, B=40) — the 80/20 ratio
holds every time.
In scikit-learn#
from sklearn.model_selection import StratifiedShuffleSplit
sss = StratifiedShuffleSplit(n_splits=5, test_size=0.2, random_state=42)
for train_idx, test_idx in sss.split(X, y):
...
It shines on imbalanced or small data where you want many randomized splits rather than a fixed fold structure — the stratified counterpart to a plain shuffle split, which randomizes but does not preserve class balance.
Theme: Validation & Cross-Validation · All terminology
Hint
Mind map — connected ideas
Stratified Group K-Fold · Multiclass stratified CV · k-fold cross-validation · Cross-Validation (CV) · Class Weighting · SMOTE (Synthetic Minority Over-sampling Technique)
Hint
More in Validation & Cross-Validation
Blocked Splits (Single Holdout) · Cross-Validation (CV) · Data Leakage · Evaluation Set · Expanding Window Cross-Validation · k-fold cross-validation · k-fold Stratified Cross-Validation (Stratified CV) · Multiclass stratified CV · Sliding Window (Rolling Window) Cross-Validation · Stratified Group K-Fold · Time-based splits (a.k.a. Temporal Cross-Validation, Rolling Window Validation)
See also
Source article Adapted (context, re-expressed) in our own words from: Stratified Shuffle Split (insightful-data-lab.com).