Concept · Builds on AIF-C01
Sources of bias in training data
Selection, sampling, measurement and label bias, leakage, and splitting that keeps tests honest.
You know from AI Practitioner
- A model learns from its data, so missing or skewed groups lead to unfair results.
- Good data is representative, varied and balanced.
- Training, validation and test sets are kept apart.
Selection
- Cause
- Data is not the whole population
- Remedy
- Collect from missing groups
Sampling
- Cause
- Skewed way of drawing rows
- Remedy
- Random or stratified sampling
Measurement
- Cause
- Tools record groups unequally
- Remedy
- Fix the tools, validate
Label
- Cause
- Annotator or history bias
- Remedy
- Guidelines, several annotators
Leakage
- Cause
- Answer or test data in training
- Remedy
- Split first, fit on train only
| Bias | Cause | Remedy |
|---|---|---|
| Selection | Data is not the whole population | Collect from missing groups |
| Sampling | Skewed way of drawing rows | Random or stratified sampling |
| Measurement | Tools record groups unequally | Fix the tools, validate |
| Label | Annotator or history bias | Guidelines, several annotators |
| Leakage | Answer or test data in training | Split first, fit on train only |
1 / 2
Selection
- Cause
- Data is not the whole population
- Remedy
- Collect from missing groups
Sampling
- Cause
- Skewed way of drawing rows
- Remedy
- Random or stratified sampling
Measurement
- Cause
- Tools record groups unequally
- Remedy
- Fix the tools, validate
| Bias | Cause | Remedy |
|---|---|---|
| Selection | Data is not the whole population | Collect from missing groups |
| Sampling | Skewed way of drawing rows | Random or stratified sampling |
| Measurement | Tools record groups unequally | Fix the tools, validate |
2 / 2
Label
- Cause
- Annotator or history bias
- Remedy
- Guidelines, several annotators
Leakage
- Cause
- Answer or test data in training
- Remedy
- Split first, fit on train only
| Bias | Cause | Remedy |
|---|---|---|
| Label | Annotator or history bias | Guidelines, several annotators |
| Leakage | Answer or test data in training | Split first, fit on train only |
- 1Shuffle the rows (not for a time series), then split with the same class mix in each split.
- 2Fit scalers and encoders on the training set only.
- 3Evaluate once on the untouched test set.
Step by step
- 1Shuffle the rows (not for a time series), then split with the same class mix in each split.
- 2Fit scalers and encoders on the training set only.
- 3Evaluate once on the untouched test set.
A safe order of steps for splitting and preprocessing.
What it is
Bias enters at each step. Selection bias: the data comes from a group that is not the whole population, such as only customers who stayed. Sampling bias: the way you draw rows skews the mix, for example only weekday data. Measurement bias: a sensor or form records one group less accurately. Label bias: annotators carry their own assumptions, or labels come from past human decisions that were biased. Remedies: collect or weight data from underrepresented groups, resample, augment, use clear label guidelines with several annotators, and check results per group.
What it is
Splitting protects honest evaluation. Shuffle rows before splitting, so an ordered file does not put one class or period in one split. Use stratified splits so train, validation and test keep the same class proportions, which matters most for rare classes. For time series, split by time instead and do not shuffle, so the model never trains on the future.
What it is
Data leakage lets information from outside training into the model. Target leakage: a feature contains the answer or is created after the outcome, such as a refund flag in a model that predicts refunds. Train-test contamination: preprocessing fit on all data before splitting, or the same record in train and test. Fit scalers and encoders on training data only, and remove duplicates across splits. Leakage gives great test scores and poor real results.
Remember
- Selection, sampling, measurement and label bias each have a different cause.
- Shuffle before splitting, except for time series.
- Stratified splits keep class proportions in every split.
- Leakage: target leakage and train-test contamination.
- Fit preprocessing on training data only.
Remember
- Remedies: collect more, reweight, resample, better labels, per-group checks.
On the exam
- “Test accuracy is far higher than production accuracy” points to data leakage.
- “A rare class is missing from the validation set” points to stratified splitting.
- “Only data from customers who stayed” points to selection bias.