A COMPARATIVE STUDY OF K-NEAREST NEIGHBORS AND RANDOM FOREST CLASSIFIERS ON DIABETES - Sudiatmika, I Putu Gede Abdi; Saputra, Putu Satya; albaab, Mochammad Rifki Ulil (Proceeding International Conference on Information Technology, Multimedia, Architecture, Design, and E-Business, 2024)
The early detection of diabetes is crucial for effective management and prevention of complications associated with this chronic health condition. Machine learning techniques offer promising approaches for developing predictive models that can support medical decision-making. This study investigates the performance of two popular classification algorithms—K-Nearest Neighbors (KNN) and Random Forest—in predicting diabetes based on a dataset comprising key health indicators, including glucose levels, blood pressure, insulin, BMI, and age. The primary goal is to assess which model provides higher predictive accuracy and reliability for medical applications.The research employs data preprocessing steps, such as handling missing values and standardizing feature scales, to ensure model consistency. Hyperparameter tuning is performed to optimize the settings for both algorithms. For KNN, the optimal number of neighbors and weighting scheme are determined, while Random Forest is fine-tuned by adjusting the number of trees, maximum depth, and minimum samples required for a split. These optimizations are implemented through grid search cross-validation to enhance model performance.The models are evaluated using accuracy, precision, recall, and F1 score as key metrics. Results show that the KNN model achieves an accuracy of 70.13%, while Random Forest reaches a higher accuracy of 75.97%. Additionally, Random Forest demonstrates better recall and F1 scores, indicating a stronger ability to correctly identify positive diabetes cases and maintain a balance between precision and recall.. This demonstrates Random Forest’s robustness in handling complex, multivariate data, which is advantageous for accurately classifying diabetes cases. In contrast, KNN shows limitations in sensitivity, potentially due to its reliance on distance metrics, which may not fully capture the dataset’s inherent complexity.This study concludes that Random Forest is a more suitable model for diabetes prediction in this dataset, offering reliable and interpretable results that could support healthcare providers in early diagnosis. Future research may explore other advanced algorithms, data balancing methods, and feature engineering techniques to further improve prediction accuracy.