AI Bias and Fairness: How Unfair Data Makes Unfair Models
A machine learning model learns from examples. It has no other way to know about the world. So if the examples are one-sided, the model will be one-sided too. When a model works well for some people and badly for others, we call that bias. Making sure a model treats different groups fairly is called fairness.
This guide explains how bias gets into a model, how to check for it with simple counting, and what questions to ask about any AI system you meet.
A model only knows its data
Imagine you show a computer 1,000 photos of dogs so it can learn to spot a dog. Now imagine 950 of those photos are of one breed: big, golden, fluffy dogs. The model gets very good at spotting big, golden, fluffy dogs. Then someone shows it a small, black, short-haired dog. The model has hardly seen anything like it. It may say "not a dog".
The model is not being mean. It does not have opinions at all. It simply learned the pattern in the photos it was given, and those photos left most dogs out.
Here is another made-up example. A voice tool learns to understand spoken commands, such as "lights on". If almost all of its training recordings come from people with one accent, it may understand that accent well and other accents badly. Children with a different accent would have to repeat themselves again and again, while others never notice a problem.
Three ways bias gets in
- Someone is missing. The data has few or no examples of some group, like the small dogs above. The model has nothing to learn from for them.
- Someone is mislabeled. A label is the answer we want the model to learn, such as "dog" or "not a dog". If people labeling the data make more mistakes for one group, the model learns those mistakes.
- The past was unfair. If a model learns from old decisions that were unfair, it can learn to repeat them. Copying the past is not the same as being right.
Our guide to data and datasets shows how to build a table of examples carefully, and why it must include everyone the model will be used on.
A real example: checking face tools group by group
In 2018, the researchers Joy Buolamwini and Timnit Gebru published a study called Gender Shades. They tested three commercial computer programs that looked at a photo of a face and guessed whether the person was a man or a woman. They first noticed that two popular collections of face photos used for testing were mostly of lighter-skinned people. So they built a new, balanced set of photos and checked how often each program was wrong for each group.
The results were very uneven. For lighter-skinned men, the error rate was at most 0.8 percent. For darker-skinned women, it was as high as 34.7 percent. The programs looked accurate overall, but they were much worse for one group. The study is a good lesson: you only find a problem like this if you count separately for each group.
How to check fairness: count for each group
A single accuracy number can hide a weak group. Here is a made-up example to show how. Our voice tool from earlier listens to a short clip and decides one thing: did the person say "yes"? We test it on 1,000 clips. Most clips (900) come from speakers with the accent that filled the training data. We will call them Group A. The other 100 come from speakers with a different accent, Group B.
For each group we fill in a confusion matrix, a small table of four counts:
- True positive: the person said "yes" and the tool heard "yes".
- False positive: the person did not say "yes", but the tool heard "yes".
- True negative: the person did not say "yes", and the tool agreed.
- False negative: the person said "yes", but the tool missed it.
These numbers are invented for this example:
| Made-up results | True pos. | False pos. | True neg. | False neg. | Accuracy | Recall |
|---|---|---|---|---|---|---|
| Group A (900 clips) | 430 | 10 | 440 | 20 | 0.9667 | 0.9556 |
| Group B (100 clips) | 25 | 5 | 40 | 30 | 0.65 | 0.4545 |
| Everyone (1,000 clips) | 455 | 15 | 480 | 50 | 0.935 | 0.901 |
Accuracy is the share of all answers that were right. Recall is the share of real "yes" answers the tool caught.
Look at the bottom row first. An accuracy of 0.935 means the tool was right on 935 of 1,000 clips. That sounds great. Now look at Group B. The tool was right on only 65 of their 100 clips, and it caught fewer than half of the times they really said "yes" (25 out of 55). Because Group B is small, its bad results barely move the overall number. If you only looked at the bottom row, you would never know.
You can check these figures yourself with the Model Accuracy Predictor, which works out accuracy, precision and recall from a confusion matrix. Type in each row's four counts. Our guide to accuracy, precision and recall explains each measure.
What can fix it?
- Collect better data. Add carefully labeled examples of the groups that were missing, with permission from the people involved.
- Test every group, every time. Keep a test set with enough examples of each group to count fairly. Ten clips is not enough to judge a group.
- Check the labels. Look for groups where the labels are more often wrong.
- Decide if the tool should be used at all. Sometimes the fair answer is that a tool is not good enough for a job yet.
Size matters too. The Dataset Size Calculator shows how a split works: 1,000 rows split 70/15 gives 700 for training, 150 for validation and 150 for testing. If only 10 percent of the rows came from Group B, roughly 15 of those 150 test rows would be theirs. That is too few to measure them well, so you may need to collect more.
Questions to ask about any AI system
- What data did it learn from, and who collected it?
- Who is missing from that data, or barely there?
- Was it tested on people like the ones who will use it?
- Are the results reported for each group, or only as one overall number?
- What happens when it is wrong, and who can fix the mistake?
- Can a person check or overrule its answer?
These questions work for a homework app, a photo sorter or a voice tool. You do not need to know how the model is built to ask them. They are also a good starting point for a class discussion about AI ethics.
For parents and teachers
Bias is a good topic for class discussion because children can test the idea with paper cards: train a "rule" on a pile that is missing one kind of card, then test it on a full pile. Keep any real data about people out of the activity. Collect information about pupils only with permission, and never type classmates' names, photos or voices into an online tool. A model that is fair on average can still fail a small group, so the habit to teach is simple: count for each group, not just for everyone.