Skip to main content

Forms of machine learning

Why This Matters

The form of machine learning decides what “correct” means, and so how you test it. A supervised model can be checked against labelled answers. A clustering model has no answers to check against. A reinforcement learning agent is only as good as the reward it was given. Knowing which form you are testing tells you which oracle you have.

What you will learn

  • The three forms of machine learning: supervised, unsupervised and reinforcement learning
  • The task types within them: classification, ML regression, clustering and association
  • What each form means for testing

Syllabus: AI-3.1.1.

Supervised learning

Supervised learning learns from labelled data: every training example comes with the right answer. The model learns to map inputs to outputs, and is then used on new inputs. The loan data from this course is labelled: every application has approved Yes or No.

There are two kinds of supervised task:

  • Classification: the output is a class from a fixed set. Spam or not spam; approve or reject; which of 1,000 objects is in this photo. Two classes is binary classification, more is multi-class.
  • ML regression: the output is a number on a continuous scale. The price of a house, someone’s age estimated from a photo, tomorrow’s stock price, the delivery time of a parcel.

Careful with the word regression. In other ISTQB syllabi it means a defect introduced by a change (and regression testing finds it). In ML it means predicting a number. The syllabus says ML regression to avoid confusion; the exam does too.

For testers: supervised learning gives you an oracle, the labels, so you can measure performance with metrics (module 4). The quality of those labels is now part of the quality of the system (lesson 39).

Unsupervised learning

Unsupervised learning works on unlabelled data and finds structure in it by itself.

  • Clustering groups similar items. Customer segmentation: the model finds five groups of customers with similar buying behaviour, without being told what the groups are.
  • Association finds which attributes occur together. People who buy pasta and tomatoes often buy parmesan: the basis of “customers also bought” recommendations.

For testers: there is no label to compare with, so there is no simple “correct”. You test whether the result is useful and stable: do domain experts recognise the clusters? Do the same clusters come out when you run it again, or on a different sample? Are the associations plausible, or artefacts of how the data was collected?

Reinforcement learning

In reinforcement learning an agent acts in an environment and learns from rewards and penalties. Nobody tells it the right action; it tries, sees what happens, and over many attempts learns a strategy that collects the most reward. Applications: robotics, autonomous vehicles, game playing, chatbots that adapt to users.

The syllabus names three challenges:

  • Setting up the environment: training in the real world is slow and dangerous, so agents are usually trained in a simulation, and a simulation is never quite the real world.
  • Designing the reward function: the agent optimises exactly what you reward, which may not be what you meant. Reward a cleaning robot for “no visible dirt” and it may learn to cover the dirt.
  • Choosing a strategy: how much to try new actions (exploration) versus repeat what worked (exploitation).

For testers: test the reward function as if it were a specification, because it is one. Look for reward hacking: behaviour that scores well but is not what was intended (lesson 42). And test in conditions the simulation did not cover.

Summary

FormDataTypical tasksOracle for testing
SupervisedLabelledClassification, ML regressionThe labels
UnsupervisedUnlabelledClustering, associationExpert judgement, stability, usefulness
ReinforcementRewards from an environmentControl, strategyThe reward, and whether behaviour matches intent

Exercise

Which form of ML, and which task type, fits each problem?

  1. Predict the number of days a patient will stay in hospital
  2. Decide whether a bank transaction is fraudulent, from past transactions marked as fraud or not
  3. Group news articles by topic, without predefined topics
  4. Teach a robot arm to pick up objects of different shapes
  5. Suggest a film because people who watched film A often watched film B
  6. Recognise which of 26 letters a handwritten character is
Show suggested answer
  1. Supervised, ML regression (a number).
  2. Supervised, classification (binary: fraud or not).
  3. Unsupervised, clustering.
  4. Reinforcement learning (reward for a successful grip).
  5. Unsupervised, association.
  6. Supervised, classification (multi-class).

Exam-style questions

Quiz

1. A model estimates a person’s age from a photo. Which form of ML is this?

  • A. Supervised learning, classification
  • B. Supervised learning, ML regression
  • C. Unsupervised learning, clustering
  • D. Reinforcement learning
Show answer
B. Age is a continuous value, learned from labelled photos.
Quiz

2. A retailer wants to divide its customers into groups with similar behaviour, without defining the groups in advance. Which approach fits?

  • A. Classification
  • B. ML regression
  • C. Clustering
  • D. Reinforcement learning
Show answer
C. Unlabelled data, grouped by similarity.
Quiz

3. Which is a challenge specific to reinforcement learning?

  • A. Labelling the training data
  • B. Designing the reward function
  • C. Choosing the number of clusters
  • D. Calculating precision and recall
Show answer
B. The syllabus names environment setup, reward function design and strategy selection as RL challenges.