Optimized Stacking Ensemble of Random Forest and XGBoost for Heart Disease Prediction
Keywords:
Heart disease prediction, Random Forest, XGBoost, Stacking ensemble, Hyperparameter optimizationAbstract
Heart disease remains a leading cause of death worldwide, highlighting the need for reliable tools to support early diagnosis and clinical decision-making. Although machine learning methods have been widely applied to heart disease prediction, many existing studies rely on default model settings, limited evaluation metrics, and a narrow range of algorithms. This study develops an optimized stacking ensemble model that combines Random Forest and XGBoost, with hyperparameters tuned using Optuna. The models were evaluated using a publicly available clinical dataset comprising 918 patient records with demographic and cardiovascular attributes. An 80:20 train-test split was applied, and performance was assessed using multiple metrics, including accuracy, macro and weighted F1-score, ROC-AUC, PR-AUC, and balanced accuracy. The results show that the optimized Random Forest achieved an accuracy of 89.1% and a ROC-AUC of 93.4%, while XGBoost achieved an accuracy of 88.6% with a similar ROC-AUC. The stacking ensemble provided the best overall performance, with an accuracy of 89.7%, macro F1-score of 89.6%, ROC-AUC of 93.6%, and PR-AUC of 93.5%. These findings suggest that combining optimized ensemble models can improve predictive performance compared to individual classifiers. However, the results are based on a secondary dataset and have not been validated in real clinical settings, which may limit their direct applicability in practice. Overall, this study contributes by demonstrating the value of hyperparameter optimization and model stacking, while adopting a broader evaluation framework for heart disease prediction.
References
Argulian, E., & Narula, J. (2021). Advanced cardiovascular imaging in clinical heart failure. JACC Heart Failure, 9(10), 699–709. https://doi.org/10.1016/j.jchf.2021-.06.016
Arunachalam, S. K., & Rekha, R. (2022). A novel approach for cardiovascular disease prediction using machine learning algorithms. Concurrency and Computation Practice and Experience, 34(19). https://doi.org/10.1002/cpe.7027
Heart Failure Prediction Dataset. (2021, September 10). Kaggle. https://www.-kaggle.com/datasets/fedesoriano/heart-failure-prediction
Javaid, M., Haleem, A., Singh, R. P., Suman, R., & Rab, S. (2022). Significance of machine learning in healthcare: Features, pillars and applications. International Journal of Intelligent Networks, 3, 58–73. https://doi.org/10.1016/j.ijin.2022-.05.002
Khan, A. A., Chaudhari, O., & Chandra, R. (2023). A review of ensemble learning and data augmentation models for class imbalanced problems: Combination, implementation and evaluation. Expert Systems with Applications, 244, 122778. https://doi.org/10.1016/j.eswa.2023.122778
Kokori, E., Patel, R., Olatunji, G., Ukoaka, B. M., Abraham, I. C., Ajekiigbe, V. O., Kwape, J. M., Babalola, A. E., Udam, N. G., & Aderinto, N. (2024). Machine learning in predicting heart failure survival: a review of current models and future prospects. Heart Failure Reviews. https://doi.org/10.1007/s10741-024-10474-y
Lam, C. S. P., Docherty, K. F., Ho, J. E., McMurray, J. J. V., Myhre, P. L., & Omland, T. (2023). Recent successes in heart failure treatment. Nature Medicine, 29(10), 2424–2437. https://doi.org/10.-1038/s41591-023-02567-2
Liang, M., Singh, S., & Huang, J. (2024). Implementing Machine Learning to Predict Survival Outcomes in Patients with Resected Pulmonary Large Cell Neuroendocrine Carcinoma. Expert Review of Anticancer Therapy, 24(10), 1041–1053. https://doi.org/10.1080/-14737140.2024.2401446
Mahmud, I., Kabir, M. M., Mridha, M. F., Alfarhood, S., Safran, M., & Che, D. (2023). Cardiac failure forecasting based on clinical data using a lightweight machine learning metamodel. Diagnostics, 13(15), 2540. https://doi.-org/10.3390/diagnostics13152540
Saqib, M., Perswani, P., Muneem, A., Mumtaz, H., Neha, F., Ali, S., & Tabassum, S. (2024). Machine learning in heart failure diagnosis, prediction, and prognosis: review. Annals of Medicine and Surgery. https://doi.org/10.1097/ms9.0000000000002138
Shahim, B., Kapelios, C. J., Savarese, G., & Lund, L. H. (2023). Global Public Health Burden of heart Failure: An updated review. Cardiac Failure Review, 9. https://doi.org/10.15420/cfr.2023.05
Downloads
Published
How to Cite
Issue
Section
License
Copyright (c) 2026 Researchers Journal of Science and Technology

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



