Komparasi Random Forest dan XGBoost Berbasis SMOTE dalam Penanganan Ketidakseimbangan Data untuk Prediksi Risiko Stroke


  • Chairunnisa Desti Arzety Universitas Sriwijaya, Palembang, Indonesia
  • Bayu Wijaya Putra * Mail Universitas Sriwijaya, Palembang, Indonesia
  • M Rudi Sanjaya Universitas Sriwijaya, Palembang, Indonesia
  • Dwi Rosa Indah Universitas Sriwijaya, Palembang, Indonesia
  • (*) Corresponding Author
Keywords: Stroke; Machine Learning; Random Forest; XGBoost; SMOTE; Class Imbalance

Abstract

Class imbalance is one of the main obstacles in building machine learning models for stroke prediction, as this condition tends to make models learn the characteristics of the majority class more dominantly than those of the minority class. This study aims to examine the comparison and evaluate the performance between the Random Forest and XGBoost algorithms in predicting stroke risk, by applying SMOTE as a data balancing technique. The study uses the Kaggle Stroke Prediction Dataset, consisting of 5,110 patient records. The research stages include data cleaning, categorical feature representation using TF-IDF, numerical feature normalization through Standard Scaling, data splitting using the Stratified Train-Test Split technique, application of SMOTE on the training data, and model development using the Random Forest and XGBoost algorithms. Model performance was evaluated using several metrics, namely Accuracy, Precision, Recall, F1-Score, ROC-AUC, Confusion Matrix, and Feature Importance. The test results show that XGBoost achieved a Recall of 0.1600, an F1-Score of 0.1702, and an ROC-AUC of 0.7877—all higher than those of Random Forest, which achieved a Recall of 0.0800, an F1-Score of 0.1111, and an ROC-AUC of 0.7068. Although these results represent an improvement over Random Forest, the still relatively low Recall and F1-Score values indicate that the model’s ability to detect stroke cases is not yet optimal and therefore requires further development. Furthermore, SMOTE was applied to balance the class distribution in the training data so that the model’s learning process would give greater attention to the minority class. This study contributes by implementing a consistent preprocessing pipeline, including data cleaning, Standard Scaling, TF-IDF-based categorical feature representation, Stratified Train-Test Split, and SMOTE on the training data, enabling a more objective comparison of Random Forest and XGBoost through the use of comprehensive evaluation metrics on an imbalanced stroke prediction dataset.

Downloads

Download data is not yet available.

References

T. Vu et al., “Machine Learning Approaches for Stroke Risk Prediction: Findings from the Suita Study,” JCDD, vol. 11, no. 7, p. 207, Jul. 2024, doi: 10.3390/jcdd11070207.

A. Papadopoulou, D. Harding, G. Slabaugh, E. Marouli, and P. Deloukas, “Prediction of atrial fibrillation and stroke using machine learning models in UK Biobank,” Heliyon, vol. 10, no. 7, p. e28034, Apr. 2024, doi: 10.1016/j.heliyon.2024.e28034.

S. Sahriar et al., “Unlocking stroke prediction: Harnessing projection-based statistical feature extraction with ML algorithms,” Heliyon, vol. 10, no. 5, p. e27411, Mar. 2024, doi: 10.1016/j.heliyon.2024.e27411.

P. Bathla and R. Kumar, “A hybrid system to predict brain stroke using a combined feature selection and classifier,” Intelligent Medicine, vol. 4, no. 2, pp. 75–82, May 2024, doi: 10.1016/j.imed.2023.06.002.

P. Chakraborty et al., “Predicting stroke occurrences: a stacked machine learning approach with feature selection and data preprocessing,” BMC Bioinformatics, vol. 25, no. 1, p. 329, Oct. 2024, doi: 10.1186/s12859-024-05866-8.

R. Wijaya, F. Saeed, P. Samimi, A. M. Albarrak, and S. N. Qasem, “An Ensemble Machine Learning and Data Mining Approach to Enhance Stroke Prediction,” Bioengineering, vol. 11, no. 7, p. 672, Jul. 2024, doi: 10.3390/bioengineering11070672.

I. Abousaber, “A Novel Explainable Attention-Based Meta-Learning Framework for Imbalanced Brain Stroke Prediction,” Sensors, vol. 25, no. 6, p. 1739, Mar. 2025, doi: 10.3390/s25061739.

J. Lee, K. M. Park, and S. Park, “Interpretable machine learning for prediction of clinical outcomes in acute ischemic stroke,” Front. Neurol., vol. 14, p. 1234046, Sep. 2023, doi: 10.3389/fneur.2023.1234046.

P. N. Srinivasu, U. Sirisha, K. Sandeep, S. P. Praveen, L. P. Maguluri, and T. Bikku, “An Interpretable Approach with Explainable AI for Heart Stroke Prediction,” Diagnostics, vol. 14, no. 2, p. 128, Jan. 2024, doi: 10.3390/diagnostics14020128.

N. Melnykova, Y. Patereha, S. Skopivskyi, M. Farion, S. Fedushko, and K. Drohomyretska, “Machine learning for stroke prediction using imbalanced data,” Sci Rep, vol. 15, no. 1, p. 33773, Sep. 2025, doi: 10.1038/s41598-025-01855-w.

A. Rehman, T. Alam, M. Mujahid, F. S. Alamri, B. A. Ghofaily, and T. Saba, “RDET stacking classifier: a novel machine learning based approach for stroke prediction using imbalance data,” PeerJ Computer Science, vol. 9, p. e1684, Nov. 2023, doi: 10.7717/peerj-cs.1684.

K. Abhishek, Machine Learning for Imbalanced Data: Tackle imbalanced datasets using machine learning and deep learning techniques, 1st ed. Birmingham: Packt Publishing Limited, 2023.

Y. Li et al., “Hematoma expansion prediction based on SMOTE and XGBoost algorithm,” BMC Med Inform Decis Mak, vol. 24, no. 1, p. 172, Jun. 2024, doi: 10.1186/s12911-024-02561-9.

A. Y. Imran, M. R. Sanjaya, B. W. Putra, and G. E. H. Cahyadi, “Optimization Of Sentiment Analysis On Tokopedia User Reviews Using Gridsearchcv And Smote With Machine Learning Algorithms,” JURNAL INOVTEK POLBENG - SERI INFORMATIKA, vol. 10, no. 3, 2025, doi: 10.35314/5ax8km80.

C. Kokkotis et al., “An Explainable Machine Learning Pipeline for Stroke Prediction on Imbalanced Data,” Diagnostics, vol. 12, no. 10, p. 2392, Oct. 2022, doi: 10.3390/diagnostics12102392.

H. A. Nabila and Endang Wahyu Pamungkas, “Perbandingan Algoritma Machine Learning: Svm, Random Forest, Dan Xgboost Untuk Prediksi Stroke,” rabit, vol. 10, no. 2, pp. 1098–1110, Jul. 2025, doi: 10.36341/rabit.v10i2.6444.

L. R. Sitompul, A. A. Nababan, M. L. Manihuruk, W. A. Ponsen, and S. Supriyandi, “Comparison of Xgboost, Random Forest and Logistic Regression Algorithms in Stroke Disease Classification,” SinkrOn, vol. 9, no. 2, pp. 957–968, Jun. 2025, doi: 10.33395/sinkron.v9i2.14794.

M. R. Sanjaya, A. Khoiriah, R. I. Heroza, and B. W. Putra, “Analysis Of User Reviews For The Mytelkomsel App Using Naïve Bayes And Random Forest Methods,” Jurnal Testing dan Implementasi Sistem Informasi, vol. 4(1), pp. 32–48, 2026, doi: 10.55583/jtisi.v4i1.2220.

N. Hollmann et al., “Accurate predictions on small data with a tabular foundation model,” Nature, vol. 637, no. 8045, pp. 319–326, Jan. 2025, doi: 10.1038/s41586-024-08328-6.

M. J. Kim, L. Grinsztajn, and G. Varoquaux, “CARTE: Pretraining and Transfer for Tabular Learning,” May 31, 2024, arXiv: arXiv:2402.16785. doi: 10.48550/arXiv.2402.16785.

M. Mráz, B. Das, A. Gupta, L. Purucker, and F. Hutter, “Towards Benchmarking Foundation Models for Tabular Data With Text,” Jul. 10, 2025, arXiv: arXiv:2507.07829. doi: 10.48550/arXiv.2507.07829.

Munaldi, Algoritma Random Forest dan XGBoost Menggunakan Python. Indonesia: Ganesha Kreasi Semesta, 2025. [Online]. Available: https://repository.ganeshakreasisemesta.com/publications/640026/algoritma-random-forest-dan-xgboost-menggunakan-python

B. W. Putra, “Deep Neural Network Classification for ECG Arrhythmia Detection with Optimized Feature Autoencoder,” J. Adv. Res. Appl. Mech., vol. 133, no. 1, pp. 78–86, Feb. 2025, doi: 10.37934/aram.133.1.7886.

R. Chen et al., “A study on predicting the length of hospital stay for Chinese patients with ischemic stroke based on the XGBoost algorithm,” BMC Med Inform Decis Mak, vol. 23, no. 1, p. 49, Mar. 2023, doi: 10.1186/s12911-023-02140-4.

W. Hong et al., “A Comparison of XGBoost, Random Forest, and Nomograph for the Prediction of Disease Severity in Patients With COVID-19 Pneumonia: Implications of Cytokine and Immune Cell Profile,” Front. Cell. Infect. Microbiol., vol. 12, p. 819267, Apr. 2022, doi: 10.3389/fcimb.2022.819267.

G. Howard, “Rural-urban differences in stroke risk,” Preventive Medicine, vol. 152, p. 106661, Nov. 2021, doi: 10.1016/j.ypmed.2021.106661.

A. Machin, S. P. Widiawan, A. Lefi, M. S. Ardhi, N. Husni, and M. W. Rosyich, “Stroke Risk Factors Based on The Framingham Stroke Risk Score Among Urban vs Rural Elderly Communities,” Malaysian Journal of Medicine and Health Sciences, vol. 20, no. SUPP9, pp. 35–41, 2024, doi: 10.47836/mjmhs20.s9.6.


Bila bermanfaat silahkan share artikel ini

Berikan Komentar Anda terhadap artikel Komparasi Random Forest dan XGBoost Berbasis SMOTE dalam Penanganan Ketidakseimbangan Data untuk Prediksi Risiko Stroke

Dimensions Badge
Article History
Submitted: 2026-07-15
Published: 2026-09-22
Abstract View: 236 times
PDF Download: 67 times
How to Cite
Arzety, C., Putra, B., Sanjaya, M., & Indah, D. (2026). Komparasi Random Forest dan XGBoost Berbasis SMOTE dalam Penanganan Ketidakseimbangan Data untuk Prediksi Risiko Stroke. Building of Informatics, Technology and Science (BITS), 8(2), 881-893. https://doi.org/10.47065/bits.v8i2.10740
Section
Articles