Measuring Pre-Training Bias with SageMaker Clarify
This lesson explains where bias in ML, systematic differences in how a dataset or model treats groups, usually originates, and how to measure it before training with SageMaker Clarify.
Learning outcomes
After completing this lesson, you will be able to:
- Identify sampling, historical, measurement and other sources of bias.
- Define facets and labels for a Clarify bias analysis.
- Interpret class imbalance and difference in proportions of labels.
Where bias comes from
Sampling bias arises when the data does not represent the population, such as a voice dataset recorded mostly by young speakers. Historical bias arises when labels reflect past unfair decisions, such as previous hiring outcomes. Measurement bias arises when features are measured differently across groups. Label bias arises from inconsistent or prejudiced annotators. Proxy features, such as postal code standing in for ethnicity, carry bias even when sensitive attributes are removed.
Name the bias
Facets and SageMaker Clarify
SageMaker Clarify measures bias with respect to a facet, the attribute that defines the groups being compared, such as gender or age group, and a label with a value that represents the positive outcome, such as loan approved. It then compares how groups are represented and how outcomes are distributed among them.
A Clarify processing job computes pre-training metrics on the dataset, such as class imbalance and differences in positive label rates between groups, before any model exists. After training, it computes post-training metrics on the model's predictions, such as differences in accuracy or approval rates. Reports appear in SageMaker Studio and as JSON files in Amazon S3, so they can be reviewed and archived as evidence.
Key pre-training metrics
Class imbalance (CI) compares the number of records in the facet groups; values near +1 or -1 mean one group is barely represented. Difference in proportions of labels (DPL) compares the rate of positive labels between groups. Kullback-Leibler (KL) and Jensen-Shannon (JS) divergence, Lp-norm and total variation distance (TVD) compare the full label distributions. Kolmogorov-Smirnov (KS) gives the largest difference between distributions, and conditional demographic disparity (CDD) checks disparity within subgroups, which reveals cases where an overall difference is explained by another attribute.
The following table summarises the metrics most often tested.
| Metric | Measures | Interpretation |
|---|---|---|
| Class imbalance (CI) | Group sizes | Near 0 balanced; near +/-1 one group under-represented |
| DPL | Positive-label rate difference | Near 0 similar rates; large value favours one group |
| KL / JS divergence | Difference of label distributions | 0 identical; larger means more different |
| Total variation distance | Half the L1 distance of distributions | 0 identical |
| CDD | Disparity within subgroups | Detects Simpson's paradox effects |
Post-training metrics include difference in positive proportions in predicted labels (DPPL), disparate impact (DI), and differences in accuracy, recall and precision between groups.
The following diagram shows the group sizes and approval rates behind two pre-training bias metrics for a loan dataset, where applicants under 25 are the group of interest.

Compute class imbalance and DPL
A loan approval dataset
Before training a loan approval model, a Clarify pre-training job is run with facet age_group = under_25 and positive label approved = 1.
Facet group Records Approval rate
under_25 4,000 38%
25_and_over 96,000 71%
CI = (96,000 - 4,000) / 100,000 = 0.92 -> under_25 heavily under-represented
DPL = 0.71 - 0.38 = 0.33 -> large difference in approval labelsBoth metrics signal risk. The team collects more applications from younger customers, reviews whether historical approvals were fair, and plans to check post-training metrics such as disparate impact. Simply deleting the age column would not help, because correlated features such as credit history length act as proxies.
What does the difference in proportions of labels (DPL) measure?
Show answer
The difference in positive-label rates between groups, before any model is trained.
Exam Tips
Remember for the exam
- Measure bias before training: Clarify pre-training metrics on a facet.
- CI near +/-1: one group under-represented.
- DPL: difference in positive-label rates between groups.
- Removing a sensitive column does not remove proxy bias.
- Post-training metrics (DPPL, DI) evaluate the model's predictions.