Classification of Diabetes Mellitus using the K-Nearest Neighbor (KNN) Algorithm: A Case Study of Patient Data at Salatiga Regional Hospital - Gwen Theresia Grandis Aritonang; Magdalena A. Ineke Pakereng (Universitas Islam Indragiri, 2026)
One of the most common metabolic diseases in Indonesia, including at RSUD Salatiga, is Diabetes Mellitus. Early diagnosis of this disease is crucial to prevent the development of more severe complications; however, this process is often challenging because the initial symptoms are difficult to recognize. This study implements the K-Nearest Neighbor (KNN) algorithm as a classification technique for predicting diabetes mellitus risk based on clinical data from patients at RSUD Salatiga. The dataset used in this research included variables such as gender, age, hypertension history, glucose level, HbA1c level, smoking status, liver disease history, and Body Mass Index (BMI). The research stages consisted of data collection, preprocessing (data cleaning, normalization, and variable encoding), feature selection, and optimization of the k parameter. Model evaluation was conducted using a confusion matrix with performance metrics including accuracy, precision, recall, and F1-score. The results indicate that the KNN algorithm achieved the highest accuracy of 92.08% when feature selection was applied with k = 6. This improvement demonstrates that both k-parameter optimization and feature selection significantly affect model performance. Therefore, the KNN algorithm can serve as an effective early prediction tool to assist medical personnel in identifying diabetes mellitus patients, enabling faster and more accurate interventions.