k-Nearest Neighbors › Disadvantages

Michael BrenndoerferOctober 26, 20262 min read
Machine Learning from ScratchAll chapters
Part 7 of 15Supervised Learning Beyond Linear Models
Chapter 53k-Nearest Neighbors › Disadvantages
Reading section 3 of 10 · Disadvantages · 2 minSection 3 of 10 · 2 min

Section 3 of 10 · 2 min read

k-Nearest Neighbors › DisadvantagesSection view · Sections in this chapter3 / 10 ↓
Reading tools Definitions, links & notes

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

Notes & comments

The same flexibility that makes kNN effective also creates weaknesses. First, kNN does not tell us which features matter. If a feature is irrelevant but has a large numeric range, its contribution to the distance can dominate the calculation and produce neighborhoods that are essentially determined by noise. Choose feature scales deliberately, as discussed in the earlier standardization chapter. Unintended unit differences can reshape neighborhoods even when the underlying observations are unchanged.

Second, kNN is computationally expensive at prediction time. The training set must be stored. With brute-force search, each query computes the distance to every stored point, a cost that grows linearly with the number of training samples and the number of features. For a small dataset this is trivial; for millions of points in dozens of dimensions, brute-force kNN can become the bottleneck. Exact spatial indexes can reduce distance calculations while preserving the nearest neighbors, at the cost of building and storing the index, plus tuning it. Approximate search introduces a separate speed–recall tradeoff and may return a different neighbor set.

Third, kNN can suffer from the curse of dimensionality. With many noise features, the relative contrast between nearest and farthest distances can shrink, making it harder to identify a useful local neighborhood. We quantify this under an independent Gaussian feature model later in the chapter. This motivates using informative features or a suitable low-dimensional representation; high dimension alone does not determine how kNN will perform.

Comments

Add to the conversation

A question, a correction, or an example from your own work.

No comments yet. Be the first to share your thoughts!

Newsletter

Stay up to date

Get new articles, book updates, and notes on AI and technology.

Unsubscribe at any time. Privacy policy