Heart Disease Classification Using Random Forest and Fox Algorithm as Hyperparameter Tuning

Keywords: Classification, Random Forest, Hyperparameter Tuning, FOX Algorithm, Heart Disease

Abstract

Heart disease remains the leading cause of death worldwide, making early and accurate diagnosis crucial for reducing mortality and improving patient outcomes. Traditional diagnostic approaches often suffer from subjectivity, delay, and high costs. Therefore, an effective and automated classification system is necessary to assist medical professionals in making more accurate and timely decisions. This study aims to develop a heart disease classification model using Random Forest, optimized through the FOX algorithm for hyperparameter tuning, to improve predictive performance and reliability. The main contribution of this research lies in the integration of the FOX metaheuristic optimization algorithm with the RF classifier. FOX, inspired by fox hunting behavior, balances exploration and exploitation in searching for the optimal hyperparameters. The proposed RF-FOX model is evaluated on the UCI Heart Disease dataset consisting of 303 instances and 13 features. Several preprocessing steps were conducted, including label encoding, outlier removal, missing value imputation, normalization, and class balancing using SMOTE-NC. FOX was used to optimize six RF hyperparameters across a defined search space. The experimental results demonstrate that the RF-FOX model achieved superior performance compared to standard RF and other hybrid optimization methods. With a training accuracy of 100% and testing accuracy of 97.83%, the model also attained precision (97.83%), recall (97.88%), and F1-score (97.89%). It significantly outperformed RF-GS, RF-RS, RF-PSO, RF-BA, and RF-FA models in all evaluation metrics. In conclusion, the RF-FOX model proves highly effective for heart disease classification, providing enhanced accuracy, reduced misclassification, and clinical applicability. This approach not only optimizes classifier performance but also supports medical decision-making with interpretable and reliable outcomes. Future work may involve validating the model on more diverse datasets to further ensure its generalizability and robustness.

Downloads

Download data is not yet available.

References

S. Emmons-Bell, C. Johnson, and G. Roth, “Prevalence, incidence and survival of heart failure: a systematic review,” 2022, BMJ Publishing Group. doi: 10.1136/heartjnl-2021-320131.

G. Savarese, P. M. Becher, L. H. Lund, P. Seferovic, G. M. C. Rosano, and A. J. S. Coats, “Global burden of heart failure: a comprehensive and updated review of epidemiology,” Dec. 01, 2022, Oxford University Press. doi: 10.1093/cvr/cvac013.

A. Norhammar et al., “Prevalence, outcomes and costs of a contemporary, multinational population with heart failure,” Heart, vol. 109, no. 7, pp. 548–556, Apr. 2023, doi: 10.1136/heartjnl-2022-321702.

V. L. Roger, “Epidemiology of Heart Failure: A Contemporary Perspective,” Circ Res, vol. 128, no. 10, pp. 1421–1434, May 2021, doi: 10.1161/CIRCRESAHA.121.318172.

J. G. F. Cleland, “The struggle towards a Universal Definition of Heart Failure—how to proceed?,” Eur Heart J, vol. 42, no. 24, pp. 2331–2332, Jun. 2021, doi: 10.1093/eurheartj/ehab082.

A. Ward et al., “Machine learning and atherosclerotic cardiovascular disease risk prediction in a multi-ethnic population,” NPJ Digit Med, vol. 3, no. 1, Dec. 2020, doi: 10.1038/s41746-020-00331-1.

R. Nakanishi et al., “Machine Learning Adds to Clinical and CAC Assessments in Predicting 10-Year CHD and CVD Deaths,” JACC Cardiovasc Imaging, vol. 14, no. 3, pp. 615–625, Mar. 2021, doi: 10.1016/j.jcmg.2020.08.024.

B. K. Tamarappoo et al., “Machine learning integration of circulating and imaging biomarkers for explainable patient-specific prediction of cardiac events: A prospective study,” Atherosclerosis, vol. 318, pp. 76–82, Feb. 2021, doi: 10.1016/j.atherosclerosis.2020.11.008.

X. Liu, J. Lu, H. Dai, D. Zhou, S. Cheng, and J. Wang, “Prevention and Health Promotion MACHINE LEARNING DRIVEN CORONARY HEART DISEASE RISK ASSESSMENT: ANALYSES OF NHANES 1999-2018 DATA.”

D. P. Mishra, H. K. Gupta, G. Saajith, and R. Bag, “Optimizing Heart Disease Prediction Model with GridsearchCV for Hyperparameter Tuning,” in 2024 1st International Conference on Cognitive, Green and Ubiquitous Computing, IC-CGU 2024, Institute of Electrical and Electronics Engineers Inc., 2024. doi: 10.1109/IC-CGU58078.2024.10530772.

P. K. P, M. A. B. V, and G. G. Nair, “An efficient classification framework for breast cancer using hyper parameter tuned Random Decision Forest Classifier and Bayesian Optimization,” Biomed Signal Process Control, vol. 68, Jul. 2021, doi: 10.1016/j.bspc.2021.102682.

K. A. Barry, Y. Manzali, R. Flouchi, and M. Elfar, “Heart disease approach using modified random forest and particle swarm optimization,” IAES International Journal of Artificial Intelligence (IJ-AI), vol. 14, no. 2, p. 1242, Apr. 2025, doi: 10.11591/ijai.v14.i2.pp1242-1251.

C. M. Rahman and T. A. Rashid, “A new evolutionary algorithm: Learner performance based behavior algorithm,” Egyptian Informatics Journal, vol. 22, no. 2, pp. 213–223, Jul. 2021, doi: 10.1016/j.eij.2020.08.003.

N. Bacanin, T. Bezdan, E. Tuba, I. Strumberger, and M. Tuba, “Optimizing convolutional neural network hyperparameters by enhanced swarm intelligence metaheuristics,” Algorithms, vol. 13, no. 3, Mar. 2020, doi: 10.3390/a13030067.

M. Daviran, M. Shamekhi, R. Ghezelbash, and A. Maghsoudi, “Landslide susceptibility prediction using artificial neural networks, SVMs and random forest: hyperparameters tuning by genetic optimization algorithm,” International Journal of Environmental Science and Technology, vol. 20, no. 1, pp. 259–276, Jan. 2023, doi: 10.1007/s13762-022-04491-3.

H. Mohammed and T. Rashid, “FOX: a FOX-inspired optimization algorithm,” Applied Intelligence, vol. 53, pp. 1030–1050, 2023, doi: 10.1007/s10489-022-03533-0/Published.

D. Połap and M. Woźniak, “Red fox optimization algorithm,” Expert Syst Appl, vol. 166, Mar. 2021, doi: 10.1016/j.eswa.2020.114107.

A. Masbakhah, U. Sa’adah, and M. Muslikh, “Feature Selection Risk Factors Cervical Cancer Using Hybrid Methods Random Forest and FOX-Inspired Optimization Algorithm,” CAUCHY: Jurnal Matematika Murni dan Aplikasi, vol. 9, no. 2, pp. 352–367, Nov. 2024, doi: 10.18860/ca.v9i2.29582.

Z. Zhang, X. Wang, and L. Cao, “FOX Optimization Algorithm Based on Adaptive Spiral Flight and Multi-Strategy Fusion,” Biomimetics, vol. 9, no. 9, p. 524, Aug. 2024, doi: 10.3390/biomimetics9090524.

R. Sharma et al., “Comparative performance analysis of binary variants of FOX optimization algorithm with half-quadratic ensemble ranking method for thyroid cancer detection,” Sci Rep, vol. 13, no. 1, Dec. 2023, doi: 10.1038/s41598-023-46865-8.

X. Zhu, J. Li, J. Ren, J. Wang, and G. Wang, “Dynamic ensemble learning for multi-label classification,” Inf Sci (N Y), vol. 623, pp. 94–111, Apr. 2023, doi: 10.1016/j.ins.2022.12.022.

K. Sumwiza, C. Twizere, G. Rushingabigwi, P. Bakunzibake, and P. Bamurigire, “Enhanced cardiovascular disease prediction model using random forest algorithm,” Inform Med Unlocked, vol. 41, Jan. 2023, doi: 10.1016/j.imu.2023.101316.

A. Desiani, N. R. Dewi, A. N. Fauza, N. Rachmatullah, M. Arhami, and M. Nawawi, “Handling Missing Data Using Combination of Deletion Technique, Mean, Mode and Artificial Neural Network Imputation for Heart Disease Dataset,” 2021. [Online]. Available: https://doi.org/11.26554/sti.2221.6.4.333-312

D. Singh and B. Singh, “Investigating the impact of data normalization on classification performance,” Appl Soft Comput, vol. 97, Dec. 2020, doi: 10.1016/j.asoc.2019.105524.

M. Ahmed Ouameur, M. Caza-Szoka, and D. Massicotte, “Machine learning enabled tools and methods for indoor localization using low power wireless network ✩,” Internet of Things, vol. 12, p. 0, 2020, doi: 10.1016/j.iot.2020.10.

R. AŞLIYAN, “Examining Variants of Learning Vector Quantizations According to Normalization and Initialization of Vector Positions,” European Journal of Science and Technology, Dec. 2022, doi: 10.31590/ejosat.1222296.

B. Paul and B. Karn, “Heart disease prediction using scaled conjugate gradient backpropagation of artificial neural network,” Soft comput, vol. 27, no. 10, pp. 6687–6702, May 2023, doi: 10.1007/s00500-022-07649-w.

H. Benhar, A. Idri, and J. L Fernández-Alemán, “Data preprocessing for heart disease classification: A systematic literature review.,” Oct. 01, 2020, Elsevier Ireland Ltd. doi: 10.1016/j.cmpb.2020.105635.

F. Thabtah, S. Hammoud, F. Kamalov, and A. Gonsalves, “Data imbalance in classification: Experimental evaluation,” Inf Sci (N Y), vol. 513, pp. 429–441, Mar. 2020, doi: 10.1016/j.ins.2019.11.004.

P. Zhang, Y. Jia, and Y. Shang, “Research and application of XGBoost in imbalanced data,” Int J Distrib Sens Netw, vol. 18, no. 6, Jun. 2022, doi: 10.1177/15501329221106935.

C. Vairetti, J. L. Assadi, and S. Maldonado, “Efficient hybrid oversampling and intelligent undersampling for imbalanced big data classification,” Expert Syst Appl, vol. 246, Jul. 2024, doi: 10.1016/j.eswa.2024.123149.

E. C. Gök and M. O. Olgun, “SMOTE-NC and gradient boosting imputation based random forest classifier for predicting severity level of covid-19 patients with blood samples,” Neural Comput Appl, vol. 33, no. 22, pp. 15693–15707, Nov. 2021, doi: 10.1007/s00521-021-06189-y.

C. H. Bhavani and A. Govardhan, “Cervical cancer prediction using stacked ensemble algorithm with SMOTE and RFERF,” Mater Today Proc, vol. 80, pp. 3451–3457, Jan. 2023, doi: 10.1016/j.matpr.2021.07.269.

I. Priyana, N. Alamsyah, Budiman, A. P. Sarifiyono, and E. Rusnendar, “Predictive Boosting for Employee Retention with SMOTE and XGBoost Hyperparameter Tuning,” in 2024 International Conference on Smart Computing, IoT and Machine Learning, SIML 2024, Institute of Electrical and Electronics Engineers Inc., 2024, pp. 92–97. doi: 10.1109/SIML61815.2024.10578116.

L. Breiman, “Random Forests,” 2001.

S. Dhanka and S. Maini, “Random Forest for Heart Disease Detection: A Classification Approach,” in 2021 IEEE 2nd International Conference on Electrical Power and Energy Systems, ICEPES 2021, Institute of Electrical and Electronics Engineers Inc., 2021. doi: 10.1109/ICEPES52894.2021.9699506.

M. Pal and S. Parija, “Prediction of Heart Diseases using Random Forest,” in Journal of Physics: Conference Series, IOP Publishing Ltd, Mar. 2021. doi: 10.1088/1742-6596/1817/1/012009.

K. M. M. Uddin, A. Al Mamun, A. Chakrabarti, R. Mostafiz, and S. K. Dey, “An ensemble machine learning-based approach to predict cervical cancer using hybrid feature selection,” Neuroscience Informatics, vol. 4, no. 3, p. 100169, Sep. 2024, doi: 10.1016/j.neuri.2024.100169.

P. Probst, “Hyperparameters, Tuning and Meta-Learning for Random Forest and Other Machine Learning Algorithms,” 2019.

P. Probst, M. N. Wright, and A. L. Boulesteix, “Hyperparameters and tuning strategies for random forest,” May 01, 2019, Wiley-Blackwell. doi: 10.1002/widm.1301.

J. Ivan and S. Y. Prasetyo, “Heart Disease Prediction Using Ensemble Model and Hyperparameter Optimization,” International Journal on Recent and Innovation Trends in Computing and Communication, vol. 11, pp. 290–295, 2023, doi: 10.17762/ijritcc.v11i8s.7208.

A. Baita, I. A. Prasetyo, and N. Cahyono, “HYPERPARAMETER TUNING ON RANDOM FOREST FOR DIAGNOSE COVID-19,” JIKO (Jurnal Informatika dan Komputer), vol. 6, no. 2, Aug. 2023, doi: 10.33387/jiko.v6i2.6389.

M. A. Jumaah, Y. H. Ali, T. A. Rashid, and S. Vimal, “FOXANN: A Method for Boosting Neural Network Performance,” 2024. doi: https://doi.org/10.48550/arXiv.2407.03369.

M. H. Nadimi-Shahraki, H. Zamani, Z. Asghari Varzaneh, and S. Mirjalili, “A Systematic Review of the Whale Optimization Algorithm: Theoretical Foundation, Improvements, and Hybridizations,” Archives of Computational Methods in Engineering, vol. 30, no. 7, pp. 4113–4159, Sep. 2023, doi: 10.1007/s11831-023-09928-7.

O. O. Akinola, A. E. Ezugwu, J. O. Agushaka, R. A. Zitar, and L. Abualigah, “Multiclass feature selection with metaheuristic optimization algorithms: a review,” Nov. 01, 2022, Springer Science and Business Media Deutschland GmbH. doi: 10.1007/s00521-022-07705-4.

J. J. Tanimu, M. Hamada, M. Hassan, H. A. Kakudi, and J. O. Abiodun, “A Machine Learning Method for Classification of Cervical Cancer,” Electronics (Switzerland), vol. 11, no. 3, Feb. 2022, doi: 10.3390/electronics11030463.

J. Lu, E. Song, A. Ghoneim, and M. Alrashoud, “Machine learning for assisting cervical cancer diagnosis: An ensemble approach,” Future Generation Computer Systems, vol. 106, pp. 199–205, May 2020, doi: 10.1016/j.future.2019.12.033.

Y. Rimal and N. Sharma, “Hyperparameter optimization: a comparative machine learning model analysis for enhanced heart disease prediction accuracy,” Multimed Tools Appl, vol. 83, no. 18, pp. 55091–55107, May 2024, doi: 10.1007/s11042-023-17273-x.

Q. H. Doan, S. H. Mai, Q. T. Do, and D. K. Thai, “A cluster-based data splitting method for small sample and class imbalance problems in impact damage classification[Formula presented],” Appl Soft Comput, vol. 120, May 2022, doi: 10.1016/j.asoc.2022.108628.

D. Chicco and G. Jurman, “The advantages of the Matthews correlation coefficient (MCC) over F1 score and accuracy in binary classification evaluation,” BMC Genomics, vol. 21, no. 1, Jan. 2020, doi: 10.1186/s12864-019-6413-7.

A. P. Kumar, Y. Macha, and A. S. Kumar, “HEART FAILURE DETECTION USING OPTIMIZATION ALGORITHMS,” J Theor Appl Inf Technol, vol. 15, no. 7, 2025, [Online]. Available: www.jatit.org

N. K. Chauhan and K. Singh, “Performance Assessment of Machine Learning Classifiers Using Selective Feature Approaches for Cervical Cancer Detection,” Wirel Pers Commun, vol. 124, no. 3, pp. 2335–2366, Jun. 2022, doi: 10.1007/s11277-022-09467-7.

D. Shah, S. Patel, and S. K. Bharti, “Heart Disease Prediction using Machine Learning Techniques,” SN Comput Sci, vol. 1, no. 6, Nov. 2020, doi: 10.1007/s42979-020-00365-y.

M. G. El-Shafiey, A. Hagag, E. S. A. El-Dahshan, and M. A. Ismail, “A hybrid GA and PSO optimized approach for heart-disease prediction based on random forest,” Multimed Tools Appl, vol. 81, no. 13, pp. 18155–18179, May 2022, doi: 10.1007/s11042-022-12425-x.

S. A. Ardiyansa, N. C. Maharani, S. Anam, and E. Julianto, “OPTIMIZING HEART ATTACK DIAGNOSIS USING RANDOM FOREST WITH BAT ALGORITHM AND GREEDY CROSSOVER TECHNIQUE,” BAREKENG: Jurnal Ilmu Matematika dan Terapan, vol. 18, no. 2, pp. 1053–1066, May 2024, doi: 10.30598/barekengvol18iss2pp1053-1066.

J. Huang, M. M. S. Sabri, D. V. Ulrikh, M. Ahmad, and K. A. M. Alsaffar, “Predicting the Compressive Strength of the Cement-Fly Ash–Slag Ternary Concrete Using the Firefly Algorithm (FA) and Random Forest (RF) Hybrid Machine-Learning Method,” Materials, vol. 15, no. 12, Jun. 2022, doi: 10.3390/ma15124193.

M. Youssef, M. A. Deif, R. Elgohary, H. Attar, M. Hafez, and S. M. Sharfo, “Fox Optimizer and Logistic Regression for Liver Diseases Classification,” in 2nd International Engineering Conference on Electrical, Energy, and Artificial Intelligence, EICEEAI 2023, Institute of Electrical and Electronics Engineers Inc., 2023. doi: 10.1109/EICEEAI60672.2023.10590225.

V. Shalamov, V. Efimova, and A. Filchenkov, “Faster Hyperparameter Optimization via Finding Minimal Regions in Random Forest Regressor,” in Procedia Computer Science, Elsevier B.V., 2022, pp. 378–386. doi: 10.1016/j.procs.2022.11.022.

M. K. Suryadi, R. Herteno, S. W. Saputro, M. R. Faisal, and R. A. Nugroho, “A Comparative Study of Various Hyperparameter Tuning on Random Forest Classification with SMOTE and Feature Selection Using Genetic Algorithm in Software Defect Prediction,” Journal of Electronics, Electromedical Engineering, and Medical Informatics, vol. 6, no. 2, pp. 137–147, Apr. 2024, doi: 10.35882/jeeemi.v6i2.375.

R. Valarmathi and T. Sheela, “Heart disease prediction using hyper parameter optimization (HPO) tuning,” Biomed Signal Process Control, vol. 70, Sep. 2021, doi: 10.1016/j.bspc.2021.103033.

R. Torthi, A. D. K. Marapatla, S. Mande, H. K. V. Gadiraju, and C. Kanumuri, “Heart Disease Prediction Using Random Forest Based Hybrid Optimization Algorithms,” International Journal of Intelligent Engineering and Systems, vol. 17, no. 2, pp. 134–144, 2024, doi: 10.22266/ijies2024.0430.12.

V. Parikh, B. Sharma, A. Byotra, and A. Malhotra, “Optimizing Heart Disease Prediction Using a Hybrid Dynamic Swarm Evolution Approach,” SN Comput Sci, vol. 5, no. 8, Dec. 2024, doi: 10.1007/s42979-024-03484-y.

Published
2025-08-01
How to Cite
[1]
A. Masbakhah, U. Sa’adah, and M. Muslikh, “Heart Disease Classification Using Random Forest and Fox Algorithm as Hyperparameter Tuning”, j.electron.electromedical.eng.med.inform, vol. 7, no. 4, pp. 964-976, Aug. 2025.
Section
Medical Engineering