Splitting, Shuffling and Augmenting Data to Reduce Bias
This lesson explains how splitting data into training, validation and test sets affects bias and evaluation reliability, and how shuffling, stratification and augmentation mitigate bias.
Learning outcomes
After completing this lesson, you will be able to:
- Explain the roles of training, validation and test sets.
- Apply shuffling, stratification and group-aware splits.
- Use augmentation and reweighting for under-represented groups.
Training, validation and test splits
Data is split into three sets with distinct roles. The training set is used to fit the model. The validation set is used to tune hyperparameters and decide when to stop training. The test set is used once, at the end, to estimate real-world performance; using it repeatedly for decisions makes its estimate optimistic. Common ratios are 70/15/15 or 80/10/10.
Data is usually shuffled before splitting so each set is representative, except for time series, which are split by time so the model is tested on later data than it was trained on. For small datasets, k-fold cross-validation trains k models, each validated on a different fold of the data, and averages the scores, which uses all the data for both training and validation.
What each split is for
Shuffling and stratification
Data is often stored in an order, such as by date, region or class. Splitting without shuffling can put all of one region or class in the test set. Shuffle before a random split, and use a stratified split to keep the same proportions of each class (and, if needed, each facet group) in every split. The exception is time series: split by time, training on the past and testing on the future, and never shuffle across time, or future information leaks into training. Groups of related records, such as several records from one patient, should be kept in one split.
The following diagram shows the grouped, stratified split.

Split it fairly
Augmentation and reweighting
Augmentation creates additional training examples for under-represented groups: image transformations, text paraphrases, synthetic records. Resampling over-samples small groups or under-samples large ones, and reweighting gives examples from small groups more weight in the loss function. These are applied to the training set only; validation and test sets must keep the real distribution. The following table summarises the techniques.
| Technique | Purpose | Caution |
|---|---|---|
| Shuffle then split | Avoid ordered splits | Not for time series |
| Stratified split | Same class or group mix in each split | Choose the stratification column carefully |
| Time-based split | Realistic evaluation for temporal data | No shuffling across time |
| Group split | Keep related records together | Needs a group ID |
| Augmentation, resampling, reweighting | Represent small groups better | Training set only |
Augmenting fairly
A skin-condition classifier
A dermatology image dataset has 20,000 images, of which only 6% show darker skin tones, and some patients have up to 30 images each. The first model performs much worse on darker skin.
- Split by patient ID so the same patient never appears in training and test sets.
- Stratify by skin-tone group so the test set contains enough darker-skin images to measure performance reliably.
- Augment darker-skin training images with rotations, crops and lighting changes, and collect more real images.
- Report recall separately for each skin-tone group.
Augmentation alone cannot replace real data diversity, so collection is part of the fix, but stratified evaluation is what reveals whether the gap has closed.
Why should time series not be shuffled across time before splitting?
Show answer
The model would train on future data and look better than it will in production.
Exam Tips
Remember for the exam
- Shuffle before random splits; never shuffle time series across time.
- Stratified splits keep class and group proportions.
- Keep all records of one entity in the same split.
- Augment, resample and reweight the training set only.
- Evaluate performance per group to detect bias.