Skip to content

Latest commit

 

History

History
11 lines (9 loc) · 971 Bytes

File metadata and controls

11 lines (9 loc) · 971 Bytes

K-Nearest Neighbors

K-Nearest neighbor is machine learning algorithm that can used for classification and regression. In both cases, the input consists of the k closest training examples in the feature space. The output depends on whether k-NN is used for classification or regression:

  • In k-NN classification, the output is a class membership. An object is classified by a majority vote of its neighbors, with the object being assigned to the class most common among its k nearest neighbors (k is a positive integer, typically small). If k = 1, then the object is simply assigned to the class of that single nearest neighbor.
  • In k-NN regression, the output is the property value for the object. This value is the average of the values of its k nearest neighbors.

A graphical explanation of KNN

Image of KNN

Further reference:

https://en.wikipedia.org/wiki/K-nearest_neighbors_algorithm