...

/

KNN (K-Nearest Neighbors)

KNN (K-Nearest Neighbors)

In this lesson, we introduce KNN, which is a very simple and intuitive model.

KNN stands for the k-nearest neighbor algorithm which is a non-parametric method used for classification and regression. In both cases, the input consists of the k closest training examples in the feature space. KNN is a type of instance-based learning or lazy learning. Lazy learning means this model doesn’t need any training process. Non-parametric means there is no assumption for the distribution of data. Instance-based means you need to store all data points.

How does the KNN work?

Let’s follow the steps below:

  • Define K. K is a hyperparameter, which defines the number of neighbors we used to do the prediction work.
  • After defining the K, the model is already generated.
  • Input a new sample,
...