Measuring Bias Across Numeric, Text and Image Data
This lesson explains how to apply bias metrics across tabular, text and image data and adjust data distributions accordingly, since bias can hide in any modality a model uses.
Learning outcomes
After completing this lesson, you will be able to:
- Measure bias in numeric and categorical data.
- Derive attributes to measure bias in text data.
- Measure and correct skew in image data.
Numeric and categorical data
For tabular data, SageMaker Clarify computes bias metrics directly on facet columns, such as class imbalance (CI), difference in proportions of labels (DPL), Kullback-Leibler (KL) divergence and Jensen-Shannon (JS) divergence. Continuous facets, such as age, are divided into groups with a threshold, for example under 40 and 40 or over.
The aim is not identical numbers in every group, which may be impossible or even wrong when groups genuinely differ. The aim is awareness of large gaps and a deliberate, documented decision on whether each gap is justified or must be corrected.
Facets in numeric data
Text data
Text datasets can be biased in language, dialect, topic, sentiment and the demographic groups mentioned. To measure this, derive attributes for each document, for example language with Amazon Comprehend's language detection, sentiment and entities with Comprehend and demographic mentions with keyword lists or classifiers, then compute group sizes and outcome rates per attribute as facets. For generative models, paired prompts that differ only in a demographic term reveal stereotyping in outputs, which Bedrock evaluations and Clarify FM evaluations support.
The following diagram shows a bias finding against Spanish-language insurance claims and the fix for each kind of data: numeric fields, claim notes and photos.

Bias beyond tables
Image data
Image datasets can be skewed in lighting, background, camera, viewpoint, and subject attributes such as age or skin tone. Collect attributes from capture metadata, human annotation or Amazon Rekognition labels, then compare group sizes and model accuracy per group. Rebalance by collecting more images of under-represented conditions, augmenting with realistic transformations and weighting the loss.
The following table summarises how to measure and fix distribution bias in each modality.
| Modality | Derive facets from | Rebalance with |
|---|---|---|
| Numeric / categorical | Existing columns, bucketed thresholds | Resampling, reweighting, more data |
| Text | Comprehend language, sentiment, entities; keyword classifiers | Targeted collection, paraphrase, back-translation |
| Images | Capture metadata, Rekognition labels, annotation | Collection, augmentation, loss weighting |
A multimodal claims model
An insurer's claims model uses claim amount (numeric), the adjuster's notes (text) and damage photos (images). Approvals are lower for claims written in Spanish.
- Numeric: Clarify shows DPL of 0.18 between English and Spanish claims for similar amounts.
- Text: Comprehend language detection shows Spanish notes are 4% of training data; the text encoder was trained mostly on English.
- Images: photos for Spanish claims come mostly from older phone models with low resolution.
Fixes include a multilingual text encoder, more Spanish training examples (back-translation from English examples where appropriate), image augmentation simulating low-resolution cameras and re-measuring DPL after retraining. Looking only at the numeric columns would have missed two of the three causes.
What must be done before bias can be measured on text or images?
Show answer
Derive facet attributes, such as language or the people shown, from the content.
Exam Tips
Remember for the exam
- Derive facet attributes for text and images before measuring bias.
- Comprehend language detection and sentiment help profile text datasets.
- Rekognition labels and metadata help profile image datasets.
- Paired prompts reveal stereotyping in generative models.
- Re-measure bias metrics after rebalancing.