Stratified sampling
Stratified sampling divides a population into defined subgroups and selects observations from each to control or preserve subgroup representation in the sample.
Machine Learning System Design
Stratification is a sampling technique that divides data into groups and controls the amount selected from each group.
- How it is used
- Supports validation design, subgroup representation, and efficient sampling for large, imbalanced, or duplicate-heavy datasets.
- How deep it goes
- Defines group-based sampling and selection priorities, but does not detail algorithms or validation procedures.
- Examples
- Uses cross-country customer representation and fresh-versus-old temporal groups as concrete sampling cases.
- What you can do after
- Apply stratification by defining subgroups and controlling each group’s contribution to training or test data.
Read how Machine Learning System Design explains stratified sampling →
Inside Deep Learning: Math, Algorithms, Models
A sampling method that preserves class proportions across data splits or samples.
- How it is used
- Improves imbalanced-classification evaluation by preserving class ratios across train/test splits.
- How deep it goes
- Defines the ratio-preservation idea and its motivation but defers detailed class-imbalance treatment and implementation.
- Examples
- Uses a 99%-to-1% class example and a name-language classification dataset to contrast stratified and random splits.
- What you can do after
- Apply it via scikit-learn to create train/test splits whose class percentages mirror the original dataset.
Read how Inside Deep Learning: Math, Algorithms, Models explains stratified sampling →
Related concepts
- dataset splitused by · A dataset split is the division of a dataset into distinct subsets, typically assigned separate roles or distributed for independent storage or processing.
- samplingused by · Sampling is a procedure for selecting or generating observations, values, or outcomes from a larger population, signal, or probability distribution according to a specified method.
- evaluation datasetconfigures · An evaluation dataset is a collection of examples or cases designated to assess a model or system against defined criteria.
- multilabel classificationuses · Multilabel classification is a classification task in which each input may be assigned zero or more labels simultaneously.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

