🧷  Multiclass stratified CV

Multiclass stratified CV#

Stratified cross-validation maintaining each class’s proportion across folds.

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#

Multiclass stratified CV is stratified k-fold extended beyond two classes: every fold keeps approximately the same distribution across all classes as the full dataset. It is the natural generalisation of binary stratification to three or more labels.

How it works#

Measure the overall class mix — say A = 60%, B = 30%, C = 10% — and build each fold to mirror it, so every fold carries A, B and C in roughly those proportions. Both training and validation sets then represent all classes.

Example#

For 1,000 samples split A = 600, B = 300, C = 100 with k = 5, a regular k-fold might leave some folds with almost no class-C examples. Multiclass stratified k-fold gives each fold about A = 120, B = 60, C = 20 — the original shape, fold after fold.

Why it matters#

In imbalanced multiclass problems, plain k-fold can starve a minority class in some folds, producing unstable, misleading metrics (a fold with no class-C samples cannot measure class-C performance). Stratification makes the evaluation fair and stable. It applies to classification only — there is nothing to stratify in a regression target.


Theme: Validation & Cross-Validation  ·  All terminology



See also

Source article Adapted (context, re-expressed) in our own words from: Multiclass stratified CV (insightful-data-lab.com).

Tags: purpose: reference topic: terminology level: intermediate