Question bank › IB Computer Science › A4 Machine learning

Data preprocessing: cleaning, feature selection, dimensionality reduction (HL)

Answer on paper first, then reveal the mark scheme one mark at a time.

1CoreHL only6 marks

A clinic is preparing data to train a machine learning model that predicts a patient's risk of type 2 diabetes. An extract of the raw data is shown.

VisitIDAgeMass (kg)SmokerVisit dateReceptionist
V1013472.5Yes2026-03-14Ms Patel
V10251No2026-03-15Mr Okafor
V10324580.1No2026-03-15Ms Patel
V1042965.0Y16/03/2026Mr Okafor
V1056290.3No2026-03-17Ms Patel
V1056290.3No2026-03-17Ms Patel

(a) Identify four different data-quality problems in this extract. For each, refer to a specific record or field. [4]

(b) Explain why the Receptionist field should be removed before the model is trained. [2]

2StandardHL only6 marks

An estate agent is building a K-nearest neighbours (K-NN) model to estimate house prices. Two of the features are floor area (m²) and number of bedrooms. The floor areas in the training data are:

48, 65, 72, 90, 110, 160

The data is normalized using min–max scaling: $$x' = \frac{x - x_{\min}}{x_{\max} - x_{\min}}$$

(a) Calculate the normalized value of a floor area of 90 m². [2]

(b) Explain why the features should be normalized before the K-NN model is used. [2]

(c) A new house with a floor area of 175 m² is to be valued. Using the training minimum and maximum, calculate its normalized floor area and comment on the result. [2]

3CoreHL only5 marks

A fitness app records the resting heart rate (beats per minute) of five users:

58, 62, 64, 66, 70

Before training a model, this feature is standardized using $z = \frac{x - \mu}{\sigma}$, where $\mu$ is the mean and $\sigma$ is the standard deviation $\sigma = \sqrt{\frac{\sum (x-\mu)^2}{n}}$.

(a) Calculate the mean, $\mu$. [1]

(b) Calculate the standard deviation, $\sigma$. [1]

(c) Calculate the standardized value of 70. [1]

(d) Outline two differences between standardization and min–max normalization. [2]

Stuck on Data preprocessing: cleaning, feature selection, dimensionality reduction (HL)?

Get it sorted in a free 30-minute session

We work through your weakest questions on this topic on Zoom. I reply the same day.

4StandardHL only5 marks

A teacher collected data on hours of revision and test score for ten students to train a linear regression model. The scatter graph shows the data.

(a) Identify the outlier, giving its coordinates. [1]

(b) Describe the effect that keeping this outlier would have on the regression line. [2]

(c) Explain why the outlier should not automatically be deleted, and what the teacher should do instead. [2]

012345678910020406080100Hours of revisionTest score (%)
5StandardHL only6 marks

A bank is training a model to predict loan default. One field is annual income (£ thousand). Seven applicants have the following values, one of which is missing:

21, 24, 25, 27, 30, 180, missing

(a) Calculate the value that would replace the missing entry using (i) mean imputation and (ii) median imputation. [2]

(b) Justify which imputed value is more suitable for this data. [2]

(c) Describe one alternative way of handling missing data, other than imputation, and state one disadvantage of it. [2]

6StandardHL only6 marks

Feature selection reduces the number of input features used to train a model.

Describe how each of the following methods selects features.

(a) filter methods [2]

(b) wrapper methods [2]

(c) embedded methods [2]

7HardHL only6 marks

A filter method is used to select features for a model that predicts the sale price of a house. The correlation coefficient between each feature and the sale price is shown.

FeatureCorrelation with sale price, r
Floor area0.82
Number of rooms0.78
Distance to station−0.61
House number0.03
Day of week listed−0.05

The correlation between floor area and number of rooms is 0.93.

A feature is removed if $|r| < 0.2$.

(a) Identify the features that are removed. [1]

(b) Explain why distance to station is kept even though its correlation is negative. [1]

(c) Explain why one of floor area or number of rooms could also be removed, and state which one. [3]

(d) Outline one limitation of selecting features using correlation alone. [1]

8HardHL only6 marks

A wrapper method using forward selection is applied to four features A, B, C and D. It starts with no features. In each round it trains a model for every way of adding one more feature to the current set, then adds the feature that gives the highest validation accuracy. It stops when the best new model improves accuracy by less than 0.02 on the current set.

Features usedValidation accuracy
A0.71
B0.64
C0.69
D0.58
A, B0.74
A, C0.79
A, D0.72
A, B, C0.80
A, C, D0.78

(a) Trace the forward selection to find the final set of features. Show the accuracy after each round. [3]

(b) State the number of models trained during the search. [1]

(c) An exhaustive search would train a model for every non-empty subset of features. Calculate how many models this would need for 20 features, and hence explain why wrapper methods usually use a search strategy such as forward selection. [2]

9HardHL only6 marks

A classifier is trained on a fixed set of 200 examples. The graph shows its validation accuracy as more features are used.

(a) State the number of features that gives the highest validation accuracy. [1]

(b) Explain why the accuracy falls when more features are added beyond this point, even though more information is available. [3]

(c) Suppose the range of every feature is divided into 5 equal intervals, giving $5^d$ cells for $d$ features. Calculate the average number of training examples per cell when (i) 3 features and (ii) 8 features are used. [2]

0510152025300.50.60.70.80.9Number of features usedValidation accuracy
10StretchHL only6 marks

A school security system uses a machine learning model to recognise students' faces. Each image is a 64 × 64 pixel greyscale image, and each pixel is used as a separate input feature. The training set contains 1500 images.

Discuss the importance of applying dimensionality reduction to this data before training the model. [6]

Stuck on this topic?

Book a free 30-minute session on WhatsApp and we'll find exactly which step is costing you the marks. Or build a timed paper on it.

Free 30-minute session