K-Nearest Neighbors

K-Nearest Neighbors

Estimates conditional probability of a Bayes classifier
Given a positive integer K and a test observation x0, the KNN classifier first identifies the K points in the training data that are closest to x0, represented by N0. It then estimates the conditional probability for class j as the fraction of points in N0 whose response values equal j:

Pr(Y=j|X=x0)=1K∑i∈N0I(yi=j)

KNN classifies the test observation x0 to the class with the highest probability.
The value of K determines the flexibility of a KNN model

Sources: 1

Connect With Me!