Computer Science · A4

Machine learning

How machines learn, what hardware they need and what ethical dilemmas they raise. In 7Quest it is Synthetic Mind: 10 stages, 112 quick questions and 29 exam-style ones.

What the stages cover

Codes follow the 2027 guide (A1–A4 and B1–B4). HL-only stages are marked. Each stage is a short lesson, quick questions, a minigame and an exam-style question.

  1. Types of machine learning
    Identify whether a problem calls for supervised, unsupervised, reinforcement, deep or transfer learning, and justify it with real examples.
    Syllabus A4.1.1
  2. Hardware for machine learning
    Choose and justify suitable hardware (CPU, GPU, TPU, ASIC, FPGA, cloud, HPC or edge) for training or using a model in a given scenario.
    Syllabus A4.1.2
  3. Preparing data for machine learningHL
    Describe how data cleaning, feature selection and dimensionality reduction make a dataset fit for training.
    Syllabus A4.2.1, A4.2.2, A4.2.3
  4. Linear regression and classificationHL
    Explain how linear regression predicts continuous values and how k-NN and decision trees predict categories from labelled data.
    Syllabus A4.3.1, A4.3.2
  5. Hyperparameters and model selectionHL
    Explain how evaluation metrics, hyperparameter tuning and cross-validation are used to avoid overfitting and to choose and compare models.
    Syllabus A4.3.3, A4.3.10
  6. Clustering and association rulesHL
    Describe how k-means groups unlabelled data, choose k with the elbow method, and calculate and interpret support, confidence and lift for association rules.
    Syllabus A4.3.4, A4.3.5
  7. Reinforcement learning and genetic algorithmsHL
    Describe how an agent learns a policy that maximises cumulative reward, explain the exploration–exploitation trade-off, and describe how a genetic algorithm evolves solutions to real optimisation problems.
    Syllabus A4.3.6, A4.3.7
  8. Artificial and convolutional neural networksHL
    Sketch and explain a perceptron and a multi-layer perceptron, outline how a network is trained, and describe how a CNN uses convolution, pooling and fully connected layers to learn a hierarchy of image features.
    Syllabus A4.3.8, A4.3.9
  9. Ethics of machine learning
    Analyse the bias, accountability, transparency, privacy, consent, security, environmental and social impact of ML in real cases, and write level-7 “Discuss/Evaluate” answers.
    Syllabus A4.4.1
  10. A society that depends on machines
    Discuss, with balanced arguments and a reasoned conclusion, the digital divide, surveillance, anonymity, autonomy and dependence that come with the growing use of computer systems and AI.
    Syllabus A4.4.2

Two questions to try

Written for 7Quest in the style of the exam, not taken from past papers. Answer first, then open the markscheme.

Explain3 marksHardware for machine learning

Explain why graphics processing units (GPUs) are more suitable than central processing units (CPUs) for training deep neural networks.

Show the markscheme

Markscheme (3 marks)

  1. Training a deep network consists mainly of matrix multiplications / many identical, independent operations.
  2. A GPU has thousands of simple cores that perform the same operation on lots of data in parallel, whereas a CPU has a few cores optimised for sequential/varied tasks.
  3. Therefore the GPU processes far more operations per second (and has high-bandwidth memory), reducing training time from weeks to hours/days.

A full-marks answer

Training a deep neural network consists mostly of multiplying huge matrices, that is, repeating millions of identical operations that are independent of one another. A GPU has thousands of simple cores that can apply the same operation to lots of data in parallel, whereas a CPU has a few powerful cores designed for varied, sequential tasks. As a result, together with its high-bandwidth memory, the GPU performs far more operations per second and drastically reduces training time.

Justify9 marksHLChallengeHyperparameters and model selection

A hospital compares two models that screen X-rays for a rare lung disease. Each is tested on the same 1,000 patients, 50 of whom have the disease. The positive class is “has the disease”.

(a) Calculate the accuracy of each model. [2]

(b) Calculate the precision and the recall of model A. [2]

(c) Explain why accuracy is a misleading measure for comparing these models. [2]

(d) Justify which of the two models the hospital should use for screening. [3]

ModelTPFNFPTN
A401030920
B25255945
Show the markscheme

Markscheme (9 marks)

  1. (a) Accuracy of A =(40+920)/1000=0.96= (40 + 920) / 1000 = 0.96.
  2. (a) Accuracy of B =(25+945)/1000=0.97= (25 + 945) / 1000 = 0.97.
  3. (b) Precision of A =40/(40+30)≈0.571= 40 / (40 + 30) \approx 0.571.
  4. (b) Recall of A =40/(40+10)=0.8= 40 / (40 + 10) = 0.8.
  5. (c) The classes are imbalanced: 95% of patients are healthy, so a model can score high accuracy by predicting “healthy” for most cases…
  6. (c) …while missing many sick patients; accuracy hides the false negatives (B is more accurate yet finds only half of the cases).
  7. (d) Model A should be chosen.
  8. (d) A has a much higher recall (0.8 against 0.5): it misses 10 sick patients rather than 25; a false negative (untreated disease) is the most serious error in screening.
  9. (d) A’s extra false positives (30 against 5) only lead to further tests, an acceptable cost; A also has the higher F1 (about 0.67 against 0.625). The threshold could be tuned further to raise A’s precision.

A full-marks answer

(a) Model A: (40+920)/1000=0.96(40 + 920) / 1000 = 0.96. Model B: (25+945)/1000=0.97(25 + 945) / 1000 = 0.97.
(b) Precision of A =40/70≈0.571= 40 / 70 \approx 0.571; recall of A =40/50=0.80= 40 / 50 = 0.80.
(c) Only 50 of the 1,000 patients are sick, so the classes are heavily imbalanced: a model that called almost everyone healthy would still score about 95%. Accuracy is dominated by the many true negatives and hides how many sick patients are missed: model B is the more accurate model, yet it detects only half of the cases.
(d) The hospital should use model A. In screening, a false negative means a sick patient goes untreated, which is far more serious than a false positive, which only leads to a further test. Model A has a recall of 0.80 against 0.50 for B, so it misses 10 patients instead of 25. Its 30 false positives (against 5) cost extra examinations, which is acceptable, and its F1 score is also higher, about 0.67 against 0.625 for B. The hospital could then tune model A’s decision threshold to reduce its false positives while keeping its recall high.

The other 27 questions in this topic are in the app, marked point by point, and anything you miss comes back in your review. If this is the topic you find hardest, you can make it your free topic and do all of it, with short practice tests on it, without paying or giving a card.

Start Computer Science free