Gradient LabStart the lesson

Lessons › Chapter 1: Foundations

Types of learning

Every example comes with the right answer (its color here). The model learns a rule that separates the classes, like the dashed boundary. Spam filters and price predictors work this way.

Watch it move. This lesson is interactive on Gradient Lab: every step is an animated scene you can replay.

Start the interactive lesson

Step by step

Story

Ideas on a whiteboard

The team brainstorms projects: spot fraud from labeled cases, group customers with no labels at all, and maybe an app that learns from feedback.

Concept

Supervised learning

Every example comes with the right answer (its color here). The model learns a rule that separates the classes, like the dashed boundary. Spam filters and price predictors work this way.

Concept

Unsupervised learning

Now remove the labels. All we have are points. Can the computer still find structure in them?

Build

It finds groups on its own

Clustering pulls similar points together. Nobody told it what the groups mean. It just noticed they are close. Customer segments and topic discovery work like this.

Concept

Reinforcement learning

An agent acts in a world and gets rewards: +1 for reaching the goal, −1 for falling in a pit. There are no answer labels, only feedback after acting.

Build

It learns a strategy

After many tries the agent learns a policy: which move to make in each square. Here it has learned to walk around the pits. Game-playing AIs and robot control work this way.

Large language models use a fourth flavor, self-supervised learning: they hide the next word and learn to predict it.

Real life

In real life: three everyday examples

Supervised: your spam filter, trained on emails marked “spam” or “not spam”. Unsupervised: a shop grouping its customers by how they shop, with no labels given. Reinforcement: a robot vacuum learning a good route around your furniture from what works.

Quick check: Grouping customers by shopping habits, with no labels, is…

There are no answers to learn from, only structure to discover. That is unsupervised learning.

Pseudocode

# Supervised: examples come with answers
model.learn(examples, answers)

# Unsupervised: no answers, find groups
groups = find_groups(examples, how_many = 3)

# Reinforcement: try things, collect rewards
move = agent.choose_move(where_am_i)
where_am_i, reward = world.do(move)
agent.learn_from(reward)

Key terms

agent
In reinforcement learning, the learner that takes actions in a world.
reward
A score the world gives after an action: good moves earn more.
policy
The strategy an agent has learned: which move to make in each situation.