The K-Nearest Neighbors Classifier
Now that we have our training and testing data, it is time to prepare our classifier to perform k-nearest neighbor classification. After being introduced to the k-nearest neighbor algorithm, we will use scikit-learn to perform classification.
Introducing the K-Nearest Neighbors Algorithm (KNN)
The goal of classification algorithms is to divide data so that we can determine which data points belong to which group.
Suppose that a set of classified points is given to us. Our task is to determine which class a new data point belongs to.
In order to train a k-nearest neighbor classifier (also referred to as KNN), we need to provide the corresponding class for each observation on the training set, that is, which group it belongs to. The goal of the algorithm is to find the relevant relationship or patterns between the features that will lead to this class. The k-nearest neighbors algorithm is based on a proximity measure that calculates the...