The following are the primary benefits of using kNN for classification: Implementation is very straightforward. In terms of the search space, it's robust; for example, classes don't have to be linearly separable. As new examples with known classes are supplied, the Classifier can be updated online at a low cost.
The KNN algorithms choose a number k as the closest Neighbor to the data point to be categorised. If k is set to 5, it will search for the 5 closest Neighbors to that data point. If we suppose k=4 in this case, KNN learns about the four closest Neighbors.