k-nearest neighbors
k-nearest neighbors (k-NN) is perhaps the simplest machine learning algorithm. In the case of classification, it assigns a class to a particular data point by a majority vote of its k nearest neighbors. In other words, the data point is assigned the class that is the most common among its k-nearest neighbors. In the case of regression, it computes the average value for the target variable based on its k-nearest neighbors.
Unlike most machine learning algorithms, k-NN is non-parametric and lazy in nature. The former means that k-NN does not make any underlying assumptions about the distribution of the data. In other words, the model structure is determined by the data. The latter means that k-NN undergoes virtually no training. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access