International Journal of Computer Applications |
Foundation of Computer Science (FCS), NY, USA |
Volume 186 - Number 33 |
Year of Publication: 2024 |
Authors: Ahmad Farhan AlShammari |
10.5120/ijca2024923894 |
Ahmad Farhan AlShammari . Implementation of Classification using K-Nearest Neighbors (KNN) in Python. International Journal of Computer Applications. 186, 33 ( Jul 2024), 19-24. DOI=10.5120/ijca2024923894
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.