B2 · How Artificial Intelligence Works: Data and Learning

Learning from Examples

Learning from examples means discovering a pattern by looking at many cases where the right answer is known, then using that pattern to handle new cases. In AI this is called machine learning.

8 min Beginner Jump to the activity

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

Definition

How did you learn to recognise a mango? Did anyone give you a definition?

Learning from examples means discovering a pattern by looking at many cases where the right answer is known, then using that pattern to handle new cases. In AI this is called machine learning.

In simple words

Nobody gave you a rule like "a mango is oval, 10 to 15 cm long, green to yellow". You saw many mangoes and heard "mango" each time, and your brain found the pattern. A machine does something similar: we show it many labelled examples, and it adjusts itself until its answers match the labels.

Why it matters

Many tasks are too messy to write rules for: recognising faces, understanding speech, spotting spam. Learning from examples is how almost all of today's AI handles them.

How it works

  1. Collect many examples, each with the right answer (the label).
  2. Show them to the model, which makes a guess for each one.
  3. Compare each guess with the label and adjust the model to make fewer mistakes.
  4. Repeat until the guesses are mostly right.
  5. Use the model on new examples it has never seen.

Try it yourself

How a model learns “ripe mango”

No one tells it the rule. Watch it find one from examples.

Train a 'human model'

Play this with two or more people.

  1. One person, the teacher, secretly picks a rule, such as "words with two vowels".
  2. The teacher says words and labels each one YES or NO.
  3. The others, the model, listen and try to guess the label of each new word before it is told.
  4. Keep score. How many examples did the model need before it was usually right?

Think about it

  • Did the model ever guess the rule wrong but still get answers right?
  • What happened when the teacher used a tricky word?

What does the model need?

Which of these help a machine learn from examples?

  • Many examples

  • Labels that are often wrong

  • The right answer for each example

  • Examples that are all almost the same

  • Feedback on its mistakes

Common mistakes

  • Thinking the machine is given the rule. It works out the pattern itself.
  • Thinking a few examples are enough for a machine. It usually needs many.
  • Testing only on the examples it learned from. Real learning shows on new examples.

Check yourself

Question 1

1. What is a label?

Question 2

2. What does the model do with its mistakes?

Question 3

3. Where does real learning show?

Summary

  • Machines learn by finding patterns in labelled examples.
  • They guess, compare with the label, adjust and repeat.
  • Learning is proven on new examples, not old ones.

Finished reading?

Sources: Elements of AI (University of Helsinki)