Prediction of Risk of Unplanned Readmission or Death in Elderly Heart Failure Patients During the Vulnerable Phase: Machine Learning With SHAP Interpretation Authors: Hao Luo, Qi Wu, Zaiyong Zheng, Xuefeng Wang, Na Lai, Yixuan Li, Xiang Zheng, Yihang Li, Deqiang Li, Kai Guo, Ji Li Published: 2026 ABSTRACT ABSTRACTHeart failure (HF) as the final stage of cardiovascular disease in the elderly leads to frequent readmissions and seriously affects their quality of life. This study aimed to develop a predictive model for hospital readmission or death during the vulnerable phase in elderly HF patients, and to identify the key associated risk factors. The dataset was randomly divided into 70% training sets and 30% validation sets. Three feature selection methods were applied to the training data, followed by the construction of 18 predictive models using six machine learning (ML) algorithms (XGBoost, LightGBM, AdaBoost, GBDT, GNB, and SVM). The performance of each model was assessed on the validation set using receiver operating characteristic (ROC) curves, sensitivity, accuracy, specificity, F1 score, and Brier score. SHapley Additive exPlanations (SHAP) were used to interpret the feature contributions both globally and locally. Eleven models achieved an area under the ROC curve (AUC) greater than 0.8, with the Boruta‐XGBoost model performing best, showing an AUC of 0.873 in the validation set, along with a sensitivity of 0.839, accuracy of 0.769, specificity of 0.747, F1 score of 0.634, and Brier score of 0.130. SHAP analysis revealed that the top five important features were hemoglobin (HGB), serum free thyroxine (FT4), age, diabetes, and serum potassium (K). The Boruta‐XGBoost based risk prediction model, combined with SHAP interpretation, demonstrated high predictive accuracy and robust interpretability for forecasting hospital readmission or death during the vulnerable phase in elderly HF patients.Keywords: heart failure, interpretability model, machine learning, SHAP, vulnerable phase Introduction Heart failure (HF) is a clinical syndrome characterized by impaired cardiac function due to structural and/or functional abnormalities, resulting in ventricular systolic or diastolic dysfunction. It is commonly considered the end‐stage of various cardiovascular diseases [1, 2]. Despite significant advancements in preventive and therapeutic strategies over recent decades, the prevalence of HF continues to rise, largely driven by the aging population and the prolonged survival of patients due to effective evidence‐based therapies. Currently, an estimated 56.2 million individuals across 204 countries and regions live with HF [3]. According to the American Heart Association, HF prevalence in the United States is expected to increase by 46% between 2012 and 2030, with the proportion of HF patients rising from 2.4% to 3.0%. Total associated costs are projected to reach $69.8 billion by 2030 [4]. Moreover, HF remains one of the leading causes of hospitalization among individuals aged 65 and older, underscoring the need for strategies to reduce the hospitalization burden [5]. Furthermore, the mortality and readmission rates for HF patients within 2–3 months after discharge are approximately 15% and 30%, respectively. This high‐risk period, termed the “vulnerable phase” [6], is likely due to hemodynamic instability, increased left ventricular filling pressures, and reduced ejection fraction following discharge [7]. As a result, identifying effective interventions to reduce readmissions and mortality during this phase has become a primary focus of clinical trials and quality improvement initiatives. Clinical prognostic models, which estimate disease risk and identify key factors over a specific timeframe, hold promise for improving HF prognosis and alleviating healthcare costs [8, 9, 10]. HF patient data is often complex, characterized by high dimensionality and nonlinear relationships. Traditional statistical approaches, such as logistic regression and risk scoring tools, are limited in their ability to capture these multidimensional associations, leading to suboptimal predictive performance [11, 12]. In contrast, machine learning (ML), an emerging field of artificial intelligence, has demonstrated its capacity to model nonlinear relationships, identify key prognostic factors, and facilitate rapid decision‐making [13, 14]. Increasing evidence supports the integration of ML in medical applications, including disease diagnosis, risk prediction, and medical imaging analysis, offering significant advancements for global healthcare systems [15, 16, 17]. However, the opaque “black box” nature of many ML models remains a key challenge in clinical practice. The reasoning and decision‐making processes behind these models are often unclear, limiting their broader application in healthcare [18]. To address this, the SHAP (SHapley Additive exPlanations) technique was developed to provide interpretability by calculating Shapley values for each feature in the model. This method allows for a detailed evaluation of each feature's contribution to model performance, offering insights into the complex relationships between features and predictions [19]. Thus, to accurately predict the risk of unplanned readmission or death during the vulnerable phase in elderly HF patients, this study employs multiple ML algorithms to develop and select the optimal risk prediction model, while using the SHAP framework to interpret the ML predictions. The aim is to explore the prognostic factors affecting these outcomes, which are of significant importance for reducing unplanned readmissions or mortality during the vulnerable phase in elderly HF patients. Methods Study Population This study included patients diagnosed with HF who were hospitalized in the Department of Cardiovascular Medicine at Luzhou People's Hospital between January 1, 2020, and December 31, 2020. The inclusion criteria were as follows: (1) age ≥ 65 years; (2) diagnosis consistent with the “Chinese guidelines for the diagnosis and treatment of heart failure 2024” [20]; (3) length of hospital stay ≥ 24 h. Exclusion criteria: (1) lost to follow‐up; (2) severe cognitive impairment or a history of psychiatric disorders (poor follow‐up adherence leads to unreliable outcome data, and inconsistent treatment patterns confound the identification of core heart failure risk factors); (3) uncertain discharge status. Data Collection and Preprocessing Baseline clinical data were collected for each patient, including sociodemographic characteristics (age, gender, smoking history, drinking history), clinical comorbidities (hypertension, diabetes, chronic obstructive pulmonary disease), laboratory test results (HGB, BNP, creatinine, UA, CRP, etc.), echocardiographic data, and medication usage. A total of 649 patients were included, and they were randomly assigned to the training and validation sets in a 7:3 ratio. Data preprocessing involved several steps: correlation testing, handling of missing values, and data standardization. Variables with more than 30% missing data were excluded from analysis. For those with a missing rate of 30% or less, missing values were imputed using the K‐nearest neighbors (KNN) algorithm. The KNN method identifies K samples in close spatial proximity to the missing data point using distance metrics and imputes the missing values as the average of these K neighbors [21]. Pearson and Spearman correlation analyzes were subsequently performed, and variables with a correlation coefficient greater than 0.8 were removed. Additionally, to reduce scale differences between features and accelerate the convergence of the algorithms, Min‐Max normalization was used to scale feature values to a range of [0, 1] [22]. Study Outcome In this study, the primary composite endpoint in this study was defined as either unplanned readmission or all‐cause mortality during the 3‐month follow‐up period following discharge in HF patients. Data regarding these endpoint events were collected through the electronic medical record system, outpatient visits, and telephone follow‐up. Unplanned readmission was characterized as an unscheduled rehospitalization due to cardiovascular disease after discharge, excluding planned admissions for interventions such as rehabilitation therapy, hemodialysis, or surgery. All‐cause mortality was defined as death from any cause during the follow‐up period. Feature Selection Selecting appropriate feature selection methods, rather than including all variables in the model, is essential for enhancing model performance. Feature selection improves understanding of the dataset's underlying structure, facilitates better generalization, and mitigates the risk of overfitting. The random forest (RF) algorithm, an ensemble learning method based on decision trees, is widely utilized for feature selection in supervised learning. It evaluates the importance of each feature based on its contribution to the predictive model [23]. Additionally, the Boruta algorithm, which is also derived from RF, compares the Z‐scores of original features with those of shadow features. Features with Z‐scores significantly lower than the shadow features are deemed unimportant, while those with significantly higher Z‐scores are considered important. The Boruta algorithm offers an advantage by reducing the random variability associated with feature importance estimates in RF [24]. In this study, we used the RF, Boruta algorithm, and a combination of both methods to select important features. Model Development and Evaluation The patient cohort was randomly split into a training set (70%) and a validation set (30%). Using the selected features, multiple ML algorithms were applied in the training set to develop models predicting the risk of readmission and mortality. These algorithms included XGBoost, LightGBM, AdaBoost, GBDT, Gaussian Naive Bayes (GNB), and Support Vector Machines (SVM) (Figure S1). Hyperparameter optimization was carried out using grid search combined with five‐fold cross‐validation to minimize the risk of overfitting. In the validation set, model performance was evaluated using several metrics: AUC, sensitivity, accuracy, specificity, F1 score, and Brier score. A comprehensive comparison was made across the models, with the one demonstrating the strongest generalization capabilities selected for further risk prediction and stratification. Given the class imbalance in the cohort, the no‐information rate (NIR) was additionally introduced as a reference to assess model clinical utility. Model Interpretation and Analysis The “black‐box” nature of ML models often makes it difficult for clinicians to understand how each feature contributes to a prediction, potentially leading to distrust in the model's outcomes. To address this challenge, we employed the SHAP interpretability framework, which provides both global and local explanations of the models. SHAP is a post hoc interpretability method that assigns SHAP values to each input feature, quantifying its contribution to the model's predictions [19]. This method enhances both the transparency and the credibility of the model, facilitating a better understanding of the decision‐making process and the rationale behind specific predictions. SHAP plots were generated to rank the importance of features influencing the composite endpoint during the vulnerable phase of HF, as well as to illustrate the relationship between individual features and prediction outcomes. The entire model development and validation process is shown in Figure 1. Model development and validation flow. Ethics Statement This study has been approved by the Ethics Committee of Luzhou People's Hospital (LW202401010). The study was conducted in accordance with the principles of the Declaration of Helsinki. As fully anonymized data were used, from which individuals cannot be identified, the requirement for informed consent was waived. Statistical Analysis All statistical analyzes were conducted using R software (version 4.2.3) and Python (version 3.11). Continuous variables that did not follow a normal distribution were presented as medians with interquartile ranges [M (P25, P75)], and comparisons between groups were performed using the Mann–Whitney U non‐parametric test. Categorical data were expressed as frequencies and percentages (n, %), and the Chi‐square test was used for group comparisons. The predictive performance of the ML models was assessed comprehensively using several metrics, including sensitivity, specificity, accuracy, Brier score, F1 score, and AUC. A two‐sided p‐value of < 0.05 was considered to indicate statistical significance. Results Baseline Characteristics A total of 649 HF patients met the inclusion and exclusion criteria for the final analysis, comprising 367 males and 282 females, with a mean age of 73 years. The cohort was divided into two groups: patients who experienced composite endpoint events during the follow‐up period (n = 141) and those who did not (n = 508). As presented in Table 1, patients in the composite endpoint group were older, with a median age of 75.0 years [71.0, 81.0], compared to 72.0 years [68.0, 77.0] in the non‐event group (p < 0.001), and had longer hospital stays (11 days vs. 9 days, p < 0.001). Furthermore, hemoglobin (HGB) levels (105.0 g/L [86.0, 123.4]) and left ventricular ejection fraction (LVEF) (51.2% [43.0, 58.0]) were lower in the event group compared to the non‐event group (121.0 g/L [103.0, 132.0] and 58.0% [51.0, 62.8], respectively, p < 0.001). While the majority of patients in both groups were classified as New York Heart Association (NYHA) Class III, 29.8% of patients in the event group were classified as NYHA Class IV, compared to 13.6% in the non‐event group. The event rates were 21.6% (98/454) in the training set and 22.1% (43/195) in the validation set, consistent with the overall rate of 21.7%. In the entire cohort, the 3‐month unplanned readmission rate was 18.2% (118/649), all‐cause mortality rate was 3.5% (23/649), and the composite endpoint rate was 21.7% (141/649). TABLE 1Patient baseline characteristic data.CharacteristicOverall (n = 649)No‐event group (n = 508)Event group (n = 141) p Age 73.000 [69.000, 78.000] 72.000 [68.000, 77.000] 75.000 [71.000, 81.000] < 0.001Gender, n (%)0.049Female282 (43.451)231 (45.472)51 (36.170)Male367 (56.549)277 (54.528)90 (63.830)Smoking, n (%)< 0.001No434 (66.872)356 (70.079)78 (55.319)Yes215 (33.128)152 (29.921)63 (44.681)Drinking, n (%)0.083No483 (74.422)386 (75.984)97 (68.794)Yes166 (25.578)122 (24.016)44 (31.206)Hypertension, n (%)0.035No395 (60.863)320 (62.992)75 (53.191)Yes254 (39.137)188 (37.008)66 (46.809)Diabetes, n (%)< 0.001No533 (82.126)432 (85.039)101 (71.631)Yes116 (17.874)76 (14.961)40 (28.369)COPD, n (%)0.029No557 (85.824)444 (87.402)113 (80.142)Yes92 (14.176)64 (12.598)28 (19.858)Medical insurance, n (%)0.321Cash payment92 (14.176)68 (13.386)24 (17.021)Resident416 (64.099)333 (65.551)83 (58.865)Employee141 (21.726)107 (21.063)34 (24.113)Admissionway, n (%)< 0.001Non‐emergency479 (73.806)395 (77.756)84 (59.574)Emergency170 (26.194)113 (22.244)57 (40.426)LOS9.000 [6.000, 12.000] 9.000 [6.000, 12.000] 11.000 [8.000, 15.000] < 0.001K3.700 [3.410, 4.070]3.700 [3.400, 4.020] 3.790 [3.466, 4.200] 0.059Cl 105.800 [102.900, 108.000] 105.895 [103.000, 108.000] 105.800 [102.600, 108.500] 0.736Na 139.800 [137.100, 141.700] 139.900 [137.000, 141.800] 139.700 [137.400, 141.200] 0.745Ca1.170 [1.110, 2.200] 1.170 [1.110, 2.210] 1.160 [1.110, 2.130] 0.391cTnT0.023 [0.012, 0.080]0.022 [0.012, 0.075] 0.025 [0.014, 0.118] 0.083BNP906.974 [621.200, 1356.200]824.300 [580.248, 1250.000]1323.250 [835.200, 1832.500]< 0.001WBC6.750 [5.160, 8.900]6.800 [5.260, 9.190] 6.430 [4.850, 8.590] 0.089HGB 119.000 [100.000, 130.000] 121.000 [103.000, 132.000] 105.000 [86.000, 123.365] < 0.001PLT 161.000 [124.000, 210.000] 163.077 [124.987, 211.000] 157.594 [122.000, 205.000] 0.763Monocyte0.4 40 [0.340, 0.580]0.440 [0.340, 0.580] 0.460 [0.340, 0.570] 0.769Lymphocyte1.339 [0.920, 1.680]1.360 [0.950, 1.700] 1.260 [0.810, 1.590] 0.014CRP4.410 [1.380, 16.520] 4.310 [1.341, 15.364] 5.490 [1.494, 21.420] 0.386LDL‐C2.097 [1.640, 2.600]2.070 [1.656, 2.570] 2.150 [1.610, 2.660] 0.539HDL‐C1.142 [0.930, 1.360]1.146 [0.950, 1.360] 1.107 [0.890, 1.320] 0.144TG1.150 [0.870, 1.500]1.160 [0.870, 1.530] 1.130 [0.880, 1.430] 0.573UA 356.027 [301.600, 423.500] 352.200 [295.000, 419.100] 368.500 [325.400, 430.700] 0.025Cr 74.500 [62.863, 98.141] 73.600 [61.300, 94.000] 81.700 [67.400, 109.800] < 0.001eGFR 80.601 [62.120, 97.830] 82.026 [65.640, 98.590] 76.130 [54.010, 93.580] 0.002IBiL10.271 [7.500, 13.400] 10.200 [7.500, 13.400] 10.400 [7.700, 13.700] 0.628DBiL3.310 [2.161, 5.300]3.400 [2.161, 5.300] 3.300 [2.200, 5.300] 0.758TT 16.800 [16.000, 17.700] 16.800 [16.000, 17.800] 16.800 [15.900, 17.500] 0.402FIB3.410 [2.870, 4.180]3.450 [2.880, 4.310] 3.350 [2.850, 3.940] 0.364FBG6.165 [5.030, 8.096]6.100 [5.060, 8.000] 6.300 [4.950, 8.529] 0.767ALB 36.700 [33.600, 39.300] 36.900 [33.700, 39.600] 35.800 [33.000, 38.400] 0.005GLB 29.100 [26.000, 32.300] 29.000 [26.100, 32.300] 29.400 [26.000, 32.200] 0.992FT32.640 [2.220, 2.990]2.645 [2.240, 2.987] 2.602 [2.140, 3.020] 0.599FT41.330 [1.180, 1.549]1.330 [1.190, 1.530] 1.280 [1.160, 1.650] 0.619TSH1.873 [1.278, 2.918]1.852 [1.279, 2.831] 2.008 [1.235, 3.133] 0.439HCY 15.701 [13.320, 19.513] 15.552 [12.950, 19.294] 16.890 [14.250, 20.544] 0.004ALT 18.000 [12.500, 29.100] 18.000 [12.200, 28.900] 18.079 [13.700, 31.000] 0.213ALP 84.000 [70.800, 100.400] 84.000 [70.200, 99.100] 84.200 [72.100, 102.400] 0.616LVEF 57.000 [49.000, 62.000] 58.000 [51.000, 62.768] 51.189 [43.000, 58.000] < 0.001LV enlargement, n (%)< 0.001No543 (83.667)447 (87.992)96 (68.085)Yes106 (16.333)61 (12.008)45 (31.915)LA enlargement, n (%)0.024No455 (70.108)367 (72.244)88 (62.411)Yes194 (29.892)141 (27.756)53 (37.589)RV enlargement, n (%)0.149No621 (95.686)483 (95.079)138 (97.872)Yes28 (4.314)25 (4.921)3 (2.128)RA enlargement, n (%)0.089No570 (87.827)452 (88.976)118 (83.688)Yes79 (12.173)56 (11.024)23 (16.312)ARNI, n (%)0.003No151 (23.267)105 (20.669)46 (32.624)Yes498 (76.733)403 (79.331)95 (67.376)Diuretic, n (%)0.350No16 (2.465)11 (2.165)5 (3.546)Yes633 (97.535)497 (97.835)136 (96.454)Blocker, n (%)0.366No152 (23.421)123 (24.213)29 (20.567)Yes497 (76.579)385 (75.787)112 (79.433)NYHA, n (%)< 0.001II228 (35.131)198 (38.976)30 (21.277)III310 (47.766)241 (47.441)69 (48.936)IV111 (17.103)69 (13.583)42 (29.787)Abbreviations: ALB, Albumin; ALP, Alkaline Phosphatase; ALT, Alanine transaminase; ARNI, Angiotensin receptor‐neprilysin inhibitor; BNP, brain natriuretic peptide; COPD, Chronic obstructive pulmonary disease; Cr, Creatinine; CRP, C‐reactive protein; DBiL, Direct Bilirubin; eGFR, Estimated glomerular filtration rate; FBG, Fasting blood glucose; FIB, Fibrinogen; FT3, Free triiodothyronine 3; FT4, Free triiodothyronine 4; GLB, Globulin; HCY, Homocysteine; HDL‐C, High‐density lipoproteincholesterol; HGB, Hemoglobin; IBiL, Indirect Bilirubin; LA, Left atrium; LDL‐C, Low‐density lipoprotein cholesterol; LOS, Length of stay; LV, Left ventricle; LVEF, Left ventricular ejection fractions; NYHA, New York Heart Association; PLT, Platelets counts; RA, Right atrium; RV, Right ventricle; TG, Triglyceride; TSH, Thyroid stimulating hormone; TT, Thrombin time; UA, Uric acid; WBC, White blood cell counts. Patient baseline characteristic data. 73.000 [69.000, 78.000] 72.000 [68.000, 77.000] 75.000 [71.000, 81.000] 9.000 [6.000, 12.000] 11.000 [8.000, 15.000] 3.790 [3.466, 4.200] 105.800 [102.900, 108.000] 105.895 [103.000, 108.000] 105.800 [102.600, 108.500] 139.800 [137.100, 141.700] 139.900 [137.000, 141.800] 139.700 [137.400, 141.200] 1.170 [1.110, 2.210] 1.160 [1.110, 2.130] 0.025 [0.014, 0.118] 6.430 [4.850, 8.590] 119.000 [100.000, 130.000] 121.000 [103.000, 132.000] 105.000 [86.000, 123.365] 161.000 [124.000, 210.000] 163.077 [124.987, 211.000] 157.594 [122.000, 205.000] 0.460 [0.340, 0.570] 1.260 [0.810, 1.590] 4.310 [1.341, 15.364] 5.490 [1.494, 21.420] 2.150 [1.610, 2.660] 1.107 [0.890, 1.320] 1.130 [0.880, 1.430] 356.027 [301.600, 423.500] 352.200 [295.000, 419.100] 368.500 [325.400, 430.700] 74.500 [62.863, 98.141] 73.600 [61.300, 94.000] 81.700 [67.400, 109.800] 80.601 [62.120, 97.830] 82.026 [65.640, 98.590] 76.130 [54.010, 93.580] 10.200 [7.500, 13.400] 10.400 [7.700, 13.700] 3.300 [2.200, 5.300] 16.800 [16.000, 17.700] 16.800 [16.000, 17.800] 16.800 [15.900, 17.500] 3.350 [2.850, 3.940] 6.300 [4.950, 8.529] 36.700 [33.600, 39.300] 36.900 [33.700, 39.600] 35.800 [33.000, 38.400] 29.100 [26.000, 32.300] 29.000 [26.100, 32.300] 29.400 [26.000, 32.200] 2.602 [2.140, 3.020] 1.280 [1.160, 1.650] 2.008 [1.235, 3.133] 15.701 [13.320, 19.513] 15.552 [12.950, 19.294] 16.890 [14.250, 20.544] 18.000 [12.500, 29.100] 18.000 [12.200, 28.900] 18.079 [13.700, 31.000] 84.000 [70.800, 100.400] 84.000 [70.200, 99.100] 84.200 [72.100, 102.400] 57.000 [49.000, 62.000] 58.000 [51.000, 62.768] 51.189 [43.000, 58.000] Abbreviations: ALB, Albumin; ALP, Alkaline Phosphatase; ALT, Alanine transaminase; ARNI, Angiotensin receptor‐neprilysin inhibitor; BNP, brain natriuretic peptide; COPD, Chronic obstructive pulmonary disease; Cr, Creatinine; CRP, C‐reactive protein; DBiL, Direct Bilirubin; eGFR, Estimated glomerular filtration rate; FBG, Fasting blood glucose; FIB, Fibrinogen; FT3, Free triiodothyronine 3; FT4, Free triiodothyronine 4; GLB, Globulin; HCY, Homocysteine; HDL‐C, High‐density lipoproteincholesterol; HGB, Hemoglobin; IBiL, Indirect Bilirubin; LA, Left atrium; LDL‐C, Low‐density lipoprotein cholesterol; LOS, Length of stay; LV, Left ventricle; LVEF, Left ventricular ejection fractions; NYHA, New York Heart Association; PLT, Platelets counts; RA, Right atrium; RV, Right ventricle; TG, Triglyceride; TSH, Thyroid stimulating hormone; TT, Thrombin time; UA, Uric acid; WBC, White blood cell counts. Feature Selection A total of 58 features were initially included in this study. Five variables with more than 30% missing data (highest education level, left ventricular fractional shortening [FS], history of coronary artery disease, history of atrial fibrillation, and use of SGLT2 inhibitors) were excluded (Table S1). For variables with less than 30% missing data, imputation was performed using the KNN method. After correlation testing, three additional variables (red blood cells, total cholesterol, total bilirubin) were excluded. To optimize model performance, three feature selection methods were applied in the training set: RF, the Boruta algorithm, and a combination of both. RF identified the top 13 features, including BNP, HGB, LVEF, length of hospital stays (LOS), FT4, age, creatinine (Cr), FT3, CRP, UA, LDL‐C, HCY, and potassium (K) (Figure 2A). The Boruta algorithm selected features based on Z‐scores, identifying age, diabetes, admission way, LOS, BNP, HGB, Cr, eGFR, FT4, LVEF, K, ALB, and LV as important features (Figure 2B). The combination of both methods yielded 18 key features (Figure 2C). Feature selection. (A) RF:Feature importance is ranked from highest to lowest; (B) Boruta: The horizontal axis is the name of each variable, and the vertical axis represents the importance of the variable. The green box shows the top 11 important variables, yellow represents 2 tentative attributes, red represents unimportant variables, and blue boxes represent shadows; (C) The features selected by combining the two methods. Model Development and Comparison In the training dataset, XGBoost, LightGBM, AdaBoost, GBDT, GNB, and SVM models were developed. Hyperparameter optimization was conducted via grid search and five‐fold cross‐validation, detailed parameters are provided in Table S2. The performance of the models, based on the three feature selection methods, was evaluated in the validation set, as detailed in Tables 2, 3, 4. Among the models utilizing RF‐selected features, four had AUC values exceeding 0.8, with XGBoost and AdaBoost achieving the highest AUC of 0.861 (Figure 3A). The Boruta‐XGBoost model yielded the highest AUC at 0.873 (Figure 3B). The AdaBoost model, using combined feature selection methods, also performed well with an AUC of 0.862 (Figure 3C). Notably, both XGBoost and AdaBoost consistently demonstrated strong performance, with AUC values exceeding 0.85 across all three feature selection methods. In contrast, GBDT models performed relatively poorly, with AUC values consistently below 0.75. Additionally, we re‐evaluated the correlation among the features selected by the Boruta algorithm, confirming that all correlation coefficients were less than 0.8 (Figure S2). Based on these results, the Boruta‐XGBoost model was selected as the optimal predictive model, offering the highest AUC, along with favorable accuracy (0.769), sensitivity (0.839), specificity (0.747), F1 score (0.634), and a low Brier score (0.130). Notably, the cohort was severely imbalanced, with a composite endpoint rate of 21.7% and a corresponding NIR of 78.3%. The accuracy of the best Boruta‐XGBoost model (76.9%) was marginally lower than the NIR, which is inevitable in imbalanced datasets where a trivial “no‐event” classifier yields high accuracy without clinical value. The moderate F1 score also reflects this imbalance. Critically, the model achieved an excellent AUC of 0.873 and a high sensitivity of 0.839, indicating strong discriminative ability and reliable performance in identifying high‐risk patients, this is clinically more meaningful than overall accuracy for heart failure risk stratification. TABLE 2Performance of machine learning model based on Boruta algorithm.ModelAUCAccuracySensitivitySpecificityF1‐scoreBrier‐scoreXGBoost0.8730.7690.8390.7470.6340.130LightGBM0.7470.6920.6450.7070.5000.182AdaBoost0.8690.7540.8060.7370.6100.192GBDT0.6600.7620.5850.6720.5130.182GNB0.8470.6850.8060.6460.5490.153SVM0.7890.7080.7740.6870.5580.135 Performance of machine learning model based on Boruta algorithm. TABLE 3Performance of machine learning model based on Random forest.ModelAUCAccuracySensitivitySpecificityF1‐scoreBrier‐scoreXGBoost0.8610.8080.7420.8280.6480.133LightGBM0.7850.6620.8060.6160.5320.179AdaBoost0.8610.7620.7420.7680.5970.210GBDT0.6770.7620.6350.6230.5130.182GNB0.8380.7460.8390.7170.6120.157SVM0.8420.7310.8710.6870.6070.133 Performance of machine learning model based on Random forest. TABLE 4Performance of combined model based on Random Forest and Boruta.ModelAUCAccuracySensitivitySpecificityF1‐ScoreBrier‐scoreXGBoost0.8580.7920.8060.7880.6490.135LightGBM0.6700.7620.5490.5220.4920.181AdaBoost0.8620.7690.7740.7680.6150.210GBDT0.7400.6080.6820.5660.4740.182GNB0.8560.7000.7740.6770.5520.151SVM0.8020.7540.7420.7580.5900.135 Performance of combined model based on Random Forest and Boruta. ROC curves were constructed by three groups using six different machine learning algorithms. (A) Random Forest, (B) Boruta, (C) Combination of Random Forest and Boruta algorithm. Feature Importance and Model Interpretation The SHAP technique was used to analyze and interpret the feature importance in the Boruta‐XGBoost model. The SHAP summary plot illustrated the ranking of the 13 included features by importance, with the x‐axis representing the average SHAP value and each row representing a feature. The top five most important features contributing to the prediction of readmission or death risk during the vulnerable phase of HF were identified as HGB, FT4, age, diabetes, and K (Figure 4A). As shown in Figure 4B, each point in the plot represents an individual sample, and the color indicates how the feature value affects the prediction outcome—red for higher feature values and blue for lower. The plot demonstrated that older age, higher BNP levels, lower HGB concentration, and reduced LVEF were associated with an increased probability of experiencing composite endpoint events. SHAP explanations for Boruta‐XGBoost model. (A) The ranking of feature importance in model predictions. The x‐axis represents SHAP values, with larger SHAP values indicating greater importance of the corresponding variable. (B) Each point represents a feature value, with different colors indicating the final impact of that feature on the model's output. Red represents higher values, while blue represents lower values. Additionally, SHAP force plots were utilized to visually depict the impact of key features on individual patient outcomes. Red arrows to the left indicate increased risk of composite endpoint events, while blue arrows to the right signify reduced risk. The length of each arrow represents the magnitude of the feature's contribution to the outcome. For example, a 79‐year‐old patient with diabetes, an LVEF of 42%, HGB of 102 g/L, and Cr of 90.3 μmol/L had a high SHAP value (0.98) and a corresponding predicted risk score of 0.979 (Figure 5A). In contrast, a 68‐year‐old patient with a 6‐day hospital stay, BNP of 635.4 ng/L, and HGB of 140 g/L had a low SHAP value (0.00) and a predicted risk score of 0.003 (Figure 5B). Individualized predictive outcomes for two patients. (A) high‐risk patient, (B) low‐risk patient. Discussion Heart failure (HF), as the end‐stage manifestation of cardiovascular disease, is characterized by high morbidity, high mortality, and high rates of hospital readmission, severely impeding socioeconomic development and posing a significant threat to healthcare safety [25]. During the vulnerable phase of the first three months post‐discharge, patients are at heightened risk for adverse outcomes. Identifying risk factors for high‐risk patients during this period and optimizing treatment strategies to mitigate these risks has become a critical challenge in the medical field. Although several strategies have been implemented, such as the European Society of Cardiology (ESC) guidelines recommending the assessment of congestion status before and shortly after discharge [26], and Latif et al. suggesting a focus on composite endpoint events within 30, 60, or 90 days post‐discharge—the readmission and mortality risks during the vulnerable phase remain high [27]. Therefore, this study aims to develop a tool for assessing the risk of unplanned readmission or all‐cause mortality during the vulnerable phase in HF patients, which is crucial for healthcare providers to identify high‐risk factors and take timely preventive measures to improve prognosis. With the advancement of artificial intelligence (AI), the application of ML to analyze medical data has shown great potential in assisting disease diagnosis, prognosis prediction, medical imaging interpretation, and individualized treatment dose selection [15, 28, 29]. ML algorithms are broadly divided into two categories: supervised and unsupervised learning. Supervised learning aims to model classification and regression problems based on input data with known outputs. Because of its ability to learn from labeled data and predict and generalize to unknown data, supervised learning has wide practical applications, with common algorithms including SVM, logistic regression, decision trees, and artificial neural networks [30, 31]. In this study, we developed risk models for predicting composite endpoint events during the vulnerable period in elderly HF patients using five ML algorithms: XGBoost, LightGBM, AdaBoost, GBDT, GNB, and SVM. Feature selection, a critical step in ML, was performed using RF and Boruta algorithms to reduce the number of features and improve model performance. The Boruta algorithm, in particular, effectively identifies significant predictors by avoiding the omission of potentially important features. Although combining the two methods expanded the feature set to 18, we observed no improvement in model performance. Therefore, to enhance clinical utility, we ultimately chose the Boruta algorithm, which retains fewer but more relevant features. To handle missing data, we employed the KNN algorithm to impute values based on the similarity between feature vectors. Additionally, Min‐Max normalization was applied to standardize variables with different scales. Our final results showed that the risk prediction model based on the Boruta‐XGBoost algorithm demonstrated excellent performance in terms of AUC, sensitivity, specificity, and Brier score, making it highly predictive of readmission or mortality during the vulnerable period in elderly HF patients. Boruta, an algorithm based on RF classification, iteratively generates random features to identify important variables correlated with the outcome, and it can be combined with other classifiers to enhance model performance. XGBoost, an improved GBDT algorithm, optimizes the sequential ensemble of decision trees, reducing model error and efficiently handling classification and regression tasks, with rapid and precise training, similar to findings in previous studies [32, 33]. Given that a lack of interpretability is a major barrier to the clinical application of ML models in healthcare, we incorporated the SHAP framework to provide both global and local explanations of the model. This not only revealed feature importance but also highlighted whether the features had a positive or negative impact on the output. To further validate the incremental value of machine learning, we compared the significant variables between event and non‐event groups (p < 0.05) with SHAP identified important features. A total of 21 variables showed significant intergroup differences. The top 13 SHAP important features included several of these 21 significant variables, and further identified K and FT4 (p > 0.05) as key predictors, which were missed by traditional univariate analysis due to their nonlinear relationships with outcomes. Overall, variables with stronger univariate differences tended to have greater importance in the machine learning model, confirming that the model can capture both conventional risk factors and hidden nonlinear predictors. The results identified the five most important factors associated with readmission or mortality during the vulnerable phase in HF patients: HGB, FT4, age, diabetes, and K. Additionally, BNP, LVEF, and LOS were also significant. BNP plays a crucial role in assessing the severity and predicting long‐term outcomes in HF and is a commonly used biomarker in clinical practice [34]. Our study further underscores its prognostic value during the vulnerable period. HGB, a routine blood test parameter, reflects anemia status, and studies have shown that anemia as a common complication in HF patients, is highly associated with mortality and hospitalization risk [35, 36]. Our findings further highlight that reduced HGB concentration is a key risk factor for adverse outcomes in elderly HF patients. Moreover, while previous studies suggest that longer hospital stays can reduce the risk of all‐cause and HF‐related readmissions [37]. Our findings indicate that extended hospitalization is associated with a higher risk of readmission or death. Another noteworthy observation is the association between thyroid hormones and clinical outcomes. Thyroid hormones are crucial for regulating normal growth, development, and metabolism [38]. Our study identified FT4 as a significant predictor of composite endpoint events during the vulnerable phase in HF patients; this finding has rarely been reported previously. Dysregulated FT4 levels are associated with impaired systolic/diastolic function, increased systemic vascular resistance, and overactivation of the renin‐angiotensin‐aldosterone system in elderly HF patients. Subclinical thyroid dysfunction reflected by abnormal FT4 has also been linked to higher risks of cardiovascular events, readmission, and mortality in HF cohorts. This association highlights FT4 as a novel potential biomarker for risk stratification in elderly HF patients and warrants further clinical trials to validate its association. Limitations Despite utilizing advanced techniques such as KNN for data preprocessing, multiple feature selection algorithms, and grid search combined with five‐fold cross‐validation to optimize hyperparameters for improved model performance, this study has several limitations. First, the data were obtained from a single center, with a relatively small sample size and lack of external validation. Future research should incorporate multi‐center datasets to validate the model's generalizability and ensure its reliability in broader clinical settings. Second, although the study included various sociodemographic factors, laboratory markers, biomarkers, and comorbidities as predictor variables, several non‐clinical factors—such as anxiety, depression, lack of social support, specific lifestyle habits, or economic conditions, were not considered. These factors could potentially influence the overall prediction outcomes. Additionally, this study focused on the composite endpoint of unplanned readmission or all‐cause mortality, which is the core high‐risk outcome for elderly heart failure patients. Separate prediction models for readmission and death were not constructed due to the small number of death events (n = 23), which would lead to model overfitting and poor stability. Future multi‐center studies with larger sample sizes will develop independent prediction models for readmission and death to achieve differential risk prediction. Finally, the integration of deep learning techniques with more comprehensive clinical datasets presents a promising direction for future research and warrants further exploration to enhance model performance and applicability. Conclusion The development of individualized prevention strategies and the implementation of targeted medical interventions based on the identified risk factors for readmission or mortality during the vulnerable period in elderly HF patients are critical for improving patient outcomes. This study successfully developed a predictive model for assessing the risk of readmission or mortality in this high‐risk population using various ML algorithms. Additionally, the SHAP framework was employed to elucidate key predictive factors and their relative importance, enhancing clinicians' ability to identify high‐risk patients. The findings of this study provide robust support for early clinical intervention, facilitating a more accurate and evidence‐based assessment of adverse event risks during the vulnerable phase, ultimately contributing to improved prognosis in elderly HF patients. Author Contributions H. Luo and J. Li designed research. H. Luo and Q. Wu collected and analyzed the data. Z. Zheng, X. Wang, N. Lai, Y. Li, X. Zheng, Y. Li, D. Li and K. Guo performed research. H. Luo, Q. Wu and Z. Zheng wrote the manuscript. All other authors contributed feedback to writing, reviewing, and editing the manuscript. Conflicts of Interest The authors declare no conflicts of interest. Supporting information Table S1: Missing feature attributes and proportions. Table S2: The optimization settings of the hyperparameters. Figure S1: Model construction based on three feature selection methods. Figure S2: Correlation test of included features based on Boruta algorithm. Acknowledgments The authors have nothing to report. Data Availability Statement The data that support the findings of this study are available on request from the corresponding author upon reasonable request. References Associated Data Supplementary Materials Table S1: Missing feature attributes and proportions. Table S2: The optimization settings of the hyperparameters. Figure S1: Model construction based on three feature selection methods. Figure S2: Correlation test of included features based on Boruta algorithm. Data Availability Statement The data that support the findings of this study are available on request from the corresponding author upon reasonable request.