Data – food for artificial intelligence
A model is only as good as the data it learned from. In this lesson you will learn what data is, what features and labels are, why it is important for data to be plentiful and varied – and how bad data makes an unfair model.
What data is
| Type of data | Example | What AI can learn |
|---|---|---|
| numbers and measurements | temperature and humidity from the DHT11 sensor | to predict when it will be warm |
| text | messages, articles, books | to recognize spam or write text |
| images | photos of animals, plants, handwritten digits | to recognize what is in an image |
| sound | recordings of spoken words | to turn speech into text |
| movement | the accelerometer in a phone or a micro:bit | to recognize walking, running, jumping |
We usually write training data in a table: each row is one example, and each column one feature. Images and sound are turned into numbers before learning (for example, each pixel of an image is a number that says how bright it is).
Features and labels
In a table we distinguish two kinds of columns:
- features – what we measure or see (mass, color, shape);
- label – the correct answer the model should learn to guess (which fruit it is).
| mass (g) | color | shape | label |
|---|---|---|---|
| 150 | red | round | apple |
| 120 | yellow | long | banana |
| 200 | orange | round | orange |
| 170 | green | round | apple |
| 130 | yellow | long | banana |
Labeling data is often the biggest job in making an AI system. For some tasks (for example medical scans) the labels must be given by experts.
How much data is needed?
- For a simple task (for example telling two objects apart with a camera), a few dozen examples per group are enough – you will try this in the next lesson.
- Recognizing thousands of kinds of objects requires millions of images.
- Large language models learn from huge amounts of text – much more than a person could read in a whole lifetime.
But it isn't only the amount that matters, but also the variety: different lighting, angles, backgrounds, people, voices.
Bias: when data isn't fair
If something is missing from the data, or there are too many examples of one kind, the model “inherits” it. This is called bias.
- A model that learned only from images of black cats may not recognize a white cat.
- Face recognition that learned mostly from the faces of one group of people makes mistakes more often with other people.
- A speech recognition app that listened only to adults has a harder time understanding children.
A biased model can be unfair to some people, even though nobody intended it. That is why data is carefully chosen and checked.
Errors in data
Before learning, the data should be cleaned: errors removed or corrected. Typical errors:
- a wrong label (an apple labeled as a banana);
- an impossible value (an apple's mass of 15,000 g – someone forgot the decimal point);
- a missing value (an empty field);
- the same example entered several times.
With sensors (as in the lesson about the DHT11) a typical error is a failed measurement – that is why the program checks isnan() and doesn't save such a measurement.
Data and privacy
Much data says something about people: photos, voices, messages, location. Before it is used for learning, people should know about it and agree. When you make a data set yourselves at school, don't use photos of other people without permission – record objects, not faces.
Activity: find the errors in the table
| # | mass (g) | color | shape | label |
|---|---|---|---|---|
| 1 | 140 | red | round | apple |
| 2 | 125 | yellow | long | orange |
| 3 | 16000 | green | round | apple |
| 4 | 190 | orange | round | orange |
| 5 | yellow | long | banana | |
| 6 | 140 | red | round | apple |
Solution
Row 2: yellow and long is a banana – a wrong label. Row 3: 16,000 g is impossible – probably an entry error (160 g). Row 5: the mass is missing. Row 6: it is the same as row 1 – maybe a duplicate (or the same was measured by chance; check it).
The class makes a table of 15–20 rows together. Then groups swap tables and look for errors and “gaps” (for example not a single green apple).
Common misconceptions
- “More data always solves the problem” – if the data is monotonous or wrongly labeled, more of the same errors doesn't help.
- “A computer is objective, so AI is always fair” – AI learns from data collected by people – and inherits their flaws.
Practice tasks
Try it yourself first, and only then open the solution.
- A table about students has the columns: height, shoe size, grade and “plays basketball” (yes/no). If a model should guess whether a student plays basketball, what are the features and what is the label?
- An app recognizes dogs, but it learned only from images of German shepherds. What will probably happen with a poodle? How would you fix it?
- Name three kinds of errors that can be found in data.
Solution 1: answer
Features: height, shoe size, grade. Label: “plays basketball” (yes/no).
Solution 2: answer
It will probably make a mistake or be unsure, because a poodle looks different from everything the model has seen. Solution: add images of dogs of different breeds, sizes and colors.
Solution 3: answer
A wrong label, an impossible value (an entry error), a missing value, a duplicate.
Check your knowledge
Open the quiz
Quiz: data
1. What is the label in a training table?
2. A model for recognizing dogs learned only from images of big dogs. What is this problem called?
3. Which value is probably an entry error for the mass of an apple?
4. What is important besides the amount of data?
