Examhaus — Achieve with confidence.

IB Computer Science A4.3: Machine learning approaches (HL only)

New IB Computer Science syllabus · first exams May 2027 · Theme A · HL only

A4.3 is the largest sub-unit in A4. It covers the main algorithms, how to evaluate them, and the neural networks behind modern AI.

StatementTopicCommand term
A4.3.1Linear regressionExplain
A4.3.2Classification: K-NN and decision treesExplain
A4.3.3Hyperparameter tuning and evaluation metricsExplain
A4.3.4ClusteringDescribe
A4.3.5Association rule learningDescribe
A4.3.6Reinforcement learningDescribe
A4.3.7Genetic algorithmsDescribe
A4.3.8Artificial neural networksOutline
A4.3.9Convolutional neural networksDescribe
A4.3.10Model selection and comparisonExplain

Key points

A4.3.1 Linear regression

Fits a line ŷ = m·x + c to predict a continuous value.

  • The slope is the change in the prediction for each one-unit increase in x.
  • The intercept is the prediction when x = 0.
  • r² (0 to 1) shows how well the line fits the data.

A4.3.2 Classification

  • K-NN: finds the K closest labelled points and takes a majority vote. Example: collaborative filtering recommendations.
  • Decision trees: ask a sequence of yes/no questions about the features. Example: medical diagnosis from symptoms.

A4.3.3 Evaluation and hyperparameter tuning

  • Accuracy: the share of all predictions that were correct.
  • Precision: of the items flagged as positive, how many really were positive.
  • Recall: of the real positives, how many the model caught.
  • F1: a balance of precision and recall.
  • Hyperparameters, such as K or the depth of a tree, are set before training. Tuning them avoids overfitting (too closely fitted to the training data) and underfitting (too simple to capture the pattern).

A4.3.4–A4.3.5 Clustering and association rules

  • Clustering: groups unlabelled data by similarity. Example: segmenting customers from purchase data.
  • Association rules: find attributes that often occur together. Example: in crime analysis, areas with vandalism also tend to have theft.

A4.3.6 Reinforcement learning

An agent in a state takes an action and receives a reward, learning a policy that maximises cumulative reward. It must balance exploration (trying new actions) against exploitation (using what already works).

A4.3.7 Genetic algorithms

They evolve solutions through these stages:

  1. Population
  2. Fitness function
  3. Selection
  4. Crossover
  5. Mutation
  6. Evaluation
  7. Termination

Example: route planning, such as the travelling salesperson problem.

A4.3.8–A4.3.9 Neural networks

  • Perceptron: inputs × weights + bias → activation function → output.
  • Multi-layer perceptron (MLP): an input layer, one or more hidden layers, and an output layer.
  • CNN layers: input → convolutional layers (with kernel size and stride) → activation → pooling → fully connected → output. It learns spatial features in images.

A4.3.10 Model selection

Different algorithms suit different data and problems. Choose by the nature of the problem, its complexity and the outcome you need, and compare models fairly on the same data.


Exam-style question

Explain, with an example, how the K-Nearest Neighbours (K-NN) algorithm classifies new data points. [5]

Mark scheme

Award [1] for each point, up to [5]:

  • K-NN stores the whole labelled training dataset rather than building a separate model;
  • To classify a new point, it calculates the distance from that point to every training point;
  • It identifies the K closest training points (the nearest neighbours);
  • The new point is assigned the majority class among those K neighbours;
  • Example: a streaming service recommends content by finding users with the most similar viewing history;
  • Features should be scaled first, otherwise features with larger ranges dominate the distance;

Common mistakes that cost marks

  • Using linear regression for classification. It predicts continuous numbers, not categories.
  • Confusing parameters and hyperparameters. Parameters (such as weights and slope) are learned during training; hyperparameters (such as K and depth) are chosen beforehand.
  • Quoting only accuracy. For imbalanced data, such as disease screening, recall or precision matter more.

Frequently asked questions

Is A4.3 on the SL syllabus?
No. The whole of A4.3 is HL only.

Which classification algorithms do I need?
K-Nearest Neighbours (K-NN) and decision trees.


Go further