Math for ML Questions with Answers

42 practice questions on Math for ML (AI & Machine Learning) with answers and step-by-step solutions. Try 10 samples below, then practise all 42 free in the AptiNest app.

Sample questions

Question 1Easy

A fraud model is tested on 200 transactions:

- TP = 30
- FN = 10
- FP = 20
- TN = 140

What is the precision?

  1. 0.60
  2. 0.75
  3. 0.40
  4. 0.85

Answer: A. 0.60

Explanation

TP / (TP + FP) = 30 / 50 = 0.60.

Step-by-step solution

  1. Precision = TP / (TP + FP).
  2. = 30 / (30 + 20) = 30 / 50.
  3. = 0.60.

Why the other options are wrong

  • B. 0.75 is recall.
  • C. 0.40 is the share of flagged transactions that were false alarms (20 / 50).
  • D. 0.85 is accuracy.

Question 2Easy

What is the dot product of (1, 2, 3) and (4, -5, 6)?

  1. 32
  2. 12
  3. -12
  4. 0

Answer: B. 12

Explanation

4 - 10 + 18 = 12.

Step-by-step solution

  1. Multiply matching entries: 1 x 4 = 4, 2 x -5 = -10, 3 x 6 = 18.
  2. Sum: 4 - 10 + 18.
  3. = 12.

Why the other options are wrong

  • A. 32 ignores the minus sign on -5.
  • C. -12 gets the sign wrong.
  • D. 0 would mean the vectors are perpendicular.

Question 3Easy

A fraud model is tested on 200 transactions:

- TP = 30
- FN = 10
- FP = 20
- TN = 140

What is the accuracy?

  1. 0.60
  2. 0.875
  3. 0.75
  4. 0.85

Answer: D. 0.85

Explanation

(TP + TN) / total = (30 + 140) / 200 = 0.85.

Step-by-step solution

  1. Accuracy = (TP + TN) / total.
  2. = (30 + 140) / 200.
  3. = 170 / 200 = 0.85.

Why the other options are wrong

  • A. 0.60 is precision.
  • B. 0.875 is specificity.
  • C. 0.75 is recall.

Question 4Easy

A matrix of shape (32, 10) is multiplied by a matrix of shape (10, 5). What is the result's shape?

  1. (32, 10)
  2. (5, 32)
  3. (10, 10)
  4. (32, 5)

Answer: D. (32, 5)

Explanation

Inner dimensions (10) must match; the result takes the outer dimensions.

Step-by-step solution

  1. (m, n) x (n, p) gives (m, p).
  2. Inner dimensions match: 10 and 10.
  3. Result = (32, 5).

Why the other options are wrong

  • A. (32, 10) is the first matrix's shape.
  • B. (5, 32) is the transpose of the result.
  • C. (10, 10) uses the inner dimensions, which cancel.

Tip: Inner dims must match and vanish; outer dims remain.

Question 5Medium

Class A has F1 = 0.9 and class B has F1 = 0.5. What is the macro-averaged F1?

  1. 0.9
  2. 0.5
  3. 0.7
  4. 0.45

Answer: C. 0.7

Explanation

Macro averaging takes the unweighted mean: (0.9 + 0.5) / 2 = 0.7.

Step-by-step solution

  1. Macro F1 = unweighted mean of per-class F1.
  2. = (0.9 + 0.5) / 2.
  3. = 0.7.

Why the other options are wrong

  • A. 0.9 is class A only.
  • B. 0.5 is class B only.
  • D. 0.45 is the product, not the mean.

Question 6Medium

Why are input features often standardised before gradient descent?

  1. It speeds up convergence
  2. It is required for decision trees
  3. It removes all outliers
  4. It reduces the number of features

Answer: A. It speeds up convergence

Explanation

Features on very different scales make the loss surface elongated, slowing convergence.

Step-by-step solution

  1. Features on very different scales make the loss surface long and narrow.
  2. Gradient descent then zig-zags and needs a small learning rate.
  3. Standardising gives a rounder surface, so it converges faster.

Why the other options are wrong

  • B. Decision trees do not need scaling.
  • C. Standardising rescales data but does not remove outliers.
  • D. The number of features stays the same.

Question 7Medium

The true label is 1 and the model predicts probability 0.8. What is the binary cross-entropy loss (natural log), to two decimals?

  1. 1.61
  2. 0.80
  3. 0.22
  4. 0.20

Answer: C. 0.22

Explanation

Loss = -ln(0.8) = 0.223.

Step-by-step solution

  1. BCE for true label 1 = -ln(p).
  2. -ln(0.8) = 0.223.
  3. Rounded: 0.22.

Why the other options are wrong

  • A. 1.61 is -ln(0.2), the loss if the true label were 0.
  • B. 0.80 is the probability, not the loss.
  • D. 0.20 is 1 - p, not the log loss.

Question 8Medium

Prediction errors are 2, -2, 4 and -4. What is the RMSE, to two decimals?

  1. 3.00
  2. 3.16
  3. 10.00
  4. 0.00

Answer: B. 3.16

Explanation

Mean of squares = (4 + 4 + 16 + 16)/4 = 10; RMSE =
sqrt(10) = 3.16.

Step-by-step solution

  1. Squares: 4, 4, 16, 16; sum = 40.
  2. Mean = 40 / 4 = 10.
  3. RMSE = sqrt(10) = 3.16.

Why the other options are wrong

  • A. 3.00 is the mean absolute error.
  • C. 10.00 is the MSE before the square root.
  • D. 0 is the mean of the signed errors, which cancel.

Tip: RMSE >= MAE; equal only when all errors have the same size.

Question 9Hard

For f(w) = w^2,

starting at w = 3 with learning rate 0.1, what is w after two gradient-descent steps?

  1. 2.16
  2. 1.8
  3. 2.4
  4. 1.92

Answer: D. 1.92

Explanation

Each step multiplies w by (1 - 0.2) = 0.8: 3 -> 2.4 -> 1.92.

Step-by-step solution

  1. Each step multiplies w by (1 - 2 x 0.1) = 0.8.
  2. Step 1: 3 x 0.8 = 2.4.
  3. Step 2: 2.4 x 0.8 = 1.92.

Why the other options are wrong

  • A. 2.16 uses 2.4 - 0.24, a gradient of w instead of 2w.
  • B. 1.8 subtracts 0.6 twice, reusing the first gradient.
  • C. 2.4 is after one step only.

Question 10Hard

In a dataset with 90% class A and 10% class B, why might micro-averaged F1 look much better than macro-averaged F1?

  1. Micro averaging ignores class A
  2. They are always equal
  3. Macro averaging counts samples twice
  4. Micro favours the big class

Answer: D. Micro favours the big class

Explanation

Micro pools all predictions, so poor minority-class performance barely moves it; macro weights classes equally.

Step-by-step solution

  1. Micro averaging pools all predictions before computing the metric.
  2. With 90% class A, A's results dominate the pooled counts.
  3. If the model handles A well but B poorly, micro F1 looks high while macro F1 drops.

Why the other options are wrong

  • A. Micro averaging is dominated by class A, not blind to it.
  • B. They differ whenever classes differ in size and performance.
  • C. Macro averages per-class scores; it does not double count.

Tip: Imbalanced data: watch macro F1.

Practise all 42 questions free

The full question bank with timed practice, progress tracking and Vidya, your AI tutor. Free, no ads.

Open this topic in the app →

Related topics

See all AI & Machine Learning topics · All topics