B2 · How Artificial Intelligence Works: Data and Learning

Good Data and Bad Data

Good data is accurate, complete, varied and relevant to the task. Bad data has problems such as too few examples, wrong labels, missing values, duplicates or a one-sided mix, and a model trained on it learns those problems.

8 min Beginner Jump to the activity

What you need: Nothing. This page starts from the beginning, with no programming and no formulas.

Definition

What if half the labels in your examples were wrong?

Good data is accurate, complete, varied and relevant to the task. Bad data has problems such as too few examples, wrong labels, missing values, duplicates or a one-sided mix, and a model trained on it learns those problems.

In simple words

Engineers say "garbage in, garbage out". If you teach a model with photos where some cats are labelled dogs, it will learn the wrong thing. If all your dog photos are taken in sunshine, it may think 'sunny' means 'dog'. Checking the data is as important as building the model.

Why it matters

Most AI failures in the real world trace back to the data, not the model. Learning to spot data problems early saves time and prevents unfair or dangerous mistakes later.

Key terms

Data quality
How well data suits its purpose: accurate, complete, consistent, up to date and representative.
Missing value
A gap in the data where a value should be but was never recorded.
Duplicate
The same example appearing more than once.
Outlier
A value far from the rest, which may be a mistake or a genuine rare case.
Data cleaning
Finding and fixing errors, gaps and duplicates before data is used.
Representative
Containing the same mix of cases as the real situation the model will face.

Explained in detail

Garbage in, garbage out

Computer scientists have an old saying: garbage in, garbage out. A machine learning model has no knowledge of the world apart from its data. It cannot notice that a weight of 700 kilograms for a schoolchild is absurd, or that a photo labelled "cat" plainly shows a dog. Whatever is in the data, the model treats as truth and learns from it. For this reason the people who build AI systems commonly report spending more of their time preparing data than building models.

Six signs of good data

QualityQuestion to askExample of failure
AccurateAre the values and labels correct?A height entered as 1,700 cm
CompleteIs anything missing?Half the patients have no age recorded
ConsistentIs the same thing always written the same way?"Mumbai", "Bombay" and "mumbai" counted as three cities
Up to dateDoes it describe the present?Prices from five years ago
RelevantDoes it relate to the question?Shoe sizes in a rainfall dataset
RepresentativeDoes it cover every kind of case?Only daytime photos for a camera used at night

Common problems and what they do

Wrong labels teach the wrong lesson directly. Missing values force a choice: drop the example and lose data, or fill the gap with a guess and risk inventing a pattern. Duplicates make some examples count twice, and if a duplicate lands in both the training and the test set, the test score is inflated. Outliers need thought. An income a thousand times larger than the others may be a typing error, or it may be a real billionaire; removing genuine rare cases blinds the model to them. Too little data leaves the model guessing from coincidences.

Cleaning data

  1. Look at the data before using it. Sort each column and read the largest and smallest values.
  2. Remove exact duplicates.
  3. Make names and units consistent: one spelling for each city, one unit for each measurement.
  4. Decide what to do about each missing value, and write down what you decided.
  5. Check a sample of the labels by hand.
  6. Count the examples in each group to see whether any group is too small.

More is not always better

It is natural to think that a bigger dataset must be a better one. A million examples with careless labels can produce a worse model than ten thousand checked ones. A huge dataset drawn from one city does not teach a model about villages. Quantity helps only when quality and variety come with it. Experienced teams also write a short description of each dataset, recording where it came from, who is in it and who is missing, so that anyone who uses it later knows its limits.

How it works

ProblemExampleWhat the model learns
Too little dataOnly 5 photos of each animalA weak, unreliable pattern
Wrong labelsSome cats marked as dogsConfused answers
Missing valuesSize left blank for many animalsGaps in its knowledge
DuplicatesThe same photo added ten timesToo much weight on one case
One-sided dataOnly big dogs, never small onesMistakes on whatever is missing

Try it yourself

Clean a messy dataset

A shop wants to predict sales. See what's wrong with its data before training.

Find the problems in a dataset

Each row comes from a dataset for a fruit-sorting model. What is wrong with it, if anything?

  • Orange, 155 g, bumpy skin. Label: apple

  • Red, 150 g, smooth skin. Label: orange

  • Row 7 is exactly the same as row 6

  • Green, 140 g, smooth skin. Label: apple

  • Orange, ___ g, bumpy skin. Label: orange

Common mistakes

  • Assuming data is correct because a computer stored it.
  • Collecting data only from what is easy to find.
  • Fixing the model when the real problem is the data.

Check yourself

Question 1

1. What does 'garbage in, garbage out' mean?

Question 2

2. All dog photos were taken in sunshine. What might the model learn?

Question 3

3. The same photo appears ten times. This is…

Summary

  • Good data is accurate, complete, varied and relevant.
  • Watch for wrong labels, missing values, duplicates and one-sided data.
  • Most AI failures come from data problems.

Finished reading?

Sources: Google Machine Learning Crash Course