Implementation of Classification using K-Nearest Neighbors (KNN) in Python

Ahmad Farhan AlShammari · International Journal of Computer Applications · 2024

The goal of this research is to develop a classification program using K-Nearest Neighbors (KNN) method in Python.Classification helps to predict the categories of data by comparing the features of test and input data.The distances between the test and input data are measured and sorted to find the (k) nearest neighbors.Then, the predicted category of data is determined by the most common vote among the nearest neighbors.The basic steps of classification using k-nearest neighbors are explained: preparing observed data, preparing test data, computing distances, sorting distances, computing neighbors, performing majority voting, computing predictions, computing confusion matrix, and computing model accuracy.The developed program was tested on an experimental dataset.The program successfully performed the basic steps of classification using k-nearest neighbors and provided the required results.

Read the paper · More papers on PaperTik