Skip to main content
Machine Learning & Deep Learning

⏱ About 10 min10 XP

Learning From Examples

How did you learn what a dog looks like? Nobody handed you a rulebook that said: four legs, fur, tail, barks. You just saw dogs — at the park, in books, in cartoons — over and over. Your brain soaked up all those examples and built a picture of what a dog is. Machines can learn the same way! Today we will find out how showing a machine lots of examples teaches it to recognize things in the world.

Examples Are a Machine's Teachers

When scientists want to teach a machine to recognize cats, they do not write a list of cat rules. Instead they collect thousands — sometimes millions — of photos of cats. Each photo has a label attached to it. The label says: this is a cat. The machine looks at all those labeled photos. It searches for patterns. What do cats usually have? Pointy ears. Whiskers. A certain shape of face. The machine does not see those features the way you do. It sees numbers that represent colors and shapes. But it finds patterns in those numbers. After studying enough examples, the machine can look at a brand-new photo it has never seen before and say: yes, that is a cat, or no, that is not.

The Big Idea

Examples are how a machine learns. Each example is like one page in a giant textbook. The more pages the machine studies, the better it understands the subject.

Labels matter just as much as examples. Imagine you are learning what an apple is, but every time someone shows you an apple they call it a banana by mistake. You would get very confused! The same thing happens with machines. If a photo of a cat is labeled dog by mistake, the machine learns something wrong. That is why scientists are very careful to make sure their examples are labeled correctly. A good example has two things: the picture (or data), and the correct label. Together they are called labeled data. Labeled data is the food that a learning machine eats.

Match each part of learning from examples to what it means.

Terms

Example
Label
Labeled data
Pattern
Training

Definitions

The process of a machine studying labeled examples to get better
One piece of data the machine studies, like a single photo
The correct answer attached to an example, like the word cat
A feature that shows up again and again across many examples
A collection of examples that each have correct answers attached

Drag terms onto their definitions, or click a term then click a definition to match.

Let us look at a real example of this process. A team of scientists wanted a machine to tell spam emails from real emails. They collected ten thousand old emails. They labeled each one: spam or not spam. The machine studied all ten thousand labeled emails. It found patterns: spam emails often had words like win and free and urgent. Real emails from friends had different words and styles. After studying the examples, the machine could look at a new email and make a good guess: spam or not spam. The scientists did not write a single spam rule. The machine found the patterns itself, from the examples.

Wrong Labels Cause Wrong Learning

If the examples have wrong labels, the machine will learn the wrong thing. Getting labels right is one of the most important jobs in building a learning machine.

What is labeled data?

A scientist mislabels 500 photos of dogs as cats. What will most likely happen?

Build a Tiny Labeled Dataset

  1. You are going to make a small labeled dataset — just like scientists do!
  2. Find 10 objects around your home that belong to two groups (for example: kitchen things and bedroom things, or red things and blue things).
  3. On small slips of paper, write the name of each object and its label (which group it belongs to).
  4. Spread them out and count: how many examples are in each group? Is the dataset balanced?
  5. Now imagine you only had 2 examples total. Would a machine learn well from that? Talk about why more examples help a machine learn better.