g↗genai/ learner
How Machines Learn / Lesson 01

Supervised learning

In supervised learning, a model—a program shaped by data—learns patterns from examples that come with supplied answers, then uses what it learned to predict answers on new cases, though not all machine learning works this way.

Concept + interactive labBeginner friendly

Learning from examples with known answers.

Think of studying with a stack of practice quizzes that come with an answer key. After checking enough questions against their answers, you are ready to tackle a new test that has no answer key attached.

Supervised learning works in a loosely similar way: a model learns from past examples that pair clues with supplied answers, then uses those patterns on new cases. It is only an analogy—a model does not read or understand questions like a student.

This lesson covers five ideas in order:

  1. Inputs: the clues supplied to a model when asking it for a guess.
  2. Target (or label): the recorded answer paired with each past example that we want the model to predict.
  3. Training: the step where the model learns patterns from past examples that include both inputs and targets.
  4. Prediction: the model’s estimate for the missing target on a new case (made at prediction time, when the model receives the supplied clues and makes its estimate).
  5. Other ML methods: why not all machine learning needs supplied labels.
Running example: Sam’s community inbox

Sam (an invented character for this lesson) helps manage a local community centre’s email inbox. Volunteers sorted past emails as Spam or Not spam so a learned filter can train on them.

For each past email in this small invented dataset, the filter checks three clues: Known sender? (whether the address is in the centre’s address book), Unknown link? (whether it links to an unrecognised website), and Urgent payment? (whether it demands immediate money or gift cards).

Past emailKnown sender?Unknown link?Urgent payment?Target
Email 1NoYesYesSpam
Email 2YesNoNoNot spam
Email 3NoYesNoSpam
Email 4YesNoNoNot spam
Email 5NoNoNoNot spam
Email 6NoYesYesSpam

Notice Email 5: an unknown sender with no suspicious link or payment demand was marked Not spam (a local parent asking about room hire). Learned spam filters typically train on far more than six emails, while some filters rely on hand-written rules instead.

Diagram titled Supervised learning with subtitle Learn from supplied answers, then predict on new cases. Top row flows left to right: Labeled past emails (Inputs + target) to Training to Trained model. Bottom row flows left to right: New email clues (Inputs only) to Trained model to Prediction (Spam or Not spam). Bottom cards show Analogy (Like practising with an answer key before taking a new test.) and Key takeaways (Training uses past clues paired with answers; New cases arrive with clues only; The trained model predicts the missing answer).
Training uses past clues paired with recorded answers; once trained, the model takes clues from a new case and outputs a prediction.

Telling inputs apart from targets.

In Lesson 1.3 you met features (clues) and labels (answers). In supervised learning, those same roles are often called inputs and the target.

Use one simple test to tell them apart: inputs are the clues supplied to the model at prediction time, while the target is the recorded answer you want the model to predict. Not every column in a table is an input—for instance, an email ID such as “Email 1” only identifies the row.

Predicting a category

Checking a bank-card charge as it happens to flag possible fraud.

Inputs: amount, country, time of day.

Target: Fraud or Legitimate recorded on past charges—the model outputs a prediction for each new charge (Lesson 4.3 covers how models turn scores into categories).

Predicting a number

Estimating a flat’s monthly rent before posting a listing.

Inputs: floor area, number of rooms, neighbourhood.

Target: monthly rent recorded in past listings—the model outputs a predicted rent for a new flat (Lesson 4.2 covers predicting numbers).

Diagram titled Inputs vs target with subtitle Clues go into the model; the prediction estimates the target. Flows left to right from Inputs (clues supplied) containing chips Known sender?, Unknown link?, and Urgent payment?, to Trained model (Learned from past clues + answers), to Prediction showing Spam or Not spam. Bottom cards show Analogy (Like checking symptoms before making a diagnosis.) and Key takeaways (Inputs are clues supplied at prediction time; The target is the answer to predict; A prediction is an estimate, not a guarantee).
At prediction time, the model—trained on past clues paired with recorded answers—receives only the inputs and outputs a prediction.

Walk through Sam’s spam filter.

Many supervised models learn by adjusting internal numbers during training. To keep this walk-through easy to inspect, the lab below uses a simpler example of supervised learning: nearest-match voting.

Here is the rule: compare a new email’s three clues to all six past emails, highlight every past email tied for the highest number of matching clues, let each highlighted past email cast one vote for its own recorded target (Spam or Not spam), and predict whichever category gets more votes. Each separate row gets one vote, even when two rows share identical clues.

Worked trace: a new neighbour asks about opening hours

A new neighbour emails asking when the centre opens on Saturday, with clues Known sender: No, Unknown link: No, Urgent payment: No. Email 5 matches all 3 clues (every other past email matches at most 2), so Email 5 casts the sole vote for its recorded target and the filter predicts Not spam.

  1. Start on 1. Spot inputs & target and pick the target for Sam’s spam filter, then try the apartment rent and parcel delivery tasks.
  2. Switch to 2. Trace a new email and compare New neighbour asking hours with Fake urgent invoice.
  3. Click Club newsletter with unfamiliar link and notice how a 2–1 vote produces an estimate even when past examples disagree.
  4. Toggle individual clues yourself, then click Reset walk-through to start fresh.
Choose a task:

Prediction time: as each new email arrives in Sam's inbox, the filter must decide whether to move it to the junk folder or keep it in the inbox. The filter supplies the three arrival clues to the model. Which item is the target?

Select one item above to check whether it is the target or an input.

Does all machine learning need labels?

No. Supervised learning is widely used, so it is easy to assume every machine learning system needs a supplied answer key—but it is only one family of learning methods.

Different methods are distinguished by their training signal—the kind of feedback or target the model learns from:

Supervised learning

Learns from examples paired with supplied answers, whether written by people or recorded from past outcomes (like whether a parcel arrived late).

Unsupervised learning

Looks for patterns or groups in inputs without supplied answers, such as grouping customers with similar habits (Lesson 4.4).

Self-supervised learning

Derives its own targets directly from the data itself—for example, hiding part of a sentence and training the model to predict it (Lesson 4.5).

Reinforcement learning

Learns which actions to take from reward or penalty feedback over time rather than a table of supplied answers (Lesson 4.6).

Diagram titled Not all ML needs labels with subtitle Different learning methods get their training signal in different ways. Left card shows Supervised learning (Examples + supplied answers). Right card shows Other ML methods with three mini-cards: Unsupervised (No supplied answers), Self-supervised (Targets from data itself), and Reinforcement (Reward feedback). Bottom cards show Analogy (Like studying with an answer key vs exploring or trial and error.) and Key takeaways (Supervised learning uses supplied answers; Other methods learn without supplied answer keys; Match the method to the signal you have).
Supervised learning uses supplied answers, while unsupervised, self-supervised, and reinforcement learning learn from other kinds of training signals.

What supervised learning depends on.

Even when you have labeled examples, data quality strongly affects how reliable a supervised model can be.

  • Label quality matters: if past emails were mislabeled by mistake, the model can learn misleading patterns.
  • Unseen patterns can fool it: if scammers invent a tactic that never appeared in past examples, the filter may miss it.
  • Predictions are estimates, not guarantees: a filter can still send a real message to spam or let spam slip through.
  • Does “supervised” mean a person checks every prediction live?

    No. “Supervised” refers to the supplied answers used during training, not a human approving every prediction afterward.

  • Can a target be a number instead of a category?

    Yes. When trained on examples with supplied answers, supervised learning can predict either a number (such as monthly rent) or a category (such as Spam or Not spam).

  • What if I have lots of data, but no one labeled it?

    You can still use machine learning—methods such as unsupervised learning and self-supervised learning do not require supplied answer keys for every example.

✎ Try it yourselfKnowledge check · Practice only

Check your understanding.

A neighbourhood clinic trained a model on past appointment records that paired booking details with the recorded outcome, Missed appointment (yes or no). One day before each upcoming appointment, the clinic supplies three clues to the model—Days booked in advance, Appointment time of day, and Text-message (SMS) reminder already sent at prediction time (yes or no)—to predict whether the patient will fail to show up. Which statement is right?

Take this with you.

Supervised learning learns from supplied answers. During training, the model sees inputs (clues supplied at prediction time) paired with a known target (the answer to predict). On a new case, it takes inputs alone and outputs a prediction—and remember that not all machine learning needs labels.

Ready to continue? Return to How Machines Learn.