Comparative Analysis of K-Nearest Neighbor and Fuzzy K-Nearest Neighbor for Diabetes Classification Using the Pima Indians Diabetes Dataset

Article Sidebar

Published: Sep 8, 2026

Abstract:

Background of study: Diabetes mellitus remains one of the most common chronic diseases worldwide; thus, early and accurate prediction is critical for appropriate intervention.


Aims: This study examines the performance of the standard K-Nearest Neighbor (KNN) method and its fuzzy counterpart, Fuzzy K-Nearest Neighbor (Fuzzy KNN), in classifying diabetes status and compares their behavior across different neighborhood sizes (k).


Methods: The Pima Indians Diabetes Dataset (768 cases, 8 clinical variables) was used. Zero values in physiologically implausible attributes (glucose, blood pressure, skin thickness, insulin, and BMI) were treated as missing values based on the physiological interpretation of these variables and imputed using class-wise medians. The dataset was then split into 80% training and 20% testing subsets using stratified sampling to preserve class proportions. Five-fold cross-validation on the training set was used to determine the optimal number of neighbors (k), after which both models were evaluated on the held-out test set using accuracy, precision, recall, and F1-score.


Result: The optimal k varied between models: k=15 for KNN and k=3 for Fuzzy KNN. Cross-validation accuracy across the tested k range (3–21) remained relatively stable for both methods (approximately 0.80–0.83), indicating that performance was not highly sensitive to k selection. On the test set, Fuzzy KNN outperformed conventional KNN across all evaluation metrics (accuracy: 0.779 vs. 0.773; precision: 0.679 vs. 0.673; recall: 0.704 vs. 0.685; F1-score: 0.691 vs. 0.679).


Conclusion: For the Pima Indians Diabetes Dataset, Fuzzy KNN achieved slightly better performance than conventional KNN across all evaluated metrics on the held-out test set. These findings indicate that distance-based membership weighting may provide a modest advantage over crisp majority voting for diabetes classification in this dataset.

Keywords: Classification, Diabetes prediction, Fuzzy KNN, K-Nearest Neighbor, Machine learning

Authors:
1 . Ulfasari Rafflesia
2 . Siska Dwi Kumala
3 . Ratna Widayati
4 . Aisyah Nooravieta S.
5 . Oon Septa
How to Cite
Rafflesia, U., Kumala, S. D., Widayati, R., Nooravieta S., A., & Septa, O. (2026). Comparative Analysis of K-Nearest Neighbor and Fuzzy K-Nearest Neighbor for Diabetes Classification Using the Pima Indians Diabetes Dataset. Journal of Innovation in Applied Natural Science, 2(2), 80–89. https://doi.org/10.58723/jinas.v2i2.223
Download

Downloads

Download data is not yet available.
Licensed

Copyright (c) 2026 Ulfasari Rafflesia, Siska Dwi Kumala, Ratna Widayati, Aisyah Nooravieta S., Oon Septa

Section
Research Articles

References

Addou, M., Mermri, E. B., & Gabli, M. (2026). Feature-Importance-Weighted Distance Metrics for Enhanced k-Nearest Neighbors Classification in Medical Diagnosis. Human-Centric Intelligent Systems, 6(2), 283–300. https://doi.org/10.1007/s44230-026-00147-4

Akhtar, M., Quadir, A., Tanveer, M., & Arshad, M. (2024). Flexi-Fuzz least squares SVM for Alzheimer’s diagnosis: Tackling noise, outliers, and class imbalance. In arXiv (Cornell University). Cornell University. https://doi.org/10.48550/arxiv.2410.14207

Amer, A. A., Ravana, S. D., & Habeeb, R. A. A. (2025). Effective k-nearest neighbor models for data classification enhancement. Journal of Big Data, 12(1), 86. https://doi.org/10.1186/s40537-025-01137-2

Aria, A. O. H., Mulyana, D., Rifa’i, A. R., & Ikhsan, M. (2025). Performance Comparison of K-Nearest Neighbor, Decision Tree, and Support Vector Machine Algorithms for Diabetes Classification. CoreID Journal, 3(3), 93–98. https://doi.org/10.60005/coreid.v3i3.139

Arowolo, M. O., Adebiyi, M. O., Adebiyi, A. A., & Olugbara, O. O. (2021). Optimized hybrid investigative based dimensionality reduction methods for malaria vector using KNN classifier. Journal Of Big Data, 8(1). https://doi.org/10.1186/s40537-021-00415-z

Azevedo, B. F., Rocha, A. M. A. C., & Pereira, A. I. (2024). Hybrid approaches to optimization and machine learning methods: a systematic literature review. Machine Learning, 113(7), 4055–4097. https://doi.org/10.1007/s10994-023-06467-x

Baghdadi, N. A., Abdelaliem, S. M. F., Malki, A., Gad, I., Ewis, A. A., & Atlam, E.-S. (2023). Advanced machine learning techniques for cardiovascular disease early detection and diagnosis. Journal Of Big Data, 10(1). https://doi.org/10.1186/s40537-023-00817-1

Bian, Z., Vong, C. M., Wong, P. K., & Wang, S. (2022). Fuzzy KNN Method With Adaptive Nearest Neighbors. IEEE Transactions on Cybernetics, 52(6), 5380–5393. https://doi.org/10.1109/TCYB.2020.3031610

Bonmati, E., Hu, Y., Grimwood, A., Johnson, G., Goodchild, G., Keane, M. G., Gurusamy, K. S., Davidson, B. R., Clarkson, M. J., Pereira, S. P., & Barratt, D. C. (2021). Voice-Assisted Image Labeling for Endoscopic Ultrasound Classification Using Neural Networks. ArXiv (Cornell University), 41(6), 1311–1319. https://doi.org/10.1109/tmi.2021.3139023

Calster, B. Van, Steyerberg, E. W., Wynants, L., & Smeden, M. van. (2023). There is no such thing as a validated prediction model. BMC Medicine, 21(1), 70. https://doi.org/10.1186/s12916-023-02779-w

Chandrasekaran, S., Dutt, V., Vyas, N., & Anand, A. (2023). Fuzzy KNN Implementation for Early Parkinson’s Disease Prediction. 2023 7th International Conference on Computing Methodologies and Communication (ICCMC), 896–901.https://doi.org/10.1109/ICCMC56507.2023.10083522

Choubey, D. K., Kumar, M., Shukla, V., Tripathi, S., & Dhandhania, V. K. (2020). Comparative Analysis of Classification Methods with PCA and LDA for Diabetes. Current Diabetes Reviews, 16(8), 833–850. https://doi.org/10.2174/1573399816666200123124008

Dinesh, P., Vickram, A. S., & Kalyanasundaram, P. (2024). Medical image prediction for diagnosis of breast cancer disease comparing the machine learning algorithms: SVM, KNN, logistic regression, random forest and decision tree to measure accuracy. 020140. https://doi.org/10.1063/5.0203746

Fadaei-Kermani, E., & Ghaeini‐Hessaroeyeh, M. (2020). Fuzzy nearest neighbor approach for drought monitoring and assessment. Applied Water Science, 10(6). https://doi.org/10.1007/s13201-020-01212-4

Fan, C. (2025). Optimization and performance evaluation of machine learning classifiers for predicting construction quality and schedule. Automation in Construction, 179, 106470. https://doi.org/10.1016/j.autcon.2025.106470

González-Martínez, S., García, S., Li, S.-T., John, R., & Herrera, F. (2020). Fuzzy k-Nearest Neighbors with monotonicity constraints: Moving towardsn the robustness of monotonic noise. In arXiv (Cornell University). Cornell University. https://doi.org/10.48550/arxiv.2003.02601

Halder, R. K., Uddin, M. N., Uddin, M. A., Aryal, S., & Khraisat, A. (2024). Enhancing K-nearest neighbor algorithm: a comprehensive review and performance analysis of modifications. Journal of Big Data, 11(1), 113. https://doi.org/10.1186/s40537-024-00973-y

Hameed, E. M., & Joshi, H. (2024). Improving Diabetes Prediction by Selecting Optimal K and Distance Measures in KNN Classifier. Journal of Techniques, 6(3), 19–25. https://doi.org/10.51173/jt.v6i3.2587

Kaur, J., & Khehra, B. S. (2022). Fuzzy Logic and Hybrid based Approaches for the Risk of Heart Disease Detection: State-of-the-Art Review. Journal of The Institution of Engineers (India): Series B, 103(2), 681–697. https://doi.org/10.1007/s40031-021-00644-z

Lahmiri, S. (2023). Integrating convolutional neural networks, kNN, and Bayesian optimization for efficient diagnosis of Alzheimer’s disease in magnetic resonance images. Biomedical Signal Processing and Control, 80, 104375. https://doi.org/10.1016/j.bspc.2022.104375

Li, Y., Zhao, D., Xu, Z., Heidari, A. A., Chen, H., Jiang, X., Liu, Z., Wang, M., Zhou, Q., & Xu, S. (2023). bSRWPSO-FKNN: A boosted PSO with fuzzy K-nearest neighbor classifier for predicting atopic dermatitis disease. Frontiers in Neuroinformatics, 16, 1063048. https://doi.org/10.3389/fninf.2022.1063048

Lohani, B. P., Dagur, A., & Shukla, D. K. (2025). Synergistic ensemble classification framework: utilizing a soft voting algorithm for enhanced prediction and diagnosis of diabetes mellitus. Indonesian Journal of Electrical Engineering and Computer Science, 37(3), 1945. https://doi.org/10.11591/ijeecs.v37.i3.pp1945-1953

Lohrmann, C., Lohrmann, A., & Kumbure, M. M. (2025). On the benefit of feature selection and ensemble feature selection for fuzzy k-nearest neighbor classification. Applied Soft Computing, 171, 112784. https://doi.org/10.1016/j.asoc.2025.112784

Mailagaha Kumbure, M., & Luukka, P. (2022). A generalized fuzzy k-nearest neighbor regression model based on Minkowski distance. Granular Computing, 7(3), 657–671. https://doi.org/10.1007/s41066-021-00288-w

Mailagaha Kumbure, M., Luukka, P., & Collan, M. (2020). A new fuzzy k-nearest neighbor classifier based on the Bonferroni mean. Pattern Recognition Letters, 140, 172–178. https://doi.org/10.1016/j.patrec.2020.10.005

Mayawi, M., & Subanar, S. (2025). Parameter Independent Fuzzy Weighted K-Nearest Neighbor. Media Statistika, 17(2), 162–172. https://doi.org/10.14710/medstat.17.2.162-172

Pikula, A., Gulati, M., Bonnet, J. P., Ibrahim, S., Chamoun, S., Freeman, A. M., & Reddy, K. (2024). Promise of Lifestyle Medicine for Heart Disease, Diabetes Mellitus, and Cerebrovascular Diseases. Mayo Clinic Proceedings: Innovations, Quality & Outcomes, 8(2), 151–165. https://doi.org/10.1016/j.mayocpiqo.2023.11.005

Ren, J., Carroll, H., McCarthy, K., Allen, J., Tam, J., Philip, J., Mehta, M., & Clark, D. W. (2026). A kNN based machine learning approach to automating causality assessment of adverse events. Scientific Reports, 16(1). https://doi.org/10.1038/s41598-026-40267-2

Sachdeva, R. K., Bathla, P., Rani, P., Lamba, R., Ghantasala, P., & Nassar, I. F. (2025). No TitleA Novel K Nearest Neighbor Classifier for Lung Cancer Disease Diagnosis. Chemotherapy: Open Access, 13(1), 1–9. https://doi.org/10.35248/2167-7700.25.13.231

Salem, H., Shams, M. Y., Elzeki, O. M., Abd Elfattah, M., F. Al-Amri, J., & Elnazer, S. (2022). Fine-Tuning Fuzzy KNN Classifier Based on Uncertainty Membership for the Medical Diagnosis of Diabetes. Applied Sciences, 12(3), 950. https://doi.org/10.3390/app12030950

Siyar, S., Azarnoush, H., Rashidi, S., Winkler-Schwartz, A., Bissonnette, V., Ponnudurai, N., & Maestro, R. F. Del. (2020). Machine learning distinguishes neurosurgical skill levels in a virtual reality tumor resection task. ArXiv (Cornell University), 58(6), 1357–1367. https://doi.org/10.1007/s11517-020-02155-3

Stefane Souza, V., & Araújo Lima, D. (2024). Cardiac Disease Diagnosis Using K-Nearest Neighbor Algorithm: A Study on Heart Failure Clinical Records Dataset. Artificial Intelligence and Applications, 3(1), 56–71. https://doi.org/10.47852/bonviewAIA42022045

Suárez, J. L., González-Almagro, G., García, S., & Herrera, F. (2024). Metric learning for monotonic classification: turning the space up to the limits of monotonicity. Applied Intelligence, 54(5), 4443–4466. https://doi.org/10.1007/s10489-024-05371-8

Suyal, M., & Goyal, P. (2022). A Review on Analysis of K-Nearest Neighbor Classification Machine Learning Algorithms based on Supervised Learning. International Journal of Engineering Trends and Technology, 70(7), 43–48. https://doi.org/10.14445/22315381/IJETT-V70I7P205

Syriopoulos, P. K., Kalampalikis, N. G., Kotsiantis, S. B., & Vrahatis, M. N. (2025). kNN Classification: a review. Annals of Mathematics and Artificial Intelligence, 93(1), 43–75. https://doi.org/10.1007/s10472-023-09882-x

Szczuko, P., Kurowski, A., Odya, P., Czyżewski, A., Kostek, B., Graff, B., & Narkiewicz, K. (2021). Mining Knowledge of Respiratory Rate Quantification and Abnormal Pattern Prediction. Cognitive Computation, 14(6), 2120–2140. https://doi.org/10.1007/s12559-021-09908-8

Tasin, I., Nabil, T. U., Islam, S., & Khan, R. (2023). Diabetes prediction using machine learning and explainable AI techniques. Healthcare Technology Letters, 10(1–2), 1–10. https://doi.org/10.1049/htl2.12039

Uddin, S., Haque, I., Lu, H., Moni, M. A., & Gide, E. (2022). Comparative performance analysis of K-nearest neighbour (KNN) algorithm and its different variants for disease prediction. Scientific Reports, 12(1), 6256. https://doi.org/10.1038/s41598-022-10358-x

Vommi, A. M., & Krishna, B. T. (2024). An equilibrium optimizer-based parameter independent fuzzy kNN classifier for classification of medical datasets. Soft Computing, 28(20), 11757–11765. https://doi.org/10.1007/s00500-024-09941-3

Widyadhana, A., Putra, C. B. P., Indraswari, R., & Arifin, A. Z. (2021). A Bonferroni Mean Based Fuzzy K Nearest Centroid Neighbor Classifier. Jurnal Ilmu Komputer Dan Informasi, 14(1), 65–71. https://doi.org/10.21609/jiki.v14i1.959

Wu, W., Keller, J. M., Skubic, M., Popescu, M., & Lane, K. R. (2021). Early Detection of Health Changes in the Elderly Using In-Home Multi-Sensor Data Streams. ACM Transactions on Computing for Healthcare, 2(3), 1–23. https://doi.org/10.1145/3448671

Wu, X., Ding, Y., Wang, L., Ding, D., & Zhang, H. (2026). A novel Neutrosophic Transformer for handling imbalanced data. Journal of King Saud University - Computer and Information Sciences. https://doi.org/10.1007/s44443-026-00664-z

Zhang, S. (2022). Challenges in KNN Classification. IEEE Transactions on Knowledge and Data Engineering, 34(10), 4663–4675. https://doi.org/10.1109/TKDE.2021.3049250