Data Quality and Bias in Data
What would happen if you taught a child that every dog is a cat? Show them a hundred dogs and call each one "cat", and they will confidently call the next dog a cat. They learned exactly what they were taught. The mistake was in the teaching, not in the learning.
AI works the same way. A model learns whatever its examples teach it, including their mistakes. This lesson shows the common problems in data, and why poor-quality data can produce poor-quality AI systems.
What Bad Data Looks Like
| Problem | What it means | What goes wrong |
|---|---|---|
| Inaccurate | Values are wrong, such as a typo in a price | The model learns false patterns |
| Mislabeled | The answer attached is wrong, such as a dog labeled "cat" | The model learns the wrong answers |
| Incomplete | Values or labels are missing | Examples are wasted or misleading |
| Duplicated | The same example appears more than once | Some cases count more than they should |
| Low quality | Blurry photos, noisy audio, unreadable scans | The pattern can't be seen |
| Outdated | The world has changed since the data was collected | Predictions follow old patterns |
| Biased | Some groups or cases are missing or under-represented | The model works worse for them |
Bias in Data
Biased data doesn't represent the real world fairly. The model in the picture saw only red apples, so it struggles with green ones. That sounds harmless with fruit, but the same problem with people causes real harm:
- A face recognition system trained mostly on photos of one group of people can work worse for others.
- A speech recognition system trained mostly on one accent can misunderstand others.
- A hiring tool trained on past hiring decisions can copy the unfairness in those decisions.
The model isn't choosing to be unfair; it is repeating its data. That is why checking who is, and isn't, in a dataset matters as much as checking the values.
Simple Checks Anyone Can Run
Many problems can be found before training. This program checks a tiny photo dataset for missing labels, duplicates and inconsistent spellings:
photos = [
{"file": "p1.jpg", "label": "dog"},
{"file": "p2.jpg", "label": "cat"},
{"file": "p3.jpg", "label": None},
{"file": "p1.jpg", "label": "dog"},
{"file": "p4.jpg", "label": "Dog"},
]
missing = [p["file"] for p in photos if p["label"] is None]
print("Missing labels:", missing)
files = [p["file"] for p in photos]
duplicates = sorted({f for f in files if files.count(f) > 1})
print("Duplicates:", duplicates)
labels = {p["label"] for p in photos if p["label"]}
print("Different spellings:", sorted(labels))Missing labels: ['p3.jpg']
Duplicates: ['p1.jpg']
Different spellings: ['Dog', 'cat', 'dog']"Dog" and "dog" look the same to you, but they are two different labels to a computer. Real teams run checks like these, plus counts of how many examples each group has, before every training run.
Common Mistakes
Thinking more data fixes bad data. A million mislabeled photos teach the mistake a million times.
Blaming only the model. When a model fails for a group of people, check the data first: often that group was missing from it.
Cleaning data once and forgetting it. The world changes, so data that was accurate last year can be outdated now.
Interview Corner
Why does data quality matter so much in AI?
A model learns whatever its examples teach it. Wrong labels, missing values, duplicates and unrepresentative data all lead to wrong or unfair predictions, however good the model's design.
What is bias in data? Give an example.
Data that doesn't represent the real world fairly, so the model works worse for some groups or cases. For example, a speech recognition system trained mostly on one accent can misunderstand speakers with other accents.
Practice
Exercise: audit a dataset. Look at the product dataset you built in "Datasets, Labels and Features", or a list of your own photos. Find one example of each problem you can: a wrong value, a missing value, a duplicate, an inconsistent spelling and a group that is missing. How would each one affect a model trained on it?
Check your understanding:
- What happens when a model is trained on mislabeled examples?
- Why can a duplicate example be a problem?
- Give one real-world example of biased data.
Key Takeaways
Quick reference
| Term | Meaning |
|---|---|
| Data quality | How accurate, complete, consistent and recent data is |
| Mislabeled data | Examples with the wrong answer attached |
| Missing value | A value or label that wasn't recorded |
| Duplicate | The same example appearing more than once |
| Bias in data | Data that doesn't represent the real world fairly |
Was this tutorial helpful?