Concept

K-nearest Neighbors (k-NN)

K-nearest neighbors is a non-parametric statistical method, which predicts based on the k nearest neighbors. k-NN classifiers are an example of what's called instance based or memory based supervised learning.

It can be applied to both classification and regression problems.

  • When applied to classification problems, the prediction result would be the most common one among the k nearest training observations.
  • When applied to regression problems, the prediction result would be the average of the k nearest training observations.

Some key notes about this method:

  • It makes few assumptions about structure of data
  • It gives potentially accurate but sometimes unstable predictions
  • It is sensitive to small changes in training data

0

7

Updated 2026-05-06

Tags

Data Science

D2L

Dive into Deep Learning @ D2L