MoonSay /Tutorials/Machine Learning Interview #17
Contents
  1. 01Introduction
  2. 02The rule
  3. 03Scale first
  4. 04Choosing k
  5. 05Interview follow-ups
  6. 06Common misconceptions
  7. 07Interview questions and model answers
  8. 08Summary
  9. References
k-Nearest Neighbors/Chapter 06 of 08

06Common misconceptions

  • “k-nearest neighbors has nothing to tune, because it does not train.” The measurements, the distance, the scaling and k are all choices, and choosing them well (by cross-validation) is its training.
  • “One neighbor gets 100\% on the training set, so it is the best k.” Every training point is its own nearest neighbor; that is memorizing, not learning. On the wines, k=1 is 100\% on training and 92\% in cross-validation.
  • “Scaling is optional.” The distance depends on the units, and the measurement with the largest variance dominates it (Proposition 1). Tree models do not care about scale; k-nearest neighbors does.
  • “Standardize the whole data set before splitting.” The means and standard deviations must come from the training points only, inside each fold; otherwise test information leaks into the model (Episode 11).
  • “A larger k is always safer.” A larger k lowers the variance but raises the bias; at k=n every point gets the majority class.
  • “k-nearest neighbors is a clustering method like k-means.” k-nearest neighbors is supervised: it predicts labels from labeled data, and k counts neighbors. k-means is unsupervised: it groups unlabeled data, and k counts clusters (Episode 3).