Main Article Content


The heart is one of the most important organs for human; therefore, it needs to always be looked after and maintained properly. If it is not looked after and maintained properly, it will be at risk of disease. Currently, heart disease of various types still ranks first in deaths both in Indonesia and abroad. Various efforts continue to be developed by relevant scientists to detect it. Considering the importance of development efforts, in this research a machine-learning program was designing to classify heart disease as a detection system effort. In this article we will describe the analysis of the characteristics of the K-NN classifier, decision tree, random forest (accuracy, precision and recall), as well as determining the best classifier for detecting heart disease. To support the analysis of test results, Python and Google Colab programming has been implementation here. The best results obtained from the analysis of the application of these three models are the Decision Tree Classifier with accuracy, precision and recall values ​​of 90%, 87% and 88% respectively. These results indicate that this model has been successfully developing.


Machine learning, K-NN algorithm, decision tree, random forest

Article Details

How to Cite
Hartono A, Dewi LA, Yuniarti E, Salsabila Tahta Hirani Putri, Harahap TS. Machine Learning Classification for Detecting Heart Disease with K-NN Algorithm, Decision Tree and Random Forest. EKSAKTA [Internet]. 2023Dec.30 [cited 2024Jul.13];23(04):513-22. Available from:


  1. Aazmi, A., Zhou, H., Li, Y., Yu, M., Xu, X., Wu, Y., ... & Yang, H. (2022). Engineered vasculature for organ-on-a-chip systems. Engineering, 9, 131-147.
  2. Roberts, W., Salandy, S., Mandal, G., Holda, M. K., Tomaszewksi, K. A., Gielecki, J., ... & Loukas, M. (2019). Across the centuries: Piecing together the anatomy of the heart. Translational Research in Anatomy, 17, 100051.
  3. Alnour, H., Sharma, A., Halawa, A., & Alalawi, F. (2021). Global practices and policies of organ transplantation and organ trafficking. Experimental and clinical transplantation.
  4. Aubert, O., Yoo, D., Zielinski, D., Cozzi, E., Cardillo, M., Dürr, M., ... & Loupy, A. (2021). COVID-19 pandemic and worldwide organ transplantation: a population-based study. The Lancet Public Health, 6(10), e709-e719.
  5. Gun, S. Y., Lee, S. W. L., Sieow, J. L., & Wong, S. C. (2019). Targeting immune cells for cancer therapy. Redox biology, 25, 101174.
  6. Ghani, L., Susilawati, M. D., & Novriani, H. (2016). Faktor risiko dominan penyakit jantung koroner di Indonesia. Buletin Penelitian Kesehatan, 44(3), 153-164.
  7. Brunese, L., Martinelli, F., Mercaldo, F., & Santone, A. (2020). Deep learning for heart disease detection through cardiac sounds. Procedia Computer Science, 176, 2202-2211.
  8. Duchateau, N., King, A. P., & De Craene, M. (2020). Machine learning approaches for myocardial motion and deformation analysis. Frontiers in cardiovascular medicine, 6, 190.
  9. Gu, X., Jiang, Y., & Ni, T. (2020). Discriminative neural network for coronary heart disease detection. Journal of Medical Imaging and Health Informatics, 10(2), 463-468.
  10. Mercaldo, F., & Santone, A. (2020). Deep learning for image-based mobile malware detection. Journal of Computer Virology and Hacking Techniques, 16(2), 157-171.
  11. Pathak, A. K., & Arul Valan, J. (2019). A predictive model for heart disease diagnosis using fuzzy logic and decision tree. In Smart Computing Paradigms: New Progresses and Challenges: Proceedings of ICACNI 2018, Volume 2 (pp. 131-140). Singapore: Springer Singapore.
  12. Bhatt, C. M., Patel, P., Ghetia, T., & Mazzeo, P. L. (2023). Effective heart disease prediction using machine learning techniques. Algorithms, 16(2), 88.
  13. Brunese, L., Martinelli, F., Mercaldo, F., & Santone, A. (2020). Deep learning for heart disease detection through cardiac sounds. Procedia Computer Science, 176, 2202-2211.
  14. Uyar, K., & İlhan, A. (2017). Diagnosis of heart disease using genetic algorithm based trained recurrent fuzzy neural networks. Procedia computer science, 120, 588-593.
  15. Halim, W., & Mudjihartono, P. (2022). Kecerdasan Buatan dalam Teknologi Kedokteran: Survey Paper. KONSTELASI: Konvergensi Teknologi dan Sistem Informasi, 2(1).
  16. Sapra, V., Sapra, L., Bhardwaj, A., Bharany, S., Saxena, A., Karim, F. K., ... & Mohamed, A. W. (2023). Integrated approach using deep neural network and CBR for detecting severity of coronary artery disease. Alexandria Engineering Journal, 68, 709-720.
  17. Ueda, D., Matsumoto, T., Ehara, S., Yamamoto, A., Walston, S. L., Ito, A., ... & Miki, Y. (2023). Artificial intelligence-based model to classify cardiac functions from chest radiographs: a multi-institutional, retrospective model development and validation study. The Lancet Digital Health, 5(8), e525-e533.
  18. Tajudin, T., & Nugroho, I. D. W. (2020). Analisis Kombinasi Penggunaan Obat pada Pasien Jantung Koroner (Coronary Heart Disease) dengan Penyakit Penyerta di Rumah Sakit X Cilacap tahun 2019. Pharmaqueous: Jurnal Ilmiah Kefarmasian, 1(2), 6-13.
  19. Kumar, N., & Makkar, A. (2020). Machine learning in cognitive IoT. CRC Press.
  20. Heryadi, Y., & Wahyono, T. (2020). Machine learning konsep dan implementasi. Yogyakarta: Gava Media.
  21. Soofi, A. A., & Awan, A. (2017). Classification techniques in machine learning: applications and issues. Journal of Basic & Applied Sciences, 13(1), 459-465.
  22. Sutisna, S., & Yuniar, M. N. (2023). Klasifikasi Kualitas Air Bersih Menggunakan Metode Naïve baiyes. Jurnal Sains dan Teknologi, 5(1), 243-246.
  23. Xu, D., Shi, Y., Tsang, I. W., Ong, Y. S., Gong, C., & Shen, X. (2019). Survey on multi-output learning. IEEE transactions on neural networks and learning systems, 31(7), 2409-2429.
  24. Normah, N., Rifai, B., Vambudi, S., & Maulana, R. (2022). Analisa Sentimen Perkembangan Vtuber Dengan Metode Support Vector Machine Berbasis SMOTE. Jurnal Teknik Komputer AMIK BSI, 8(2), 174-180.
  25. Uddin, K. M. M., Ripa, R., Yeasmin, N., Biswas, N., & Dey, S. K. (2023). Machine learning-based approach to the diagnosis of cardiovascular vascular disease using a combined dataset. Intelligence-Based Medicine, 7, 100100.
  26. D’Souza, A. (2015). Heart disease prediction using data mining techniques. International Journal of Research in Engineering and Science (IJRES) ISSN (Online), 2320-9364.
  27. Loesche, W. J. (1994). Periodontal disease as a risk factor for heart disease. Compendium (Newtown, Pa.), 15(8), 976-978.
  28. Learning, M. (2017). Heart disease diagnosis and prediction using machine learning and data mining techniques: a review. Advances in Computational Sciences and Technology, 10(7), 2137-2159.
  29. Chandrasekhar, N., & Peddakrishna, S. (2023). Enhancing Heart Disease Prediction Accuracy through Machine Learning Techniques and Optimization. Processes, 11(4), 1210.
  30. Pathan, M. S., Nag, A., Pathan, M. M., & Dev, S. (2022). Analyzing the impact of feature selection on the accuracy of heart disease prediction. Healthcare Analytics, 2, 100060.
  31. Sivapalan, G., Nundy, K. K., Dev, S., Cardiff, B., & John, D. (2022). ANNet: a lightweight neural network for ECG anomaly detection in IoT edge sensors. IEEE Transactions on Biomedical Circuits and Systems, 16(1), 24-35.
  32. Sivapalan, G., Nundy, K. K., James, A., Cardiff, B., & John, D. (2023). Interpretable rule mining for real-time ECG anomaly detection in IoT Edge Sensors. IEEE Internet of Things Journal.
  33. Gavhane, A., Kokkula, G., Pandya, I., & Devadkar, K. (2018, March). Prediction of heart disease using machine learning. In 2018 second international conference on electronics, communication and aerospace technology (ICECA) (pp. 1275-1278). IEEE.
  34. Kumar, N. K., Sindhu, G. S., Prashanthi, D. K., & Sulthana, A. S. (2020, March). Analysis and prediction of cardio vascular disease using machine learning classifiers. In 2020 6th International Conference on Advanced Computing and Communication Systems (ICACCS) (pp. 15-21). IEEE.
  35. Yeom, S., Giacomelli, I., Fredrikson, M., & Jha, S. (2018, July). Privacy risk in machine learning: Analyzing the connection to overfitting. In 2018 IEEE 31st computer security foundations symposium (CSF) (pp. 268-282). IEEE.
  36. Sharma, A., Kumar, N., Kumar, A., Dikshit, K., Tharani, K., & Singh, B. (2021). Comparative investigation of machine learning algorithms for detection of epileptic seizures. Intelligent Decision Technologies, 15(2), 269-279.
  37. Remeseiro, B., & Bolon-Canedo, V. (2019). A review of feature selection methods in medical applications. Computers in biology and medicine, 112, 103375.