Heart Failure Disease Classification Using Random Forest Algorithm with Grid Search Cross Validation Technique - Septia, Rapindra; Junadhi; Susi Erlinda; Wirta Agustin (AI Society & STMIK Indonesia, 2025)
Heart failure is one of the leading causes of death worldwide and requires early detection to reduce the risk of serious complications. However, the imbalance in medical data poses a challenge in developing accurate prediction models. This study developed a heart failure classification model using the Random Forest algorithm, optimized with Grid Search Cross Validation to find the best combination of hyperparameters. The dataset consisted of 300 observations with 12 medical features and 1 target feature. Data preprocessing included outlier removal using the Interquartile Range (IQR) and Winsorize methods. The Synthetic Minority Oversampling Technique (SMOTE) was applied to address class imbalance, resulting in a more balanced training data distribution. The dataset was split into 80% training and 20% testing data using stratified sampling to maintain class proportions. The model was evaluated using accuracy, precision, recall, and F1-score metrics, with results showing 90% accuracy, 0.94 precision for class 0, 0.80 precision for class 1, 0.91 recall for class 0, and 0.86 recall for class 1. The model was implemented in a Streamlit-based application, allowing users to input health parameters and receive interactive predictions. This study demonstrates that optimizing the Random Forest algorithm with Grid Search Cross Validation can improve heart failure classification performance, providing a practical solution for supporting heart failure classification. Keywords: Heart Failure Classification, Random Forest, Hyperparameter Optimization, SMOTE, Model Evaluation.