Why must k grow with the training set size, while k/n shrinks, for KNN to be a consistent estimator?
Quick Overview
Asks why the number of neighbors in k-nearest neighbors has to grow with the training set while k/n goes to zero for the method to be consistent. Tests understanding of the bias and variance of a local vote, neighborhood size, and how dimension slows convergence.
Why must k grow with the training set size, while k/n shrinks, for KNN to be a consistent estimator?
Role: Machine Learning Engineer
Category: Machine Learning
Difficulty: medium
Interview Round: Other
Why must $k$ grow with the training set size $n$, while $k/n$ shrinks, for KNN to be a consistent estimator?
Here consistent means that as $n \to \infty$ the error of the k-nearest-neighbor rule converges to the best achievable (Bayes) error, or for regression that the estimate converges to the true regression function.
```hint Split the error
Split the error of the k-NN estimate of $P(y \mid x)$ at one query point into a bias part and a variance part, and ask what each part depends on.
```
```hint Size of the neighborhood
Think about how much probability mass the $k$ nearest neighbors of a point cover, and how that changes as $n$ grows in three cases: $k$ fixed, $k$ proportional to $n$, and $k$ growing more slowly than $n$.
```
### What a Strong Answer Covers
- What consistency means for a k-NN classifier or regressor
- Why $k \to \infty$ is needed: the variance of the local vote or average, and what happens with fixed $k$, including the limit for 1-NN
- Why $k/n \to 0$ is needed: the probability mass of the neighborhood and the bias from averaging over a region that never shrinks
- A schedule for $k$ that meets both conditions, and how $k$ is chosen in practice
- How the dimension of the input affects the speed of convergence
### Follow-up Questions
- Why can 1-NN have an error close to twice the Bayes error even with unlimited data?
- How does the best growth rate for $k$ depend on the dimension and on the smoothness of the target function?
- Does weighting neighbors by distance change the conditions for consistency?
- With a fixed amount of data in a high-dimensional space, what would you try instead of simply raising $k$?
Overview: Asks why the number of neighbors in k-nearest neighbors has to grow with the training set while k/n goes to zero for the method to be consistent. Tests understanding of the bias and variance of a local vote, neighborhood size, and how dimension slows convergence.
Why must k grow with the training set size n, while k/n shrinks, for KNN to be a consistent estimator?
Here consistent means that as n→∞ the error of the k-nearest-neighbor rule converges to the best achievable (Bayes) error, or for regression that the estimate converges to the true regression function.
What a Strong Answer Covers Guidance
What consistency means for a k-NN classifier or regressor
Why
k→∞
is needed: the variance of the local vote or average, and what happens with fixed
k
, including the limit for 1-NN
Why
k/n→0
is needed: the probability mass of the neighborhood and the bias from averaging over a region that never shrinks
A schedule for
k
that meets both conditions, and how
k
is chosen in practice
How the dimension of the input affects the speed of convergence
Follow-up Questions Guidance
Why can 1-NN have an error close to twice the Bayes error even with unlimited data?
How does the best growth rate for
k
depend on the dimension and on the smoothness of the target function?
Does weighting neighbors by distance change the conditions for consistency?
With a fixed amount of data in a high-dimensional space, what would you try instead of simply raising
k
?