Computer Science · A4.1 · SL and HL

Types of machine learning

Machine learning is new in the core of the Computer Science guide that has its first exams in May 2027, so there are almost no past papers for it yet. Most questions on this part give a scenario and ask which type of learning fits. Naming the type earns one mark and the clue in the scenario that proves it earns the other.

Written from the stage “Types of machine learning” of the 7Quest Computer Science course. The questions are our own, in the style of the exam; none are from past papers.

What machine learning is

Machine learning is a branch of artificial intelligence in which a system learns patterns from data in order to make predictions or decisions, instead of following rules written by a programmer. In traditional programming you supply rules and data and get answers; in machine learning you supply data (often with the known answers) and the algorithm produces the model, a function with fitted parameters that turns an input into a prediction.

A few words come up in every question. Features are the input variables that describe each example, such as the number of links in an email. A label is the known correct answer for a training example, such as “spam”. Training fits the model to data, and inference uses the trained model on new data.

Supervised learning: classification and regression

In supervised learning the model is trained on labelled data: every example comes with the correct answer, and the model learns the relationship between the features and the label. It does two kinds of task. Classification predicts a category, such as whether an email is spam or which digit an image shows. Regression predicts a continuous number, such as a house price or tomorrow’s temperature.

The output decides which one it is, not the topic. Predicting “hot, mild or cold” is classification; predicting 23.4 °C is regression.

Unsupervised and reinforcement learning

In unsupervised learning the data has no labels, and the algorithm finds structure on its own. Clustering puts similar examples into groups, for example segmenting customers by shopping habits or flagging behaviour that fits no group. Association rules find items that often appear together, as in market basket analysis: people who buy pasta and tomatoes tend to buy cheese.

In reinforcement learning an agent learns by trial and error in an environment. In each state it chooses an action, the environment changes and returns a reward, positive or negative, and the agent learns a policy that maximises the cumulative reward over time. It has to balance exploring new actions with exploiting the ones it already knows work. AlphaGo Zero learned Go from games against itself, and robots that learn to walk by trial and error work the same way.

Deep learning and transfer learning

Deep learning uses artificial neural networks with many hidden layers. Each neuron combines its inputs with weights that are adjusted during training; early layers pick out simple features, such as edges in an image, and later layers combine them into complex ones, such as faces. The network learns its features from raw data, which is its main advantage, but it needs a lot of data and computing power and is hard to explain.

Transfer learning takes a model already trained on a large general task, for example millions of photos of everything, and fine-tunes it on a much smaller dataset for a related task, such as a few thousand photos of skin lesions. It needs far less labelled data, time and energy, which puts machine learning within reach of a hospital or a small company. The model also inherits the biases of the original data, and it helps little when the new task is very different. How the specific algorithms work (k-NN, decision trees, clustering, neural networks) is in the HL part of the syllabus.

Where the marks go

  • Naming the type without a reason. “Supervised, because the historical data records whether each loan was repaid, which is the label” earns both marks.
  • Deciding classification or regression from the subject of the problem. Look at the output: a category or a number.
  • Calling any program that “learns from experience” supervised. If it learns from rewards for its own actions, it is reinforcement learning.
  • Saying unsupervised learning is told which groups to find. It is not; nobody gives it the categories.

Three questions to try

Answer on paper first, then open the markscheme and mark yourself honestly. A mark only counts if your answer says that point.

Identify6 marksPaper 1 style

For each scenario, identify the type of machine learning that is most suitable and justify your choice.
(a) A bank wants to predict the price a house will sell for, using records of 50,000 past sales with their selling prices. [2]
(b) A music app wants to find groups of listeners with similar habits, without deciding the groups in advance. [2]
(c) A warehouse robot improves its route through the aisles by receiving points for fast deliveries and losing points for collisions. [2]

Show the markscheme

Markscheme (6 marks)

  1. (a) Supervised learning (regression) [1]
  2. (a) The past sales are labelled with the selling price, and the output is a continuous number [1]
  3. (b) Unsupervised learning (clustering) [1]
  4. (b) The data has no labels; the algorithm finds the groups itself [1]
  5. (c) Reinforcement learning [1]
  6. (c) The robot (agent) learns by trial and error from rewards and penalties for its actions, to maximise its total reward [1]

A full-marks answer

(a) Supervised learning, specifically regression. Each of the past sales is a labelled example, because its selling price is known, and the model has to predict a continuous value, the price of a new house.
(b) Unsupervised learning, specifically clustering. The listening data has no labels and the app has not decided the groups in advance, so the algorithm must find clusters of similar listeners on its own.
(c) Reinforcement learning. The robot is an agent acting in an environment: it tries routes, gets a positive reward for fast deliveries and a negative one for collisions, and learns a policy that maximises its cumulative reward.

Distinguish4 marksPaper 1 style

A hospital wants to detect a rare eye disease from retinal photographs. It has 3,000 photographs labelled by specialists.
(a) Distinguish between classification and regression, using this scenario. [2]
(b) Explain one advantage and one disadvantage of using transfer learning for this task. [2]

Show the markscheme

Markscheme (4 marks)

  1. (a) Classification predicts a category: here, whether a photograph shows the disease or not [1]
  2. (a) Regression predicts a continuous value, e.g. a measurement such as the thickness of the retina in micrometres [1]
  3. (b) Advantage: a model pre-trained on millions of general images needs far fewer labelled examples, so 3,000 photographs can be enough (and training is cheaper and faster) [1]
  4. (b) Disadvantage: the model inherits biases from its original training data, or medical images differ enough from everyday photos that some of what it learned is of little use [1]

A full-marks answer

(a) Classification predicts which category an input belongs to. Deciding whether a retinal photograph shows the disease (yes or no) is classification. Regression predicts a continuous number instead, so estimating a quantity such as the thickness of the retina from the same photograph would be regression.
(b) Transfer learning starts from a model already trained on millions of general images, which has learned useful features such as edges and textures. Fine-tuning it needs far fewer labelled examples, so the hospital’s 3,000 photographs may be enough, and training costs less. On the other hand the model carries over any biases in its original data, and retinal photographs are very different from everyday photos, so the features it learned may transfer only partly and its accuracy has to be checked carefully.

Explain3 marksPaper 1 style

A program learns to play a board game by playing thousands of games against itself. Explain the trade-off between exploration and exploitation for this program.

Show the markscheme

Markscheme (3 marks)

  1. Exploitation: choosing the moves the agent already knows give a high reward [1]
  2. Exploration: trying new or less-tested moves that might turn out to be better [1]
  3. Too much exploitation can leave it stuck with a good but not the best strategy; too much exploration wastes games on poor moves, so it has to balance the two (e.g. explore more early in training) [1]

A full-marks answer

When the program exploits, it plays the moves it has already learned give a high reward, which wins games now. When it explores, it tries moves it has not tested much, which might be worse but might also lead to a better strategy it would never otherwise find. If it only exploits, it can settle on a strategy that is good but not the best; if it explores too much, it wastes many games on poor moves and learns slowly. So it balances the two, usually exploring more at the start of training and exploiting more as its policy improves.

Where this is in 7Quest

It is in Synthetic Mind, the part of the Computer Science map for Machine learning:

  • Types of machine learningSyllabus A4.1.1 · 3 exam-style questions

Each stage has a short lesson, quick questions, a minigame and exam-style questions marked point by point, and what you get wrong comes back in your review a few days later. If this is the topic you find hardest, you can choose Machine learning as your free Computer Science topic and do all of it without paying or giving a card. Full access is a subscription per subject that renews each September and stops after your final exams, so nothing is charged once you have finished (prices and details).

Questions students ask about this

Is machine learning in IB Computer Science only for HL?

No. The types of machine learning on this page are in the core for SL and HL. How specific algorithms work, such as linear regression, k-NN, decision trees, clustering and neural networks, is HL only.

When are the first exams for the new Computer Science guide?

May 2027. That is why there are very few past papers with machine learning questions, and why practice questions like the ones above are worth doing.

Do I need to write machine learning code?

Not for this part. The questions ask you to identify and justify the type of learning, and to discuss its use, not to implement it.