Artificial Intelligence

Practice questions

A screening test is used on 1,000 people, of whom 50 are ill. It gives TP = 40, FN = 10, FP = 60 and TN = 890. What are its accuracy and recall?

  1. 80% and 40%
  2. 93% and 40%
  3. 89% and 80%
  4. 93% and 80%
Answer and explanation

Answer: D

Accuracy = (TP + TN) ÷ total = (40 + 890) ÷ 1,000 = 930 ÷ 1,000 = 93%. Recall = TP ÷ (TP + FN) = 40 ÷ 50 = 80%. (Precision would be 40 ÷ (40 + 60) = 40%, a different measure.)

A team tries k = 1, 3, 5 and 7 for k-NN and must pick one. Which approach is correct?

  1. Pick by test-set score, because the test set gives the most honest score
  2. Pick by training-set score; k = 1 scores best there, so choose it
  3. Any choice is fine, because k is learned automatically during training
  4. Pick by validation-set score, keeping the test set untouched for one final check
Answer and explanation

Answer: D

k is a hyperparameter, chosen by comparing scores on the validation set. Choosing with the test set would make it part of model building, so its score would no longer be honest. With k = 1 each training example is its own nearest neighbour, so a training score near 100% shows memory, not learning.

A dataset of 4,000 labelled records is split 70% training, 15% validation and 15% test. The final model gets 540 of the test records right. What is its test accuracy?

  1. 77%
  2. 13.5%
  3. 90%
  4. 85%
Answer and explanation

Answer: C

Test set = 15% of 4,000 = 600 records. Accuracy = 540 ÷ 600 × 100 = 90%. Dividing 540 by all 4,000 records would wrongly give 13.5%.

A district library groups its members by borrowing habits, with no groups defined in advance. Which statement is correct?

  1. It is classification, because each member ends up in a group
  2. It is clustering; with no labels, a person judges whether the groups are useful
  3. It is regression, because borrowing counts are numbers
  4. It cannot be done without a labelled test set
Answer and explanation

Answer: B

Grouping examples without predefined labels is clustering, an unsupervised task. There are no true labels to compare with, so people judge whether the groups make sense and are useful. Classification and regression both need labelled examples.

The values 1, 2, 6, 10 and 11 are clustered by k-means with k = 2, starting centres 1 and 2. Where are the centres when the algorithm stops?

  1. 1 and 7.25
  2. 2 and 10
  3. 1.5 and 9
  4. 3 and 8
Answer and explanation

Answer: C

Round 1: 1 joins centre 1; 2, 6, 10 and 11 are nearer centre 2. Update: 1 and (2 + 6 + 10 + 11) ÷ 4 = 29 ÷ 4 = 7.25. Round 2: 2 is nearer 1 (distance 1) than 7.25, while 6, 10 and 11 stay with 7.25. Update: (1 + 2) ÷ 2 = 1.5 and (6 + 10 + 11) ÷ 3 = 27 ÷ 3 = 9. Round 3: 6 is 4.5 from 1.5 and 3 from 9, so nothing changes. The algorithm stops with centres 1.5 and 9.

Using k-NN, a new point's five nearest neighbours, from nearest to farthest, are labelled A, B, A, B, B. What are the predictions for k = 3 and for k = 5?

  1. A for both
  2. A for k = 3 and B for k = 5
  3. B for both
  4. B for k = 3 and A for k = 5
Answer and explanation

Answer: B

k = 3: the three nearest are A, B, A, so A wins 2 to 1. k = 5: all five vote A, B, A, B, B, so B wins 3 to 2. The choice of k changes the answer.

A loan model was trained only on applicants from cities. It performs badly for rural applicants. What is the main cause?

  1. The test set was too large
  2. The categories were one-hot encoded
  3. The training data did not represent rural applicants
  4. The model was deployed too early in the day
Answer and explanation

Answer: C

A model learns only from the examples it sees. With no rural applicants in the training data, it has not learned their patterns: garbage in, garbage out. The fix is data that represents everyone the model will serve, and checking results for each group.

Daily visitors at a post office are 30, 34, 36, 40 and 300 (a pension-day rush), and one day's count is missing. Which statement about filling the gap is correct?

  1. The mean is 88 and the median is 36; the median is the safer fill
  2. The mean is 36 and the median is 88; the mean is the safer fill
  3. The mean is 88 and the median is 36; the mean is the safer fill
  4. The mean is 440 and the median is 36; the median is the safer fill
Answer and explanation

Answer: A

Mean = (30 + 34 + 36 + 40 + 300) ÷ 5 = 440 ÷ 5 = 88 (440 is the total, not the mean). Sorted, the middle of the five values is 36, so the median is 36. The single extreme value drags the mean far above four of the five days, so the median of 36 is the more typical and safer fill.

A weather app predicts tomorrow's rainfall in millimetres using today's humidity, air pressure and wind speed. Which statement is correct?

  1. Rainfall is a feature and humidity is the label
  2. Humidity, air pressure and wind speed are features; rainfall is the label
  3. All four quantities are labels
  4. There are no features because the data is about weather
Answer and explanation

Answer: B

Features are the inputs the model uses (humidity, air pressure, wind speed); the label is the quantity it must predict (rainfall). Because rainfall is a number, this is also a regression task.

For a screening test for a serious disease, where every positive result is checked again by a doctor, which measure matters most?

  1. Accuracy, because the disease is rare
  2. Precision, because false alarms are the worst mistake
  3. Recall, because missing a sick person is the costliest mistake
  4. Training score, because it is the highest
Answer and explanation

Answer: C

A missed patient (false negative) may go untreated, while a false alarm only leads to a further check. Recall measures how many real cases are caught, so it matters most here. Accuracy misleads for rare diseases, and a training score says nothing about new patients.

A confusion matrix shows TP = 30, FP = 10, FN = 20 and TN = 940. What is the precision?

  1. 60%
  2. 75%
  3. 97%
  4. 40%
Answer and explanation

Answer: B

Precision = TP ÷ (TP + FP) = 30 ÷ (30 + 10) = 30 ÷ 40 = 75%. Recall would be 30 ÷ (30 + 20) = 60%, and accuracy (30 + 940) ÷ 1,000 = 97%; neither is precision.

A model is run once on a test set of 400 examples and gets 360 right. What is its test accuracy?

  1. 85%
  2. 90%
  3. 80%
  4. 36%
Answer and explanation

Answer: B

Accuracy = correct ÷ total × 100 = 360 ÷ 400 × 100 = 90%.

In the machine learning workflow, which step comes right after a model is deployed?

  1. Monitoring its performance over time
  2. Collecting the first data
  3. Cleaning the data
  4. Training the first model
Answer and explanation

Answer: A

The workflow is collect, clean, train, test, deploy, monitor. After deployment the model must be monitored because real-world data can drift and reduce its accuracy.

A team wants to choose the best value of k for k-NN by comparing several values. Which data should it use to compare them?

  1. The training set
  2. The test set
  3. The validation set
  4. Any rows chosen at random from all the data
Answer and explanation

Answer: C

Comparing settings (hyperparameters) such as k is the validation set's job. Using the test set would make it part of model building, so it could no longer give an honest final score; the training set would favour models that memorise.

A school has 500 labelled answer sheets and keeps 20% aside as a test set, with no separate validation set. How many sheets are used for training?

  1. 100
  2. 250
  3. 480
  4. 400
Answer and explanation

Answer: D

Test set = 20% of 500 = 100 sheets. Training set = 500 − 100 = 400 sheets.

In reinforcement learning, what is the 'agent'?

  1. The person who labels the data
  2. The learner that takes actions and receives rewards
  3. The group centre in clustering
  4. The reward itself
Answer and explanation

Answer: B

The agent is the learner. It acts in an environment, receives rewards or penalties and gradually learns which actions earn the most reward. Reinforcement learning uses no labelled examples and no cluster centres.

In k-means clustering, what does k stand for?

  1. The number of groups to be formed
  2. The number of neighbours that vote
  3. The number of labels in the data
  4. The number of times the algorithm runs
Answer and explanation

Answer: A

In k-means, k is the number of clusters, chosen by people before the algorithm runs. The number of neighbours that vote is the k of k-nearest neighbours, a different (supervised) method.

The values 3, 5, 15 and 17 are clustered by k-means with k = 2, starting centres 3 and 17. After one assign-and-update round, where are the centres?

  1. 3 and 17
  2. 5 and 15
  3. 8 and 12
  4. 4 and 16
Answer and explanation

Answer: D

Assign: 3 and 5 are nearer centre 3; 15 and 17 are nearer centre 17. Update: (3 + 5) ÷ 2 = 4 and (15 + 17) ÷ 2 = 16. So the new centres are 4 and 16, and a further round changes nothing.

In k-means, after points are assigned to groups, what happens to each group's centre?

  1. It is deleted
  2. It moves to the average of the points in its group
  3. It moves to the point farthest from it
  4. It is given a label by the model
Answer and explanation

Answer: B

The update step moves each centre to the mean (average) of the points assigned to it. Assign and update are repeated until no point changes group.

Why are decision trees often liked by organisations that must explain their decisions?

  1. They never make mistakes
  2. They need no data
  3. Their predictions follow a readable chain of yes/no questions
  4. They only work on images
Answer and explanation

Answer: C

A decision tree's prediction can be traced through its questions, so a person can see why it decided. Trees still make mistakes, need labelled data to learn, and work on ordinary tables of features.

Privacy · Terms · Refunds · Delivery