KNN Neighborhood Explorer
Watch k, distance metric and feature scaling reshape a k-nearest-neighbour decision boundary.
- k-NN
- decision boundary
- scaling
- bias-variance
Query prediction
Patient #0 is truly benign. Averaging the 9 nearest neighbors in 20 dimensions gives a predicted probability of 0.111 (cohort prevalence: 0.217).
Neighborhood in 2D PCA projection
Distance from query to every other case
Prediction for this patient as k grows
Curse of dimensionality: distance concentration
Nearest neighborFarthest neighbor
When 'nearest' stops meaning anything
As dimensions increase, the nearest and farthest curves converge: the ratio of nearest to farthest distance approaches 1, and every point becomes roughly equidistant from every other point. Reduce "Dimensions used" back toward 2 and watch the neighborhood snap back into a meaningful local structure.