Understanding AI · lesson 5 of 60 · about 5 minutes
Examples and Labels
AI learns from data. Find out what data looks like: examples, the details about them, and the right answers.
What you'll learn
- Describe data as a set of examples
- Name the features of an example
- Explain what a label is
Examples
To learn to tell apples from oranges, AI needs examples: lots of real fruit, each described the same way.
The details we describe each example with are called features: weight, colour, how bumpy the skin is.
Labels: the right answers
For each example in training, we also give the right answer: apple or orange. That answer is called the label.
Features plus labels, for thousands of examples, is the data AI learns from.
One example as a Python dictionary: each feature has a name and a value. The label is the right answer.
fruit = {"weight": 150, "colour": "red", "bumpy": False, "label": "apple"}
print(fruit["weight"])
print(fruit["label"])Output
150
appleTip
fruit["weight"] reads the value stored under the name weight.
Now try it yourself
This lesson is free in Codiqo, with 6 questions on what you just read. You can only learn to code by writing code, so it ends with a short program you write yourself, which we run and check straight away.