Machine Learning Basics

Practice questions

A crop-disease model worked well when launched but becomes less accurate over two seasons as new pest varieties appear. Which workflow step should catch this, and what is the effect called?

  1. Cleaning; overfitting
  2. Testing; underfitting
  3. Monitoring; data drift
  4. Collecting; reinforcement
Answer and explanation

Answer: C

After deployment the model must be monitored. When the real-world data changes over time and accuracy falls, that is data drift; the remedy is to retrain on newer data.

Among 2,000 loan applications, 40 are fraudulent. A model flags 50 applications, of which 30 are fraudulent. What are its precision and recall?

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

Answer: A

Precision = real frauds among flagged = 30 ÷ 50 = 60%. Recall = frauds caught among all frauds = 30 ÷ 40 = 75%.

Model M scores 70% on training data and 69% on test data, while a more flexible model N scores 92% on training and 90% on test. What best describes model M?

  1. Overfitting
  2. A good fit
  3. Underfitting
  4. Data drift
Answer and explanation

Answer: C

M's scores are similar but low on both training and test data, and a more flexible model does much better on both. That shows M is too simple to capture the pattern: underfitting. Overfitting would show a high training score and a much lower test score.

In the sentence 'She sat on the bank and watched the boats', a transformer uses which mechanism to work out that 'bank' means a riverside?

  1. Clustering
  2. Attention to other words such as 'boats'
  3. A larger test set
  4. Reinforcement rewards
Answer and explanation

Answer: B

Transformers use attention: while processing a word, the model weighs how relevant every other word in the passage is. Attending to 'boats' points to the riverside meaning of 'bank'.

Using the update rule new w = w + learning rate × error × input, with w = 2, input 3, correct answer 9 and learning rate 0.1, what is the new w? (Prediction = w × input; error = answer − prediction.)

  1. 2.3
  2. 2.6
  3. 2.9
  4. 3.8
Answer and explanation

Answer: C

Prediction = 2 × 3 = 6. Error = 9 − 6 = 3. New w = 2 + 0.1 × 3 × 3 = 2 + 0.9 = 2.9. The new prediction 2.9 × 3 = 8.7 is closer to 9.

A neuron has inputs 3 and 2, weights −1 and 0.5, and bias 0, with ReLU activation. What is its output?

  1. 0
  2. −2
  3. 4
  4. 1
Answer and explanation

Answer: A

Weighted sum = (3 × −1) + (2 × 0.5) + 0 = −3 + 1 = −2. ReLU outputs 0 for any negative total, so the output is 0.

Customers' monthly spending (in thousands of rupees) is 1, 3, 9 and 11. k-means with k = 2 starts with centres 1 and 11. After one assign-and-update round, where are the centres?

  1. 1 and 11
  2. 2 and 10
  3. 3 and 9
  4. 4 and 8
Answer and explanation

Answer: B

Assign: 1 and 3 are nearer centre 1; 9 and 11 are nearer centre 11. Update: (1 + 3) ÷ 2 = 2 and (9 + 11) ÷ 2 = 10. The new centres are 2 and 10, and another round changes nothing.

Using k-NN, a new point's five nearest neighbours are labelled A, B, A, B, B. With k = 3, the three nearest (in order) are A, B, A. What are the predictions for k = 3 and k = 5?

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

Answer: D

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 model has learned: electricity bill = 7 × units used + 150. Ravi's bill is predicted to be ₹1,200. How many units does the model assume he used?

  1. 171
  2. 200
  3. 1,050
  4. 150
Answer and explanation

Answer: D

Set up the equation: 1,200 = 7 × units + 150. Subtract 150: 7 × units = 1,050. Divide by 7: units = 150. Check: 7 × 150 + 150 = 1,050 + 150 = ₹1,200.

A game agent gets +50 for winning and −3 for every move. Strategy P wins in 10 moves; strategy Q wins in 14 moves. What are the total rewards of P and Q?

  1. 20 and 8
  2. 50 and 50
  3. 30 and 22
  4. 20 and 14
Answer and explanation

Answer: A

P: 50 − (10 × 3) = 50 − 30 = 20. Q: 50 − (14 × 3) = 50 − 42 = 8. So the totals are 20 and 8, and the agent learns to prefer P.

Which pair is correctly matched?

  1. Clustering - needs labelled data
  2. Reinforcement learning - learns from rewards by acting in an environment
  3. Regression - predicts a category
  4. Classification - finds groups without labels
Answer and explanation

Answer: B

Reinforcement learning is defined by an agent acting in an environment and learning from rewards. Clustering works without labels, regression predicts numbers and classification predicts categories from labelled data.

A telecom company wants to predict whether each customer will leave next month ('leave' or 'stay'), using records of past customers who did leave or stay. Which type of task is this?

  1. Regression
  2. Clustering
  3. Supervised classification
  4. Reinforcement learning
Answer and explanation

Answer: C

The answer is a category (leave or stay) and past records provide labels, so it is supervised classification. Regression would predict a number; clustering uses no labels; reinforcement learns from rewards.

Which statement best describes machine learning compared with ordinary programming?

  1. ML is given rules and produces data
  2. ML needs no examples, only rules
  3. ML can only add and subtract numbers
  4. ML is given data and correct answers and produces the rules (a model)
Answer and explanation

Answer: D

In ordinary programming, data and rules go in and answers come out. In machine learning, data and answers go in and the learned rules (the model) come out.

A dataset of 2,500 labelled photos is split 80% for training and 20% for testing. The model gets 450 of the test photos right. What is its test accuracy?

  1. 90%
  2. 18%
  3. 80%
  4. 75%
Answer and explanation

Answer: A

Test set = 20% of 2,500 = 500 photos. Accuracy = 450 ÷ 500 × 100 = 90%.

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

  1. Rainfall is a feature and humidity is the label
  2. Humidity, 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, pressure, wind speed); the label is the quantity it must predict (rainfall). Because rainfall is a number, this is also a regression task.

In the ML 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 loan model was trained only on applicants from cities. It performs badly for rural applicants. What is the main cause?

  1. Too many epochs
  2. The learning rate was zero
  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. This is data bias; the fix is representative data and checking results for each group.

A fraud model flags 25 transactions; 10 of them are real frauds. There were 20 frauds in total. What is its recall?

  1. 50%
  2. 40%
  3. 25%
  4. 80%
Answer and explanation

Answer: A

Recall = frauds caught ÷ all real frauds = 10 ÷ 20 = 50%. (Precision would be 10 ÷ 25 = 40%, a different measure.)

Out of 500 patients, 5 have a rare disease. A model always predicts 'healthy'. What is its accuracy?

  1. 1%
  2. 95%
  3. 100%
  4. 99%
Answer and explanation

Answer: D

It is right on every healthy patient: 500 − 5 = 495. Accuracy = 495 ÷ 500 = 99%, even though it detects none of the 5 sick patients. This is why accuracy can mislead when one class is rare.

A model scores 98% on its training data but only 65% on new test data. What is the most likely problem?

  1. Underfitting
  2. Overfitting
  3. The test set is too small to matter
  4. The model has no parameters
Answer and explanation

Answer: B

A very high training score with a much lower test score means the model memorised the training data instead of learning a general pattern. That is overfitting. Underfitting would give low scores on both.

Privacy · Terms · Refunds · Delivery