EasyDeepLearn

How do you choose k in k-Nearest Neighbours?

easy

Answer

  • Cross-validation over odd values (avoids ties in binary problems).
  • Small k (1-3) = low bias, high variance — sensitive to noise.
  • Large k = smooth boundary, higher bias, lower variance.
  • A common heuristic is k ≈ sqrt(n).
  • Weighted KNN (weights inversely proportional to distance) reduces sensitivity to k.
  • For classification with C classes, k should not be a multiple of C (to break ties).
Check yourself — multiple choice
  • Always k = 1
  • Cross-validate over odd k; small k = variance, large k = bias; ~sqrt(n) as a heuristic
  • k must equal n
  • k must be even

CV over odd k. Small k = high variance, large k = high bias.

#knn#hyperparameter-tuning

Practise Supervised Learning

215 interview questions in this topic.

Related questions