30 exam-style questions on Data preprocessing — topic A4.2 of Machine learning in the IB Computer Science syllabus — with answers and explanations. Samples below; the full set is free with an account.
A column of patient weights has 150 empty entries out of 5000 records. Every empty entry is filled with the mean of the values that are present. Which statement about the effect on that column is correct?
Answer: The mean of the column is unchanged, but its spread is reduced.
Adding 150 copies of the mean cannot move the mean, but each copy sits at distance zero from it, so the standard deviation falls and the column looks more consistent than the measurements really were.
A nominal attribute holding the values 'petrol', 'diesel', 'hybrid' and 'electric' is replaced by the integers 1, 2, 3 and 4. Which problem does this create for the model?
Answer: The model treats the values as ordered and as equally spaced, which they are not.
Integers carry an order and a distance, so the encoding silently claims that electric is four times petrol and that hybrid lies between diesel and electric. One-hot encoding avoids the claim by giving every category its own binary column.
A k-nearest neighbours model uses two features: annual income, with values in the tens of thousands, and number of children, from 0 to 5. Why are the features scaled before training?
Answer: Without scaling the feature with the larger range dominates distance calculations.
Income runs into the tens of thousands while the second feature never passes 5, so any distance is decided almost entirely by income. Scaling is about comparability of ranges, not about removing records or creating independence.
A feature has a minimum of 20 and a maximum of 120 across the training set. Calculate the scaled value of an observation of 45 after min-max normalisation to the range 0 to 1.
Answer: 0.25
Min-max normalisation subtracts the minimum before dividing by the range, so (45 - 20) / (120 - 20) = 25 / 100 = 0.25. Dividing by the maximum alone gives 0.38 and ignores that the scale starts at 20 rather than 0.
An analyst scales every numerical column using the minimum and maximum of the complete dataset, and only afterwards separates the rows into a training set and a test set. Why is this poor practice?
Answer: Information from the test rows has shaped the training data, so the test score flatters the model.
The minimum and maximum are themselves quantities learned from the data, and taking them from all rows lets the test rows influence training. That is data leakage, and it makes the reported test score too optimistic.
A column of daily temperatures in degrees Celsius holds values between 18 and 34, apart from a single entry of 999 left by a faulty sensor. Which statement about that entry is correct?
Answer: The mean of the column rises noticeably while the median barely moves.
The mean adds every value, so one extreme entry drags it upwards, whereas the median only depends on the position of the middle value. That is why the median is the safer choice for filling gaps in a column that contains outliers.
That was 6 of 30 Data preprocessing questions.
Practise all 30 freeOutlineAO1 · 1–2 marks
A brief account or summary: the main points in two or three sentences, no evaluation.
DistinguishAO2 · 2–4 marks
Make the difference clear for BOTH terms — a definition of one of them is only half an answer.
ExplainAO2 · 2–4 marks
Give reasons or causes: say what happens AND why, linking each step with 'because' or 'so that'.
30 Data preprocessing questions — free with an account. Spaced repetition, streaks and full exam simulations included.
Practise them freeThis platform is independently developed and is not endorsed by, affiliated with, or sponsored by the International Baccalaureate Organization. “International Baccalaureate” and “IB” are registered trademarks of the IBO.