Data Quality and Bias in Data

Updated · 6 min read
easyPython 3.13aidatadata-qualitybiasbeginnersinterview

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

A model learns whatever its examples teach it
ProblemWhat it meansWhat goes wrong
InaccurateValues are wrong, such as a typo in a priceThe model learns false patterns
MislabeledThe answer attached is wrong, such as a dog labeled "cat"The model learns the wrong answers
IncompleteValues or labels are missingExamples are wasted or misleading
DuplicatedThe same example appears more than onceSome cases count more than they should
Low qualityBlurry photos, noisy audio, unreadable scansThe pattern can't be seen
OutdatedThe world has changed since the data was collectedPredictions follow old patterns
BiasedSome groups or cases are missing or under-representedThe 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:

Python
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))
Output
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:

  1. What happens when a model is trained on mislabeled examples?
  2. Why can a duplicate example be a problem?
  3. Give one real-world example of biased data.

Quick check: data quality and bias

4 questions
1A model trained only on photos of red apples meets a green apple. What is most likely?
2To a computer, are "Dog" and "dog" the same label?
3Which statement about data quality is true?
4A speech system works badly for people with one accent. What should you check first?

Key Takeaways

Quick reference

TermMeaning
Data qualityHow accurate, complete, consistent and recent data is
Mislabeled dataExamples with the wrong answer attached
Missing valueA value or label that wasn't recorded
DuplicateThe same example appearing more than once
Bias in dataData that doesn't represent the real world fairly

Was this tutorial helpful?

Lesson 11 of 186