• Foundation
  • About 14 min
  • 5 practice questions

Types of machine learning: supervised, unsupervised and reinforcement

Tell supervised, unsupervised and reinforcement learning apart, and decide whether a supervised task is classification or regression.

If something looks wrong, please tell us.

Not every learning problem looks the same. Sometimes we have the correct answers for past examples, sometimes we have only raw data, and sometimes a program must learn by trying things and seeing what happens. These three situations give the three main types of machine learning. Exam questions often describe a situation and ask which type it is, so learn the clues for each.

Types of machine learning

  • Supervised learning
    • Every example has its correct label
    • Classification: the label is a category
    • Regression: the label is a number
  • Unsupervised learning
    • The data has no labels
    • Clustering: groups similar examples
    • Spotting unusual examples
    • Reducing many features to a few
  • Reinforcement learning
    • An agent acts in an environment
    • Learns from rewards or penalties
    • Trial and error builds a policy

1. Supervised learning: learning with answers

In supervised learning, every training example comes with its correct label, like a student practising with an answer key. The model learns to map features to labels. Supervised tasks come in two kinds, depending on what the label looks like.

  • Classification: the label is a category. Examples: spam or not spam; a handwritten digit 0 to 9; whether a loan will be repaid; which disease a leaf photo shows.
  • Regression: the label is a number on a continuous scale. Examples: the price of a flat; tomorrow's temperature; the expected yield of a wheat field in quintals.

Ask: is the answer a category or a quantity? Category = classification. Quantity = regression.

2. Unsupervised learning: finding structure without answers

In unsupervised learning, the data has no labels. The model looks for structure on its own. The most common task is clustering: putting similar examples into groups. A clothing shop may group its customers by how often they visit and how much they spend, without anyone deciding the groups in advance. The model finds, say, 'frequent small buyers', 'occasional big buyers' and 'festival-season shoppers', and the shop decides what each group means. Other unsupervised tasks include spotting unusual examples (such as an odd card transaction) and reducing many features to a few.

3. Reinforcement learning: learning by reward

In reinforcement learning, there is no fixed set of examples. An agent (the learner) takes actions in an environment and receives a reward (or penalty) after them. By trial and error it learns a policy, a way of choosing actions that earns the most reward over time. A program learning to play a board game is the classic case: winning gives a positive reward, losing a negative one, and over many games it discovers good moves. Robots learning to walk and systems that control traffic signals are other examples. The agent must balance exploration (trying new actions) with exploitation (repeating actions known to work).

How a reinforcement learning agent learns

  1. Agent takes an action In its environment: exploring new actions or repeating ones known to work.
  2. Reward or penalty Received after the action.
  3. Policy improves By trial and error it learns actions that earn the most reward over time.

Then back to step 1: Agent takes an action

The three main types at a glance
TypeData neededGoalExample
Supervised - classificationLabelled examples; label is a categoryPredict the categorySpam filter
Supervised - regressionLabelled examples; label is a numberPredict the quantityHouse price prediction
Unsupervised - clusteringUnlabelled examplesFind natural groupsCustomer groups
ReinforcementAn environment that gives rewardsLearn actions that maximise rewardGame-playing program

Some systems mix types. Semi-supervised learning uses a small labelled set together with a large unlabelled one, which helps when labelling is costly.

Worked example 1: naming the task

  1. A cooperative wants to predict how many litres of milk a farm will supply next month. The answer is a quantity, and past months have known answers, so this is supervised regression.
  2. A hospital wants to sort chest X-rays into 'normal' and 'needs review' using X-rays already marked by doctors. The answer is a category with labels available, so this is supervised classification.
  3. A streaming app wants to discover groups of viewers with similar tastes, with no groups defined beforehand. There are no labels, so this is unsupervised clustering.
  4. A delivery robot learns a route through a warehouse, earning points for quick deliveries and losing points for bumps. Learning comes from rewards, so this is reinforcement learning.

Worked example 2: reading a reinforcement setup

Suppose a game agent gets +10 for reaching the goal and −1 for every step taken. Route A reaches the goal in 4 steps; route B in 7 steps. Total reward for A = 10 − 4 = 6. Total reward for B = 10 − 7 = 3. Because the agent tries to maximise total reward, it learns to prefer route A, the shorter one. Notice how the designer's choice of reward shapes what the agent learns: the step penalty is what teaches it to hurry.

Key takeaways

  • Supervised = labelled data; classification predicts categories, regression predicts numbers.
  • Unsupervised = no labels; clustering finds groups of similar examples.
  • Reinforcement = an agent learns from rewards by acting in an environment.

Check your understanding

  1. 1. A model predicts the number of passengers who will board a train next Sunday, using past records. Which kind of task is this?

    1. Classification
    2. Clustering
    3. Reinforcement learning
    4. Regression
    Show answer

    Answer: D. The output is a quantity (a number of passengers) and past records give known answers, so it is supervised regression. Classification would predict a category; clustering and reinforcement do not use labelled answers in this way.

  2. 2. Which situation is an example of unsupervised learning?

    1. Grouping news articles by similar topics when no topics are given in advance
    2. Predicting exam marks from hours of study using past students' marks
    3. Marking emails as spam using emails already marked by users
    4. Teaching a program chess by rewarding wins
    Show answer

    Answer: A. Grouping articles with no predefined topics is clustering on unlabelled data, which is unsupervised. Predicting marks and marking spam use labelled examples (supervised), and rewarding wins is reinforcement learning.

  3. 3. In reinforcement learning, what is the 'agent'?

    1. The person who labels the data
    2. The learner that takes actions and receives rewards
    3. The test set
    4. The reward itself
    Show answer

    Answer: B. The agent is the learner. It acts in an environment, receives rewards or penalties and gradually learns a policy that earns the most reward.

  4. 4. A model decides whether a leaf photo shows 'healthy', 'rust' or 'blight', trained on photos labelled by experts. This is:

    1. Regression
    2. Reinforcement learning
    3. Classification
    4. Clustering
    Show answer

    Answer: C. The label is one of three categories and labelled examples are available, so this is supervised classification. Having more than two categories does not change that.

  5. 5. An agent earns +20 for finishing a maze and −2 for each step. How much total reward does it get if it finishes in 6 steps?

    1. 8
    2. 14
    3. 18
    4. 32
    Show answer

    Answer: A. Penalty = 6 × 2 = 12. Total reward = 20 − 12 = 8.

Privacy · Terms · Refunds · Delivery