Sample questions
Question 1Easy
In k-nearest neighbours with k = 3, a new point is classified by
- Majority class among its 3 nearest training points
- The farthest 3 points
- The average of all training labels in the dataset
- A fitted equation
Answer: A. Majority class among its 3 nearest training points
Explanation
k-NN is a lazy learner: it stores the data and votes among neighbours at prediction time.
Step-by-step solution
- Compute distances to all points.
- Pick 3 nearest.
- Take the majority class.
Why the other options are wrong
- B. The nearest are used.
- C. Only the neighbours matter.
- D. k-NN stores data and fits no equation.
Question 2Easy
The entropy (base 2) of a node with a 50/50 class split is
- 0
- 0.5
- 1
- 2
Answer: C. 1
Explanation
H = -2*(0.5*log2 0.5) = 1 bit, the maximum for two classes.
Step-by-step solution
- Entropy H = −Σ p log2(p).
- For a 50/50 split, H = −0.5 log2(0.5) − 0.5 log2(0.5) = 0.5 + 0.5.
- So the entropy is 1, which is option C.
Why the other options are wrong
- A. 0 means a pure node with one class only.
- B. 0.5 is only half of the entropy for a 50/50 split.
- D. 2 is larger than the maximum entropy for two classes, which is 1.
Tip: Two equal classes give entropy 1 bit; a pure node gives 0.
Question 3Easy
The Gini impurity of a node with 60% class A and 40% class B is
- 0.40
- 0.24
- 0.60
- 0.48
Answer: D. 0.48
Explanation
Gini = 1 - (0.6^2 + 0.4^2) = 1 - 0.52 = 0.48.
Step-by-step solution
- Gini impurity formula is 1 - (p^2 + q^2).
- p = 0.6, q = 0.4, so p^2 = 0.36.
- q^2 = 0.16, total = 0.36 + 0.16 = 0.52.
- 1 - 0.52 = 0.48.
- Final answer: 0.48.
Why the other options are wrong
- A. 0.40 is the probability of class B, not the Gini impurity; Gini is 1 minus the sum of squares.
- B. 0.24 is 0.6 times 0.4, a product that is not the Gini impurity; Gini uses 1 minus squares.
- C. 0.60 is the probability of class A, not the Gini impurity of the node.
Tip: Use formula 1 - (p^2 + q^2) for Gini impurity.
Question 4Medium
In an SVM, the support vectors are
- All training points
- Training points closest to the decision boundary that define the margin
- The points with the largest feature values
- Points removed as outliers before the model is trained
Answer: B. Training points closest to the decision boundary that define the margin
Explanation
The hyperplane depends only on the support vectors; other points can move or vanish without changing it.
Step-by-step solution
- Find the maximum-margin hyperplane.
- Points on the margin are support vectors.
- They alone fix the boundary.
Why the other options are wrong
- A. Only the boundary-defining ones are support vectors.
- C. Feature size is unrelated.
- D. They are kept, and they matter most.
Question 5Medium
In a support vector machine, the support vectors are
- all training points of the majority class
- the points farthest from the boundary
- the centroids of each class
- the training points closest to the decision boundary that define the margin
Answer: D. the training points closest to the decision boundary that define the margin
Explanation
Only the points on or inside the margin determine the hyperplane; removing other points does not change it.
Step-by-step solution
- Support vector machines use margins to separate classes.
- Points closest to the decision boundary define these margins.
- These close points are called support vectors.
- They are the training points that influence the hyperplane.
- The correct answer is the training points closest to the decision boundary that define the margin.
Why the other options are wrong
- A. Support vectors are a few boundary points, not all training points of the majority class.
- B. Points farthest from the boundary have no influence on the hyperplane, so they are not support vectors.
- C. Class centroids are not support vectors; SVM support vectors are the training points near the margin.
Tip: Remember: support vectors are the closest points to the decision boundary.
Question 6Medium
A node has 25% class A and 75% class B. Its entropy (base 2) is approximately
- 0.25
- 0.75
- 0.81
- 1.00
Answer: C. 0.81
Explanation
H = -(0.25*log2 0.25 + 0.75*log2 0.75) = 0.5 + 0.311 = 0.811.
Step-by-step solution
- Entropy formula is H = -pA*log2(pA) - pB*log2(pB).
- pA = 0.25, so 0.25 * log2(0.25) = 0.25 * -2 = -0.5.
- pB = 0.75, so 0.75 * log2(0.75) ≈ 0.75 * -0.415 = -0.311.
- Add both terms: -0.5 + (-0.311) = -0.811, then take negative to get 0.811.
- Rounded to two decimal places, entropy is approximately 0.81.
Why the other options are wrong
- A. 0.25 is only the probability of class A, not the entropy; entropy needs both terms.
- B. 0.75 is the probability of class B, not the entropy of the node.
- D. 1.00 is the maximum entropy, reached only at a 50/50 split, not at 25/75.
Tip: Remember log2(0.5) = -1 and log2(0.25) = -2; the minus sign in the entropy formula makes the result positive.
Question 7Medium
Why is feature scaling important for k-NN?
- k-NN cannot use floating-point numbers
- Distance is dominated by features with large numeric ranges
- Scaling lowers the value of k
- Scaling adds new neighbours to every point in the dataset
Answer: B. Distance is dominated by features with large numeric ranges
Explanation
Without scaling, a salary column in thousands would swamp an age column in tens.
Step-by-step solution
- k-NN uses Euclidean distance.
- Large-range feature dominates it.
- Scale features equally.
Why the other options are wrong
- A. It can.
- C. Scaling does not change k.
- D. The number of neighbours is set by k.
Question 8Medium
A decision tree grown with no depth limit usually
- overfits the training data
- underfits the training data
- has high bias
- cannot fit training data perfectly
Answer: A. overfits the training data
Explanation
A fully grown tree can memorise the training set, giving low bias and high variance. Pruning or depth limits help.
Step-by-step solution
- With no depth limit, the tree keeps splitting until each leaf fits its training points.
- So it can fit the training data almost perfectly, learning noise along with the real pattern.
- That is overfitting (high variance), so option A is the answer.
Why the other options are wrong
- B. Underfitting comes from a tree that is too shallow, not one with no depth limit.
- C. A deep tree has low bias and high variance, not high bias.
- D. A tree with no depth limit can fit the training data perfectly, so this is false.
Tip: Deep or unpruned trees have low bias and high variance, so they overfit. Shallow trees underfit.
Question 9Hard
A decision tree that keeps splitting until each leaf holds one sample will most likely
- Overfit the training data
- Underfit
- Fail to train
- Always have 100% test accuracy
Answer: A. Overfit the training data
Explanation
Unrestricted depth lets the tree memorise noise, so use max_depth or pruning.
Step-by-step solution
- Split until leaves are pure.
- Tree memorises training data.
- High variance, poor generalisation.
Why the other options are wrong
- B. Deep trees have low bias and memorise noise.
- C. It trains easily.
- D. Memorisation hurts test accuracy.
Question 10Hard
Naive Bayes with P(spam)=0.4, P(word|spam)=0.5, P(word|ham)=0.1 and P(ham)=0.6 gives P(spam|word) of about
- 0.50
- 0.83
- 0.20
- 0.77
Answer: D. 0.77
Explanation
Numerator = 0.4*0.5 = 0.2; denominator = 0.2 + 0.6*0.1 = 0.26; 0.2/0.26 = 0.769.
Step-by-step solution
- Numerator = P(spam) * P(word|spam) = 0.4 * 0.5 = 0.2.
- Denominator = numerator + P(ham) * P(word|ham) = 0.2 + 0.6 * 0.1 = 0.26.
- P(spam|word) = 0.2 / 0.26 = 0.769.
- Rounded to two decimal places, answer is 0.77.
Why the other options are wrong
- A. 0.50 ignores the ham term; the denominator adds 0.6 times 0.1, giving about 0.77.
- B. 0.83 is not computed from these numbers; the posterior is 0.2 / 0.26, about 0.77.
- C. 0.20 is only the numerator P(spam) times P(word given spam), without dividing by the total.
Practise all 20 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 →