Prediksi Risiko Serangan Jantung Menggunakan Algoritma Random Forest Berdasarkan Data Kesehatan Masyarakat Indonesia
Abstract
Cardiovascular disease, particularly heart attacks, is a leading cause of death in Indonesia. This study aims to develop a heart attack risk prediction model using the Random Forest algorithm based on public health data. The dataset consists of 158,355 respondents with demographic variables, health conditions, lifestyle, and medical history. The model was developed using the RandomForestClassifier with 300 trees, a maximum depth of 20, a minimum of five samples per leaf, and balanced class weights. Probability predictions were converted to binary classes with a threshold of 0.4 to balance sensitivity and specificity. The evaluation results showed an accuracy of 70.09%, a sensitivity of 81.31%, a specificity of 63.44%, and an AUC of 0.81. Feature importance analysis identified hypertension, a history of heart disease, smoking status, and diabetes as the most influential factors. These findings indicate that the Random Forest algorithm is capable of producing reliable and interpretable predictions to support early detection of heart attack risk in the Indonesian population.
References
“Cardiovascular diseases (CVDs).” Accessed: Nov. 08, 2025. [Online]. Available: https://www.who.int/news-room/fact-sheets/detail/cardiovascular-diseases-(cvds)
“Penyakit Jantung Penyebab Utama Kematian, Kemenkes Perkuat Layanan Primer.” Accessed: Nov. 08, 2025. [Online]. Available: https://kemkes.go.id/eng/penyakit-jantung-penyebab-utama-kematian-kemenkes-perkuat-layanan-primer
O. R. Olaniran, S. F. Olaniran, A. R. R. Alzahrani, N. M. S. Alharbi, and A. A. Alzahrani, “Random Forest Adaptation for High-Dimensional Count Regression,” Math. 2025, Vol. 13, Page 3041, vol. 13, no. 18, p. 3041, Sep. 2025, doi: 10.3390/MATH13183041.
D. Priyanto, H. Hairani, K. Marzuki, and M. Innuddin, “Optimization of Random Forest for Health Data Classification Using PCA and K-Means SMOTE-ENN,” Eng. Technol. Appl. Sci. Res., vol. 15, no. 5, pp. 27646–27652, Oct. 2025, doi: 10.48084/ETASR.12976.
X. Wang and Z. Cheng, “Cross-Sectional Studies: Strengths, Weaknesses, and Recommendations,” Chest, vol. 158, no. 1, pp. S65–S71, Jul. 2020, doi: 10.1016/j.chest.2020.03.012.
“Heart Attack Prediction in Indonesia.” Accessed: Nov. 08, 2025. [Online]. Available: https://www.kaggle.com/datasets/ankushpanday2/heart-attack-prediction-in-indonesia
T. Emmanuel, T. Maupong, D. Mpoeleng, T. Semong, B. Mphago, and O. Tabona, “A survey on missing data in machine learning,” J. Big Data 2021 81, vol. 8, no. 1, pp. 1–37, Oct. 2021, doi: 10.1186/S40537-021-00516-9.
E. Alshdaifat, D. Alshdaifat, A. Alsarhan, F. Hussein, and S. M. F. S. El-Salhi, “The Effect of Preprocessing Techniques, Applied to Numeric Features, on Classification Algorithms’ Performance,” Data 2021, Vol. 6, Page 11, vol. 6, no. 2, p. 11, Jan. 2021, doi: 10.3390/DATA6020011.
S. Matharaarachchi, M. Domaratzki, and S. Muthukumarana, “Enhancing SMOTE for imbalanced data with abnormal minority instances,” Mach. Learn. with Appl., vol. 18, p. 100597, Dec. 2024, doi: 10.1016/J.MLWA.2024.100597.
Y. Zhang, L. Deng, and B. Wei, “Imbalanced Data Classification Based on Improved Random-SMOTE and Feature Standard Deviation,” Math. 2024, Vol. 12, Page 1709, vol. 12, no. 11, p. 1709, May 2024, doi: 10.3390/MATH12111709.
L. Breiman, “Random forests,” Mach. Learn., vol. 45, no. 1, pp. 5–32, Oct. 2001, doi: 10.1023/A:1010933404324/METRICS.
P. Probst, “Hyperparameters, tuning and meta-learning for random forest and other machine learning algorithms,” Jul. 2019, doi: 10.5282/EDOC.24557.
T. Fawcett, “An introduction to ROC analysis,” Pattern Recognit. Lett., vol. 27, no. 8, pp. 861–874, Jun. 2006, doi: 10.1016/J.PATREC.2005.10.010.
O. Rainio, J. Teuho, and R. Klén, “Evaluation metrics and statistical tests for machine learning,” Sci. Reports 2024 141, vol. 14, no. 1, pp. 1–14, Mar. 2024, doi: 10.1038/s41598-024-56706-x.
M. L. Wallace et al., “Use and misuse of random forest variable importance metrics in medicine: demonstrations through incident stroke prediction,” BMC Med. Res. Methodol. 2023 231, vol. 23, no. 1, pp. 1–12, Jun. 2023, doi: 10.1186/S12874-023-01965-X.
L. Yang et al., “Study of cardiovascular disease prediction model based on random forest in eastern China,” Sci. Reports 2020 101, vol. 10, no. 1, pp. 1–8, Mar. 2020, doi: 10.1038/s41598-020-62133-5.
C. Yan, E. Gao, Y. Xing, J. Wang, and S. Liu, “Machine Learning Models for Cardiovascular Disease Prediction: A Comparative Study”, doi: 10.1101/2024.05.27.596092.
H. E. Bays et al., “Ten things to know about ten cardiovascular disease risk factors – 2022,” Am. J. Prev. Cardiol., vol. 10, p. 100342, Jun. 2022, doi: 10.1016/J.AJPC.2022.100342.
Copyright (c) 2026 Naufal Faisa, Ulfa Khaira, Akhiyar Waladi, Pradita Eko

This work is licensed under a Creative Commons Attribution 4.0 International License.