Skip to content
mentoor

Topic 1 of 5 · 3 min read

Learning a pattern from labelled examples

Goal: Describe how a model is trained from examples and labels, and identify the training data and the labels in a described system.

A model is not given rules. It is shown many examples with the right answers attached, and it adjusts itself until its guesses match those answers.

Check yourself · 1 of 3

A team trains a model to tell cats from dogs using 20,000 photos. Each photo has a tag, "cat" or "dog", added by a volunteer. What are the labels?

Choose one answer

Why it matters

When you know how a model was built, you know what it can and cannot do. A model has no opinions and no understanding of your job. It has a pattern that fitted the examples it saw. If your question looks like those examples, the answer is often good. If it does not, the answer can be badly wrong and still sound sure.

The parts

  1. Training data. The examples the model learns from. For a photo sorter, this is a large pile of photos.
  2. Labels. The right answer attached to each example. Each photo is tagged "cat", "dog" or "car" by a person or a trusted process.
  3. A model with adjustable settings. Inside are millions or billions of numbers, called weights. At the start they are random, so the first guesses are poor.
  4. A loop. The model guesses a label for a photo. The system compares the guess with the real label and measures the error. Then it nudges the weights a little so the same guess would be slightly less wrong. This repeats over the whole pile, many times.

After enough rounds, the weights hold a pattern: which shapes, colours and textures usually go with which label. Nobody wrote "cats have pointed ears". The model found a statistical link between pixels and the word "cat".

Training is a one-time, expensive job done by the company that builds the model. Using the finished model is cheap and quick.

Before and after

Before (a rule written by hand): If the photo has a round shape and orange colour, call it an orange. This fails on a pumpkin, a basketball and an orange seen in poor light.

After (learned from examples): Show the model 100,000 photos of oranges, pumpkins and basketballs, each labelled. It picks up many small clues together, such as skin texture, stem shape and the way light falls, and gets far more cases right than a short rule can.

What goes wrong

  • Wrong labels. If some "cat" photos are really dogs, the model learns a muddled pattern. It copies the mistakes in its labels.
  • Missing cases. A model trained only on daytime photos may fail at night, because it never saw one.
  • Pattern, not meaning. A model can learn a shortcut. If most "boat" photos have blue water, it may learn that blue means boat. A boat on a trailer in a driveway then confuses it.

Chat assistants such as ChatGPT, Claude and Gemini are trained in a similar spirit, with text instead of photos. The idea of learning a pattern from examples is the same, even though the details differ.

Examples

A spam filter

Training data: 50,000 emails. Labels: "spam" or "not spam", set by users who clicked the spam button. The model learns which words, senders and links tend to go with each label. A new email is then scored by how much it looks like past spam.

Spot the parts

A phone app sorts receipts into "food", "travel" and "office". Training data: thousands of scanned receipts. Labels: the category an accountant gave each one. Model: the settings that turn a receipt into a category guess.

Key points

  • A model learns by being shown many examples, not by being given rules.
  • Labels are the right answers attached to the examples, and the model is adjusted to match them.
  • The weights are the many numbers inside the model that change during training.
  • A model can learn a shortcut that fits the examples but fails in real use.
  • Mistakes in the labels or gaps in the examples become mistakes in the model.

Common mistakes

  • Thinking a person wrote rules inside the model for each case it handles.
  • Mixing up the data (the examples) with the labels (the right answers for them).
  • Assuming labels are always correct, when people and tools make labelling mistakes.
  • Believing a model that scores well on its examples will work on any new case.

Check yourself · 2 of 3

During training, a model guesses "dog" for a photo whose label is "cat". What happens next?

Choose one answer

Check yourself · 3 of 3

Most "boat" photos in a model's training set show blue water. What risk does this create?

Choose one answer

Practice items, not counted towards your mastery.

Start here