Comparison of Logistic Regression and K-Nearest Neighbor (KNN) Algorithms in a Heart Failure Prediction Dataset
DOI:
https://doi.org/10.56211/hanif.v3i1.53Keywords:
Heart Failure; K-Nearest Neighbor; Logistic Regression; Machine Learning ; Prediction
Abstract
Heart failure is one of the leading causes of death worldwide. Early detection of heart failure risk is crucial to minimize its serious consequences. This study aims to compare the performance of two machine learning algorithms, namely Logistic Regression and K-Nearest Neighbor (KNN), in predicting heart failure using a dataset from the Kaggle platform. The research stages include data preprocessing, normalization, splitting into training and testing data, model implementation, and evaluation using a confusion matrix. Evaluation is based on accuracy, precision, recall, and F1-score metrics. The results show that Logistic Regression achieved an accuracy of 88.04% with an execution time of 0.022 seconds, while KNN achieved an accuracy of 85.51% with an execution time of 0.158 seconds. Logistic Regression outperformed in recall and F1-score, making it more effective for early detection of heart failure. Therefore, Logistic Regression is considered more optimal than KNN in the context of this study. However, Logistic Regression is not always superior to K-Nearest Neighbor, as prediction results highly depend on the characteristics of the specific case.
Downloads
References
Buku
Indah Purnama Sari. Algoritma dan Pemrograman. Medan: UMSU Press, 2023, pp. 290.
Indah Purnama Sari. Buku Ajar Pemrograman Internet Dasar. Medan: UMSU Press, 2022, pp. 300.
Indah Purnama Sari. Buku Ajar Rekayasa Perangkat Lunak. Medan: UMSU Press, 2021, pp. 228.
Janner Simarmata Arsan Kumala Jaya, Syarifah Fitrah Ramadhani, Niel Ananto, Abdul Karim, Betrisandi, Muhammad Ilham Alhari, Cucut Susanto, Suardinata, Indah Purnama Sari, Edson Yahuda Putra. Komputer dan Masyarakat. Medan: Yayasan Kita Menulis, 2024, pp.162.
Mahdianta Pandia, Indah Purnama Sari, Alexander Wirapraja Fergie Joanda Kaunang, Syarifah Fitrah Ramadhani Stenly Richard Pungus, Sudirman, Suardinata Jimmy Herawan Moedjahedy, Elly Warni, Debby Erce Sondakh. Pengantar Bahasa Pemrograman Python. Medan : Yayasan Kita Menulis, 2024, pp.180
Zelvi Gustiana Arif Dwinanto, Indah Purnama Sari, Janner Simarmata Mahdianta Pandia, Supriadi Syam, Semmy Wellem Taju Fitrah Eka Susilawati, Asmah Akhriana, Rolly Junius Lontaan Fergie Joanda Kaunang. Perkembangan Teknologi Informatika. Medan: Yayasan Kita Menulis, 2024, pp.158
Jurnal
Sari, I.P., Hariani, P.P., Al-Khowarizmi, A., Ramadhani, F., Sulaiman, O.K., Satria, A, & Manurung, A.A. (2024). CLUSTERING HIV/AIDS DISEASE USING K-MEANS CLUSTERING ALGORITHM. Proceeding International Seminar on Islamic Studies 5 (1), 1668-1676
Sari, I.P., Ramadhani, F., Satria, A., & Sulaiman, O.K. Leukocoria Identification: A 5-Fold Cross Validation CNN and Adaboost Hybrid Approach. 2023 6th International Seminar on Research of Information Technology and Intelligent Systems (ISRITI), 486-491 DOI: https://doi.org/10.1109/ISRITI60336.2023.10467242
Manurung, A.A., Nasution, M.D., & Sari, I.P. (2023). Implementation of Fuzzy K-Nearest Neighbor Method in Dengue Disease Classification. 2023 11th International Conference on Cyber and IT Service Management (CITSM), 1-4 DOI: https://doi.org/10.1109/CITSM60085.2023.10455306
Sari, I.P., Ramadhani, F., Satria, A., & Apdilah, D. (2023). Implementasi Pengolahan Citra Digital dalam Pengenalan Wajah menggunakan Algoritma PCA dan Viola Jones. Hello World Jurnal Ilmu Komputer 2 (3), 146-157 DOI: https://doi.org/10.56211/helloworld.v2i3.346
Sari, I.P., Al-Khowarizmi, A, Sulaiman, O.K., & Apdilah, D. (2023). Implementation of Data Classification Using K-Means Algorithm in Clustering Stunting Cases. Journal of Computer Science, Information Technology and Telecommunication Engineering 4 (2), 402-412 DOI: https://doi.org/10.30596/jcositte.v4i2.15765
Sulaiman, O.K & Batubara, I.H. (2021). Implementation Data Mining For Level Analysis Traffic Violation By Algorithm Association Rule. Al'adzkiya International of Computer Science and Information Technology (AIoCSIT) Journal 2 (2), 128-135
Sari, I.P., Batubara, I.H., & Al-Khowarizmi, A. (2021). Sensitivity Of Obtaining Errors In The Combination Of Fuzzy And Neural Networks For Conducting Student Assessment On E-Learning. International Journal of Economic, Technology and Social Sciences (Injects) 2 (1), 331-338 DOI: https://doi.org/10.53695/injects.v2i1.412
Sari, I.P., Al-Khowarizmi, A., & Batubara, I.H. (2021). Cluster Analysis Using K-Means Algorithm and Fuzzy C-Means Clustering For Grouping Students' Abilities In Online Learning Process. Journal of Computer Science, Information Technology and Telecommunication Engineering 2 (1), 139-144
Apdilah, D., & Sari, I.P. (2021). Optimization Of The Fuzzy C-Means Cluster Center For Credit Data Grouping Using Genetic Algorithms. Al'adzkiya International of Computer Science and Information Technology (AIoCSIT) Journal 2 (2), 156-163
Downloads
Published
How to Cite
Issue
Section
License
Copyright (c) 2026 Julia Namira Nasution, Zainal Azis

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
Authors who publish in Hanif Journal of Information Systems agree to the following terms:
- Authors retain copyright and grant the journal right of first publication with the work simultaneously licensed under a Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) License that allows others to share the work with an acknowledgment of the work's authorship and initial publication in this journal.
- Authors are able to enter into separate, additional contractual arrangements for the non-exclusive distribution of the journal's published version of the work (e.g., post it to an institutional repository or publish it in a book), with an acknowledgment of its initial publication in this journal.
- Authors are permitted and encouraged to post their work online (e.g., in institutional repositories or on their website) prior to and during the submission process, as it can lead to productive exchanges, as well as earlier and greater citation of published work (See The Effect of Open Access).
Most read articles by the same author(s)
- Leony Ayu Diah Pasha, Zainal Azis, Predicting The Risk of Online Sales Fraud with The Naïve Bayes Approach on Facebook Social Media , Hanif Journal of Information Systems : Vol. 2 No. 2 (2025): February Edition
Similar Articles
- Ilham Prastia, Mulkan Azhari, Development of Virtual Reality-Based Computer Assembly Simulation Learning Media , Hanif Journal of Information Systems : Vol. 3 No. 1 (2025): August Edition
- Sabrina Meylani Pulungan, Mhd. Zulfansyuri Siambaton, Heri Santoso, Implementation of Linear Regression Algorithm in a Web-Based Major Prediction System for New Student Applicants at SMK N 1 Percut Sei Tuan , Hanif Journal of Information Systems : Vol. 3 No. 1 (2025): August Edition
- Arief Rahman Hakim, Ahmad Riady Hasibuan, Pipit Putri Hariani, Implementation of Multimedia Development Life Cycle in Learning Media Applications for Children with Mental Disabilities , Hanif Journal of Information Systems : Vol. 2 No. 1 (2024): August Edition
- Ahmad Asadel, Andi Zulherry, Detecting Zero-Width Characters Obfuscated in Phishing URLs using the XGBOOST Algorithm , Hanif Journal of Information Systems : Vol. 3 No. 1 (2025): August Edition
- Leony Ayu Diah Pasha, Zainal Azis, Predicting The Risk of Online Sales Fraud with The Naïve Bayes Approach on Facebook Social Media , Hanif Journal of Information Systems : Vol. 2 No. 2 (2025): February Edition
- Aulia Jannah, Abdillah Husaini, Aulia Ichsan, Mulkan Azhari, Implementation of Fuzzy K-Nearest Neighbor Method in Dengue Disiase Classification , Hanif Journal of Information Systems : Vol. 1 No. 2 (2024): February Edition
- Muhammad Nauval Asyqar Ridwan Ritonga, Halim Maulana, IoT Based Industrial Waste Monitoring System Design with Data Visualization on A Web Application Using The Supervised Learning Method , Hanif Journal of Information Systems : Vol. 3 No. 1 (2025): August Edition
- Al-Khowarizmi Al-Khowarizmi, Asrar Aspia Manurung, Mulkan Azhari, Design of an Application to Calculate Student Grades in Learning Logic Informatics Propositional Calculus Material , Hanif Journal of Information Systems : Vol. 1 No. 1 (2023): August Edition
- Malinar Nasution, Nizwardi Jalinus, The Philosophy and Foundations of Vocational Technology in Education with IT Integration , Hanif Journal of Information Systems : Vol. 1 No. 2 (2024): February Edition
- Aqilah Tahara, Irvan Irvan, Application of Data Mining in Predicting Demand for Blood Bags Based on Blood Type Using the Single Moving Average Method (SMA) , Hanif Journal of Information Systems : Vol. 3 No. 1 (2025): August Edition
You may also start an advanced similarity search for this article.









