AI and the Future

Lesson 2 of 7

How Machines Learn

Unpack supervised, unsupervised, and reinforcement learning to see how computers learn from data and feedback.

🟢 Beginner 60 XP

Learn it

Have you ever trained a puppy using treats when it sits and gentle corrections when it misbehaves? Machine learning works in a very similar way! Instead of dog treats, computers use numbers and feedback loops to get better at tasks over time.

We feed a learning algorithm thousands of examples, like pictures of cats and dogs. At first, it makes random guesses. But every time it gets something wrong, it tweaks its internal maths until its predictions become remarkably accurate.

Key terms

Machine Learning
A branch of AI where systems automatically learn patterns from data to make predictions.
Supervised Learning
A learning method where algorithms train on data containing both inputs and correct output labels.
Unsupervised Learning
A method where algorithms find structure, grouping, or patterns in data without pre-existing labels.
Reinforcement Learning
A goal-oriented learning framework where an agent takes actions in an environment to maximise rewards.

The Training Pipeline

Step through the stages data scientists follow to train an effective machine learning model.

  1. 1Data Collection: Gather thousands of relevant, high-quality samples such as photos, audio recordings, or sensor logs.
  2. 2Data Cleaning and Labelling: Remove corrupt data and tag each sample with correct labels, such as marking emails as spam or inbox.
  3. 3Model Training: Feed the training dataset into the algorithm, allowing it to adjust its weights and reduce prediction errors.
  4. 4Evaluation and Testing: Test the trained model on unseen test data to verify that it generalises well to new situations.
  5. 5Deployment: Integrate the finalised model into an app or website so users can receive instant predictions.

Supervised Learning Concept in Python

python# Simplified example of training data with labelled features
# Features: [has_fur (1/0), weight_in_kg]
training_data = [
    ([1, 4.5], 'Cat'),
    ([1, 25.0], 'Dog'),
    ([0, 0.2], 'Parrot'),
    ([1, 30.0], 'Dog')
]

new_animal = [1, 5.0]
print('New sample features:', new_animal)
# A trained classifier would predict 'Cat' based on nearest feature weights

Supervised models inspect labelled feature pairs (e.g. fur presence and weight) to establish mathematical decision boundaries that classify new, unseen entries.

Try it

Arrange the machine learning pipeline steps into the correct chronological order.

  • 1Collect raw dataset samples
  • 2Evaluate model accuracy on unseen test data
  • 3Label and clean the data
  • 4Deploy the model into a live application
  • 5Train the algorithm on training data

Challenge

Design a Reinforcement Learning scenario for teaching a virtual robot how to navigate a maze. Define what actions it can take, what grants a positive reward, and what triggers a penalty.

Pick whichever way suits you — every mode earns the same bonus XP.

Write at least 40 more characters to submit.

Mark your own work

Guided walkthrough — 0/5 clues revealed

  1. Clue 1 locked — reveal it only if you get stuck.
  2. Clue 2 locked — reveal it only if you get stuck.
  3. Clue 3 locked — reveal it only if you get stuck.
  4. Clue 4 locked — reveal it only if you get stuck.
  5. Clue 5 locked — reveal it only if you get stuck.

Each clue costs 3 XP (never below 15 XP). You'd earn 30 XP right now.

Extension: How would you prevent the robot from simply spinning in circles in place to avoid hitting obstacles?

Quiz time

Question 1 of 4Score 0

In supervised learning, what does the training data always include?