MACHINE LEARNING • LESSON 2

Reinforcement Learning

Reinforcement Learning is a type of Machine Learning where an agent learns what to do by interacting with an environment, taking actions, and receiving rewards or penalties.

THE CORE IDEA

The agent learns by trying actions and learning from the results.

Unlike supervised learning, we do not give the agent the correct answer for every situation. Instead, the agent tries actions and receives feedback about whether those actions were useful.

01

What Is Reinforcement Learning?

Imagine you are teaching someone to play a game.

You don't necessarily tell them exactly what action to take at every moment. Instead, they try different actions and learn from the result.

If an action helps them, they receive a positive reward. If an action makes the situation worse, they receive a negative reward or penalty.

After many attempts, they can learn which actions tend to produce better results.

02

The Four Important Parts

Reinforcement learning becomes much easier to understand when you know four basic terms.

01 Agent

The learner that makes decisions.

02 Environment

The world or system the agent interacts with.

03 Action

Something the agent chooses to do.

04 Reward

Feedback showing how useful the action was.

03

The Basic Learning Loop

The agent repeatedly interacts with the environment.

AGENT Chooses an Action
ENVIRONMENT Responds
FEEDBACK Reward / Penalty

The agent uses this feedback to improve its future decisions.

LEARN FROM THE RESULT Try again with a better decision
04

Example: Teaching a Robot to Reach a Goal

Let's use a simple example.

Imagine a robot is placed inside a room. Its goal is to reach a target location.

The robot can move:

  • Left
  • Right
  • Forward
  • Backward

At the beginning, the robot does not know which sequence of movements is best.

05

The Robot Learns Through Trial and Error

Suppose the robot moves forward and gets closer to the target.

The system could give the robot a positive reward.

Now suppose the robot moves in the wrong direction and gets farther away from the target.

The system could give it a negative reward.

ACTION Move Toward Target

Robot gets closer.

Positive Reward
ACTION Move Away

Robot gets farther away.

Negative Reward

After many attempts, the robot can learn which actions are more likely to move it toward the goal.

06

It Is Not Just About One Action

A very important idea in reinforcement learning is that an action can affect what happens later.

For example, imagine a chess-playing agent.

A move might not immediately give the agent a reward. However, that move could create a strong position that helps it win the game several moves later.

Therefore, the agent needs to learn which actions produce good results over time, not just which actions give an immediate reward.

The goal is long-term success.

A good action is not always the action that gives the biggest immediate reward. Sometimes an agent needs to make a decision now because it will lead to better results later.

07

Example: Learning to Play a Game

Imagine an AI agent learning to play a simple game.

The agent can choose different actions during the game.

AGENT AI Player
ACTION Make a Move
ENVIRONMENT Game Changes
REWARD Win / Lose / Score

The agent can repeat this process many times and gradually learn strategies that produce better results.

08

Reinforcement Learning vs Supervised Learning

These two approaches are easy to confuse, but their learning process is different.

SUPERVISED LEARNING Learn From Known Answers

The training data contains examples with known labels.

Example: Predict whether an email is spam.

REINFORCEMENT LEARNING Learn From Feedback

The agent takes actions and receives rewards or penalties.

Example: Learn how to play a game.

In supervised learning, we can tell the model what the correct answer should be for each training example.

In reinforcement learning, we generally provide a reward signal and allow the agent to discover which actions lead to better outcomes.

09

What Does the Agent Actually Learn?

The agent learns a strategy for choosing actions.

This strategy is often called a policy.

You can think of a policy as the agent's decision-making strategy:

SITUATION What should I do now? POLICY Choose an Action

Through repeated interaction and feedback, the agent tries to improve this decision-making strategy.

10

Where Is Reinforcement Learning Used?

Reinforcement learning is useful when an agent needs to make decisions over time and its actions affect future outcomes.

  • Game-playing systems.
  • Robotics.
  • Some recommendation and decision systems.
  • Resource and control problems.

The important characteristic is not the industry. It is the learning setup: an agent takes actions, observes results, and learns from feedback.

11

Reinforcement Learning in One Picture

AGENT Makes a Decision
ACTION Does Something
ENVIRONMENT Responds
REWARD Learns From Feedback
KEY IDEA

Reinforcement Learning Learns Through Actions and Feedback.

An agent interacts with an environment, takes actions, receives rewards or penalties, and uses that feedback to improve its future decisions.

QUICK CHECK

Can You Identify Reinforcement Learning?

An AI agent is learning to play a game. It tries different moves. When it wins, it receives a high reward. When it loses, it receives a negative reward.

After playing many games, the agent changes its behavior to improve its chances of winning.

Answer

This is reinforcement learning.

The agent is learning through interaction with the environment and using rewards as feedback.

It is not being given the correct move for every situation. It has to discover better actions through experience.

NEXT TOPIC

Supervised vs Unsupervised Learning

We have now seen supervised, unsupervised, and reinforcement learning. Next, we will compare the two most common approaches and clearly understand when supervised and unsupervised learning are used.