Prognostic effect of polypharmacy in ambulatory patients with heart failure: a machine learning-based analysis Authors: Zahra Hooshanginezhad, Houshang Bavandpour Karvane, Babak Mohammadi, Sepehr Nemati Published: 2026 ABSTRACT BackgroundManaging heart failure often involves polypharmacy, reflecting the challenge of balancing multiple treatments to achieve the best outcomes for patients. We aimed to investigate the effect of polypharmacy on survival in ambulatory patients with heart failure and identify key predictors of survival.MethodsWe conducted a secondary analysis of data from 1375 ambulatory patients with heart failure managed at a heart failure clinic in Spain between 2006 and 2016. Patients were stratified into low polypharmacy (< 5 cardiovascular medications) and high polypharmacy groups (≥ 5 cardiovascular medications). Survival was evaluated using Kaplan-Meier curves, log-rank tests, and a multivariable random forest Cox regression model adjusting for demographic and clinical confounders using propensity scores.ResultsThere was a significant relationship between the number of medications used and survival (log-rank test, P = 0.017) with the most pronounced risk observed in those with seven or more medications. Additionally, patients in the high polypharmacy group showed significantly reduced survival probabilities than those in the low polypharmacy group (P = 0.016). The top important predictors of survival were age, N-terminal pro B-type natriuretic peptide, New York Heart Association functional class, heart failure duration, sacubitril-valsartan, β-blockers, and angiotensin-converting enzyme inhibitors or angiotensin receptor blockers (all P < 0.001). Multivariable analysis (C-index = 0.804) showed that high polypharmacy was independently associated with reduced survival (P < 0.001).ConclusionsHigh polypharmacy is associated with reduced long-term survival in patients with heart failure. This highlights the need for personalized prescribing strategies to minimize the risks associated with polypharmacy while maximizing therapeutic benefits. Introduction Heart failure (HF) is a major global health challenge, significantly contributing to morbidity, mortality, and healthcare expenditures worldwide [1]. It is a progressive condition characterized by frequent hospitalizations and poor quality of life, further exacerbating the economic burden and underlining the critical need for effective management strategies [2]. Over the last few decades, the treatment of HF has evolved, with clinical evidence supporting the use of multiple pharmacological agents that target diverse pathophysiological mechanisms to improve survival and reduce hospitalizations [3, 4]. While polypharmacy is associated with better therapeutic outcomes, it also poses risks such as drug-drug interactions and decreased adherence, which may ultimately impact long-term prognosis [5–7]. Despite the known benefits of combining HF therapies, their effects on patient outcomes over time remain insufficiently understood [8] . As a multifaceted condition, HF involves neurohormonal dysregulation, hemodynamic alterations, and myocardial remodeling, necessitating multiple pharmacological agents targeting various pathways [9]. Current HF guidelines suggest a set of pharmacological agents, such as β-blockers, angiotensin receptor blockers (ARB), angiotensin-converting enzyme inhibitors (ACEI), mineralocorticoid receptor antagonists (MRA), and sacubitril/valsartan, yet treatment based on patient characteristics remains debated [10–12]. While clinical trials offer valuable insights into treatment efficacy, they often fail to capture the complex, comorbid nature of real-world HF patients (e.g., hypertension, diabetes, and chronic kidney disease) who are frequently prescribed more diverse and prolonged regimens [5, 13, 14]. The current literature lacks comprehensive evaluations of how different combinations of HF medications influence long-term outcomes, especially when considering the interplay of these drugs [15, 16]. Polypharmacy in this setting can lead to increased risks of adverse effects, difficulties in adherence, and a challenging balance between therapeutic benefits and potential harms [17]. Capturing the complexity of HF management through traditional analyses is difficult, as these methods often fail to account for the interrelationships between multiple drugs and their effects on long-term patient outcomes [11]. The aim of conducting this study was to evaluate the prognostic impact of polypharmacy in heart failure with a particular focus on the effects of specific medication groups, using advanced machine learning models. We used analytical techniques to enhance our understanding of which medications affect outcomes while accounting for numerous variable relationships. This is crucial for refining clinical decision-making and optimizing therapeutic interventions for better outcomes in patients with HF. We hypothesized that polypharmacy would affect patients’ long-term survival. Methods Population and data source We conducted a secondary analysis of data from ambulatory HF patients, used by Lupón et al. in a cohort study aimed at evaluating the prognostic significance of circulating neprilysin [18]. The data were obtained from patients at the Germans Trias i Pujol Hospital in Barcelona, Spain, between May 2006 and February 2016, by Lupón et al. and Bayés-Genís et al. [18–20]. The study included outpatients receiving care at a multidisciplinary HF clinic [18]. Patients were referred to the HF clinic by cardiology or internal medicine services, with fewer referrals from the emergency department or other hospital units. They were included if they had a diagnosis of HF according to the European Society of Cardiology guidelines, irrespective of etiology, with either a history of at least one HF-related hospitalization or reduced LVEF [18, 19]. Blood samples were drawn between 9:00 AM and noon, then stored at -80 °C without undergoing freeze-thaw cycles before analysis. Patients were followed longitudinally at regular intervals, with visits occurring quarterly with nursing staff, biannually with physicians, and as needed with specialists, such as geriatricians, psychiatrists, and rehabilitation physicians, particularly in cases of decompensation [20]. Collected data were verified by the Catalan and Spanish Health Systems and the Spanish National Death Registry. The follow-up period concluded on October 31, 2019 [18]. Lupón et al. made their dataset publicly available, allowing for further analysis. We conducted further analysis of the dataset to evaluate the prognostic implications of polypharmacy in HF patients, using a machine learning approach to identify significant predictors. Data availability The anonymized dataset is publicly available at https://doi.org/10.1371/journal.pone.0249674.s001 as an SPSS file and at https://doi.org/10.1371/journal.pone.0249674.s002 as a Microsoft Excel supplementary file (last accessed on September 9, 2024). The dataset accompanies Lupón et al.‘s open-access article [18], which is distributed under the Creative Commons Attribution License. This license permits unrestricted use, distribution, and reproduction in any medium, provided that proper attribution is given to the original source. Ethical considerations Our research did not involve direct assessment of individual participant characteristics or the collection of identifiable personal information. Instead, we conducted a secondary analysis using de-identified data from a publicly accessible dataset. We ensured proper attribution to the original data source and strictly adhered to ethical guidelines by refraining from republishing raw data focusing solely on the analysis and interpretation of the publicly available information. The primary study received approval from the Ethics Committee of the Hospital Universitari Germans Trias i Pujol (Comitè d’Ètica de la Investigació), with the ethical code REGI-UNIC PI-18-037 and all participants provided written informed consent. All study procedures were in accordance with the principles outlined in the Declaration of Helsinki [18]. Study candidate variables The study outcome was cardiovascular mortality. Cardiovascular mortality was defined as mortality attributable to HF (either decompensated HF or treatment-refractory HF in the absence of another identifiable cause), sudden cardiac death (unexpected, unwitnessed, or witnessed death in a previously stable patient without evidence of worsening HF or other identifiable causes), acute myocardial infarction (directly associated with an acute myocardial infarction due to mechanical, hemodynamic, or arrhythmic complications), stroke (in conjunction with the onset of an acute neurological deficit), or other cardiovascular etiologies (e.g., aneurysm rupture, peripheral ischemia, or aortic dissection). Fatal events were identified using clinical records, data from hospital wards, emergency departments, general practitioners, and direct communication with patients’ relatives. The dataset included a comprehensive set of covariates: age (years), sex, HF duration (months), diabetes, hypertension, chronic obstructive pulmonary disease (COPD), New York Heart Association (NYHA) functional class, body mass index (BMI; kg/m²), N-terminal pro-brain natriuretic peptide (NT-proBNP; pg/mL), neprilysin levels (ng/mL), and left ventricular ejection fraction (LVEF). Information on cardiac resynchronization therapy (CRT) and medications was recorded as binary variables and included the use of β-blockers, angiotensin-converting enzyme inhibitors (ACEIs) or angiotensin II receptor blockers (ARBs), sacubitril/valsartan, mineralocorticoid receptor antagonists (MRAs), ivabradine, loop diuretics, digoxin, hydralazine, and nitrates. Additionally, follow-up duration for mortality (years) was also documented. Data analyses We evaluated patients’ survival based on the number of medications per patient. Kaplan-Meier survival curves were plotted to estimate survival probabilities over time, with a log-rank test used to assess the statistical significance of differences in survival between groups. We then categorized patients into two groups of < 5 and ≥ 5 cardiovascular medication use, as this is a commonly used cutoff in the literature for defining polypharmacy [8]. We used propensity scores to balance baseline characteristics, such as comorbidities between patients receiving high polypharmacy and those receiving fewer medications. This method reduces confounding and allows for a more accurate assessment of the polypharmacy effect on survival independent of other covariates. Propensity scores were estimated using an XGBoost algorithm, incorporating demographic, clinical, and medication-related covariates. We selected XGBoost due to its ability to handle complex non-linear relationships among variables [21]. The propensity scores were subsequently included as a covariate in a Cox regression proportional hazard model. However, the proportional hazards assumption did not hold due to the complex interrelationship among the study covariates. Consequently, we conducted a random forest Cox regression including the propensity score as a confounder-adjusted covariate. While simple Cox Regression assumes linear relationships between predictors and the hazard, random forest Cox regression captures non-linearities and interactions, making it more flexible and robust in real-world scenarios. This method does not rely on the proportional hazards assumption for accurate results. Additionally, it handles high-dimensional data better and is less sensitive to outliers. Meanwhile, in a random forest Cox model, the calculation of traditional hazard ratios is not directly applicable. This is because random forests are ensemble learning techniques that generate predictions through a collection of decision trees, rather than estimating coefficients for individual variables. However, they assess the importance of variables in predicting survival, which provides insights into the contribution of each covariate to the model’s predictions. The dataset was split into training and test sets (70%/30%) to evaluate model performance, with the concordance index (C-index) used to assess predictive accuracy. Results are presented as mean (SD) for continuous variables and as count (%) for categorical data. The level of significance was set at two-tailed α = 0.05. Data analyses and visualization were performed using R software version 4.0.2. (R Foundation for Statistical Computing, Vienna, Austria. https://www.R-project.org/). The analyses were performed using the survival, survminer, randomForestSRC, and xgboost R packages, with results visualized through Kaplan-Meier plots and variable importance plots. Results Sample The dataset included 1428 patients with no duplicate entries. Cardiovascular mortality was missing in 4% of the patients. Since this was a primary outcome of the study, we excluded these patients from the analysis, resulting in a final analytic sample of 1375 patients (70.3% male) with a mean age of 67.5 (12.8) years. Missing values for NT-proBNP (3%) and BMI (1%) were imputed using a single iteration of a random forest algorithm to ensure complete data for further analysis. The median (interquartile range) follow-up period was 5.3 (3.0, 8.9) years. Table 1 shows the results of comparisons between HP and LP groups, Fig. 1.A illustrates the frequency of multiple drugs prescribed for each patient, and Fig. 1.B shows the distribution of medication use across the study sample. Most patients underwent polypharmacy (N = 900; 65.5%), typically with 5 medications and commonly including loop diuretics, β-blockers, and ACEI-ARB. Table 1Comparison of patient characteristics between high and low polypharmacy groupsTotalLow Polypharmacy (< 5 Medications)High Polypharmacy (≥ 5 Medications) p N 1375475900Age (year)67.51 (12.8)67.05 (14.0)67.75 (12.10)0.333HF Duration (month)41.21 (58.7)31.85 (46.7)46.15 (63.63)< 0.001*BMI (kg/m2)27.70 (5.4)27.14 (5.4)28.00 (5.46)0.005*NTproBNP (pg/mL)3842.84 (10734.6)4438.65 (13140.1)3528.39 (9208.4)0.135LVEF35.85 (14.06)39.26 (14.7)34.05 (13.34)< 0.001*Female Sex (%)408 (29.7)142 (29.9)266 (29.6)0.945Ischemic (%)670 (48.7)199 (41.9)471 (52.3)< 0.001*Diabetes (%)550 (40.0)152 (32.0)398 (44.2)< 0.001*HTN (%)884 (64.3)281 (59.2)603 (67.0)0.005*COPD (%)230 (16.7)79 (16.6)151 (16.8)1.000NYHA (%)0.009* 179 (5.7)41 (8.6)38 (4.2) 2958 (69.7)323 (68.0)635 (70.6) 3328 (23.9)107 (22.5)221 (24.6) 410 (0.7)4 (0.8)6 (0.7)Beta Blocker (%)1259 (91.6)393 (82.7)866 (96.2)< 0.001*ACE-ARB (%)1218 (88.6)385 (81.1)833 (92.6)< 0.001*Sacubitril-Valsartan (%)119 (8.7)3 (0.6)116 (12.9)< 0.001*MRA (%)924 (67.2)154 (32.4)770 (85.6)< 0.001*Ivabradin (%)291 (21.2)23 (4.8)268 (29.8)< 0.001*Loop Duretic (%)1273 (92.6)383 (80.6)890 (98.9)< 0.001*Digoxin (%)590 (42.9)73 (15.4)517 (57.4)< 0.001*Hydralazine (%)556 (40.4)86 (18.1)470 (52.2)< 0.001*Nitrates (%)754 (54.8)135 (28.4)619 (68.8)< 0.001*HF Heart Failure, BMI Body Mass Index (k/m2), NTproBNP N-terminal pro-brain natriuretic peptide LVEF Left Ventricular Ejection Fraction, HTN blood Hypertension, COPD Chronic Obstructive Pulmonary Disease, NYHA the New York Heart Association, ACE-ARB Angiotensin-Converting Enzyme Inhibitor or Angiotensin Receptor Blocker, MRA Mineralocorticoid Receptor Antagonists Table 1Comparison of patient characteristics between high and low polypharmacy groupsTotalLow Polypharmacy (< 5 Medications)High Polypharmacy (≥ 5 Medications) p N 1375475900Age (year)67.51 (12.8)67.05 (14.0)67.75 (12.10)0.333HF Duration (month)41.21 (58.7)31.85 (46.7)46.15 (63.63)< 0.001*BMI (kg/m2)27.70 (5.4)27.14 (5.4)28.00 (5.46)0.005*NTproBNP (pg/mL)3842.84 (10734.6)4438.65 (13140.1)3528.39 (9208.4)0.135LVEF35.85 (14.06)39.26 (14.7)34.05 (13.34)< 0.001*Female Sex (%)408 (29.7)142 (29.9)266 (29.6)0.945Ischemic (%)670 (48.7)199 (41.9)471 (52.3)< 0.001*Diabetes (%)550 (40.0)152 (32.0)398 (44.2)< 0.001*HTN (%)884 (64.3)281 (59.2)603 (67.0)0.005*COPD (%)230 (16.7)79 (16.6)151 (16.8)1.000NYHA (%)0.009* 179 (5.7)41 (8.6)38 (4.2) 2958 (69.7)323 (68.0)635 (70.6) 3328 (23.9)107 (22.5)221 (24.6) 410 (0.7)4 (0.8)6 (0.7)Beta Blocker (%)1259 (91.6)393 (82.7)866 (96.2)< 0.001*ACE-ARB (%)1218 (88.6)385 (81.1)833 (92.6)< 0.001*Sacubitril-Valsartan (%)119 (8.7)3 (0.6)116 (12.9)< 0.001*MRA (%)924 (67.2)154 (32.4)770 (85.6)< 0.001*Ivabradin (%)291 (21.2)23 (4.8)268 (29.8)< 0.001*Loop Duretic (%)1273 (92.6)383 (80.6)890 (98.9)< 0.001*Digoxin (%)590 (42.9)73 (15.4)517 (57.4)< 0.001*Hydralazine (%)556 (40.4)86 (18.1)470 (52.2)< 0.001*Nitrates (%)754 (54.8)135 (28.4)619 (68.8)< 0.001*HF Heart Failure, BMI Body Mass Index (k/m2), NTproBNP N-terminal pro-brain natriuretic peptide LVEF Left Ventricular Ejection Fraction, HTN blood Hypertension, COPD Chronic Obstructive Pulmonary Disease, NYHA the New York Heart Association, ACE-ARB Angiotensin-Converting Enzyme Inhibitor or Angiotensin Receptor Blocker, MRA Mineralocorticoid Receptor Antagonists Comparison of patient characteristics between high and low polypharmacy groups HF Heart Failure, BMI Body Mass Index (k/m2), NTproBNP N-terminal pro-brain natriuretic peptide LVEF Left Ventricular Ejection Fraction, HTN blood Hypertension, COPD Chronic Obstructive Pulmonary Disease, NYHA the New York Heart Association, ACE-ARB Angiotensin-Converting Enzyme Inhibitor or Angiotensin Receptor Blocker, MRA Mineralocorticoid Receptor Antagonists Fig. 1A The number of cardiovascular medications prescribed for patients. B The frequency of each prescribed medication. ACE-ARB, Angiotensin-Converting Enzyme Inhibitor or Angiotensin Receptor Blocker; MRA, Mineralocorticoid Receptor Antagonist A The number of cardiovascular medications prescribed for patients. B The frequency of each prescribed medication. ACE-ARB, Angiotensin-Converting Enzyme Inhibitor or Angiotensin Receptor Blocker; MRA, Mineralocorticoid Receptor Antagonist Kaplan-Meier survival curves The Kaplan-Meier curves reveal a significant association between polypharmacy and survival outcomes in patients with heart failure. Figure 2A indicates that patients prescribed fewer medications (N ≤ 3) had more favorable long-term survival compared to those in higher polypharmacy categories (N ≥ 7). This suggests that the number of medications prescribed for each patient affects the survival probability. Patients with the highest number of medications experience the best survival rates for the first few years. However, after this period, survival begins to decline to the lowest through the remainder of the follow-up. Figure 2B further highlights this trend, showing a statistically significant reduction in survival among patients in the high-polypharmacy (HP) group (≥ 5 medications) compared to those in the low-polypharmacy (LP) group (< 5 medications). The survival curves begin to separate within the first few years with a steeper decline in the HP group, indicating that the impact of polypharmacy on survival emerges early and persists over time. A statistically significant difference in survival probability was observed between patients in the HP and LP groups, log-rank test χ²(1) = 5.8, P = 0.016. Fig. 2Kaplan-Meier survival analysis illustrating the association between polypharmacy and cardiovascular mortality among patients with heart failure. A Survival probabilities are stratified by the number of prescribed medications (N ≤ 3, 4, 5, 6, and ≥ 7). The p-value from the log-rank test indicates a statistically significant difference in survival across groups. B Survival probabilities comparing LP (< 5 medications) and HP (≥ 5 medications) subgroups. A statistically significant reduction in survival probability is observed in the HP group compared to the LP group. LP, Low-polypharmacy (< 5 medications); HP, high-polypharmacy (≥ 5 medications) Kaplan-Meier survival analysis illustrating the association between polypharmacy and cardiovascular mortality among patients with heart failure. A Survival probabilities are stratified by the number of prescribed medications (N ≤ 3, 4, 5, 6, and ≥ 7). The p-value from the log-rank test indicates a statistically significant difference in survival across groups. B Survival probabilities comparing LP (< 5 medications) and HP (≥ 5 medications) subgroups. A statistically significant reduction in survival probability is observed in the HP group compared to the LP group. LP, Low-polypharmacy (< 5 medications); HP, high-polypharmacy (≥ 5 medications) Random forest cox model Using propensity score adjustment, we accounted for potential confounders of polypharmacy—e.g., comorbidities that could influence both the selection of polypharmacy and survival—by balancing the HP and LP groups based on the observed covariates. To calculate the propensity scores, we employed the XGBoost algorithm. Our investigations showed that the proportional hazards assumption for a Cox regression model fit was not met, global χ2(21) = 52.0, P < 0.001. Consequently, we developed a random forest Cox model using propensity score adjustment. The model showed a robust C-index of 0.804, demonstrating a strong discriminatory ability in predicting patient survival. Figure 3 shows variable importance for the random forest Cox model. The top three important factors affecting the probability of survival were age, NTproBNP, and NYHA. The propensity score was the 8th important factor reflecting the underlying adjustment for differences between the HP and LP groups. It was higher in rank compared with variables such as LVEF, ischemic etiology, diabetes, HTN, and COPD. We categorized age, NTproBNP, and duration based on their median values and compared median predicted survival between patient groups in the top seven variables and between those with and without HP. The test results were clinically plausible and showed the unfavorable effect of HP on survival (Table 2). Overall, our findings implied an unfavorable effect of HP on survival in ambulatory patients with HF adjusting for a large number of confounders. Fig. 3Variable importance for the random forest Cox proportional hazard model using propensity score for polypharmacy. The propensity score ranked 8th in the variable importance list. NTproBNP, N-terminal pro-brain natriuretic peptide; NYHA, the New York Heart Association; ACE-ARB, Angiotensin-Converting Enzyme Inhibitor or Angiotensin Receptor Blocker; LVEF, Left Ventricular Ejection Fraction; BMI, Body Mass Index; MRA, Mineralocorticoid Receptor Antagonist; HTN, (blood) Hypertension; COPD, chronic obstructive pulmonary disease Variable importance for the random forest Cox proportional hazard model using propensity score for polypharmacy. The propensity score ranked 8th in the variable importance list. NTproBNP, N-terminal pro-brain natriuretic peptide; NYHA, the New York Heart Association; ACE-ARB, Angiotensin-Converting Enzyme Inhibitor or Angiotensin Receptor Blocker; LVEF, Left Ventricular Ejection Fraction; BMI, Body Mass Index; MRA, Mineralocorticoid Receptor Antagonist; HTN, (blood) Hypertension; COPD, chronic obstructive pulmonary disease Table 2Comparisons of survivals between patient groups adjusted for the study covariates. For continuous variables, median values were used for groupingGroupSurvivalLog-rank testχ2DoF P Age (year) ≤700.580721.01< 0.001* >700.269NTproBNP (pg/mL) ≤15340.593595.01< 0.001* >15340.291NYHA 10.747327.03< 0.001* 20.440 30.264 40.172Duration (month) ≤15.50.45832.21< 0.001* >15.50.344Sacubitril-Valsartan Not prescribed0.37648.91< 0.001* Prescribed0.670 β-blocker (%) Not prescribed0.25459.01< 0.001* Prescribed0.419ACEI-ARB (%) Not prescribed0.246107.01< 0.001* Prescribed0.432Polypharmacy LP0.44441.51< 0.001* HP0.382DoF, Degree of Freedom; NTproBNP, N-terminal pro-brain natriuretic peptide; NYHA, the New York Heart Association; ACE-ARB, Angiotensin-Converting Enzyme Inhibitor or Angiotensin Receptor Blocker; LP, Low-polypharmacy (< 5 medications); HP, high-polypharmacy (≥ 5 medications)*Significant at P < 0.05 Table 2Comparisons of survivals between patient groups adjusted for the study covariates. For continuous variables, median values were used for groupingGroupSurvivalLog-rank testχ2DoF P Age (year) ≤700.580721.01< 0.001* >700.269NTproBNP (pg/mL) ≤15340.593595.01< 0.001* >15340.291NYHA 10.747327.03< 0.001* 20.440 30.264 40.172Duration (month) ≤15.50.45832.21< 0.001* >15.50.344Sacubitril-Valsartan Not prescribed0.37648.91< 0.001* Prescribed0.670 β-blocker (%) Not prescribed0.25459.01< 0.001* Prescribed0.419ACEI-ARB (%) Not prescribed0.246107.01< 0.001* Prescribed0.432Polypharmacy LP0.44441.51< 0.001* HP0.382DoF, Degree of Freedom; NTproBNP, N-terminal pro-brain natriuretic peptide; NYHA, the New York Heart Association; ACE-ARB, Angiotensin-Converting Enzyme Inhibitor or Angiotensin Receptor Blocker; LP, Low-polypharmacy (< 5 medications); HP, high-polypharmacy (≥ 5 medications)*Significant at P < 0.05 Comparisons of survivals between patient groups adjusted for the study covariates. For continuous variables, median values were used for grouping DoF, Degree of Freedom; NTproBNP, N-terminal pro-brain natriuretic peptide; NYHA, the New York Heart Association; ACE-ARB, Angiotensin-Converting Enzyme Inhibitor or Angiotensin Receptor Blocker; LP, Low-polypharmacy (< 5 medications); HP, high-polypharmacy (≥ 5 medications) *Significant at P < 0.05 Discussion We investigated the prognostic implications of polypharmacy in ambulatory patients with HF, hypothesizing that medication counts would affect survival outcomes. Our findings underscore the multifaceted impact of polypharmacy on patient survival and provide insights into the balance between the benefits and risks of polypharmacy in HF management. The Kaplan-Meier survival curves demonstrate progressively lower survival probabilities with increasing numbers of medications. Patients with HP experienced significantly worse survival compared to those with LP, with this disparity emerging early in the follow-up and persisting throughout the study period. The initially improved survival observed among patients with HP likely reflects early pharmacologic benefits from intensive, guideline-directed cardiovascular therapy, followed by a delayed decline related to cumulative medication burden, potential drug interactions, and reduced adherence over time. The random forest Cox model identified age, NT-proBNP levels, NYHA functional class, and heart failure duration as top important predictors of survival. Pharmacological interventions, including sacubitril-valsartan, β-blockers, and ACEI-ARB were also important in reducing mortality risk. The propensity score ranked eighth in importance. Its inclusion in the model, and its position above comorbidities, underscored the impact of the number of medications on survival. While polypharmacy often reflects higher disease complexity, it may also predispose patients to adverse drug interactions and diminished adherence, compounding the risk of poor outcomes. The strong performance of the random forest Cox model reinforces its applicability for individualized survival predictions, highlighting its potential to guide risk stratification and targeted interventions in clinical practice. Our results align with the findings from Minamisawa et al. [22]. They evaluated patients with preserved ejection fraction HF and found that hyper-polypharmacy (≥ 10 medications) was significantly associated with increased hospitalizations and adverse cardiovascular events. Similarly, a study by Wu et al. emphasized that patients categorized under HP and super-HP experienced higher risks of HF readmission, though mortality outcomes varied depending on the comorbidity burden [23]. Fujita et al. also noted that polypharmacy was independently associated with HF re-hospitalization, underscoring the need for personalized medication strategies [24]. The increased adverse events associated with polypharmacy in our cohort are also supported by the work of Li et al. who analyzed elderly HF patients and identified high rates of potentially inappropriate medications as a major contributor to hospital readmissions and mortality [25]. Their findings highlight the critical need for revising the prescription of medications in this population. Complementing these observations, a study identified significant drug-drug interactions in polypharmacy patients with cardiovascular disease, which may account for the lower survival observed in our high-polypharmacy group [26]. Our Cox model, identified NT-proBNP, age, and NYHA class, sacubitril-valsartan, ACE inhibitors, and β-blockers as important predictors of survival. Salah et al. developed a discharge risk model for patients with acute decompensated heart failure that incorporated NT-proBNP levels. Their model improved the prediction of mortality and cardiovascular rehospitalization when combined with other risk factors [27]. Also, polypharmacy has been reported to be associated with increased all-cause mortality among patients with HF following hospitalization, while prescription of ACE inhibitors and β-blockers has been associated with reduced mortality [28]. Meanwhile, existing evidence supports prioritizing therapies in patients with HF and comorbidities [29]. As it was emphasized by Díez-Manglano et al., excessive polypharmacy remains a double-edged sword, particularly in polypathological patients, where medication burden often correlates with worse outcomes [30]. They did not find statistical differences concerning the probability of one-year survival between patients with no polypharmacy, with simple polypharmacy, and with excessive polypharmacy. This may be compatible with our observations within the first few years of follow-up when polypharmacy was not associated with the worst outcome. The impact of polypharmacy on patient outcomes has been also documented across various non-cardiac populations, including elderly patients and surgical settings, where it is linked to increased mortality and complications. For instance, McIsaac et al. found that polypharmacy independently heightened the risk of adverse outcomes in older adults undergoing elective non-cardiac surgery, emphasizing the need for individualized strategies to mitigate its risks, similar to tailored approaches in heart failure management [31]. In a recent clinical consensus study, Stolfo et al. highlighted the growing challenge of polypharmacy in heart failure care, particularly among older and multimorbid patients [32]. The study emphasized that polypharmacy can impair treatment adherence, increase adverse drug reactions, and worsen patient outcomes. To address this, the authors proposed a pragmatic, multidisciplinary approach focused on preserving essential therapies, minimizing drug-related risks, and improving overall management strategies in heart failure. This demonstrates that our conclusions are broadly consistent with expert opinion. Overall, these findings highlight the importance of balancing polypharmacy’s benefits and risks through precision medicine approaches and deprescribing strategies. Differences among study results concerning the effects of polypharmacy on heart failure prognosis can arise due to variations in study designs, populations, and definitions of polypharmacy, as well as differences in the types and combinations of medications analyzed. Additionally, patient-specific factors such as age, comorbidities, and medication adherence lead to variability in findings. Some studies examining the effects of prognostic factors in patients with HF undergoing polypharmacy used Cox regression models but did not report whether they had tested key assumptions such as proportional hazards, linearity, or independence. This can raise concerns about the robustness of some conclusions. Testing assumptions like proportionality, linearity, and independence is essential to ensure that the Cox model appropriately reflects the relationships and dynamics within the data providing more credible and interpretable findings. Our use of the random forest Cox model is advantageous as it relaxes traditional assumptions, allowing for the identification of complex, non-linear interactions among prognostic factors while ensuring high predictive accuracy. Clinical implications Clinicians should be mindful of the risks associated with polypharmacy, including potential drug interactions and adverse effects, especially in older patients or those with multiple comorbidities. While HP may not inherently improve long-term survival outcomes, it should only be prescribed when clinically justified. A patient-centered, evidence-based approach to medication management is essential, prioritizing therapies with proven efficacy (e.g., sacubitril/valsartan and β-blockers) and minimizing those with marginal benefits. Clinical decision-making should also consider factors such as age, NT-proBNP levels, NYHA functional class, and heart failure duration, all of which play a critical role in tailoring treatment regimens. This study underscores the need for revising prescription strategies, especially for patients on ≥ 7 medications to reduce adverse outcomes. Risk stratification plays a crucial role in the prevention and management of cardiovascular disease [33]. Incorporating machine learning-based survival predictors further highlights the value of individualized risk stratification in optimizing therapeutic decisions. By integrating these insights, the clinician can enhance medication management and ultimately improve survival outcomes, particularly in elderly patients with complex heart failure profiles. Limitations While using a large dataset of ambulatory HF patients, this study has limitations that warrant consideration when generalizing the results to broader populations. The retrospective design might not fully capture all relevant clinical and pharmacological variables. The study cohort, derived from a single HF clinic, may not entirely represent the diversity of patients managed in other settings, including those in primary care or less specialized facilities. The relatively small number of patients prescribed sacubitril–valsartan reflects the study’s inclusion period, when the drug had recently become available. While its prognostic importance was evident in the model, this limited representation may reduce the precision of related estimates. Overall, the availability of new medications, administration of non-cardiovascular medications, evolving clinical guidelines, and potential changes in patients’ lifestyle behaviors during the study period may have influenced treatment patterns and outcomes, which could not be fully accounted for in our analysis. In addition, medication adherence data were not available in the dataset. To exactly quantify the interactions and roles of an extended list of comorbidities, medications, and covariates (e.g., the large number of lifestyle components, nutritional evaluations, and physical activities beyond NYHA classification), a large number of patients would be required. Despite these constraints, the use of propensity score adjustment and advanced machine learning models may improve the validity of the findings. Future large prospective studies across diverse healthcare settings and patient populations are necessary to further elucidate the intricate relationship between polypharmacy and survival in heart failure. Conclusion This study highlights the complex interplay between polypharmacy and survival outcomes in ambulatory patients with HF. Using advanced survival modeling, we demonstrated that patients with HP (≥ 5 medications) exhibit significantly worse survival probabilities compared to those with LP, with the greatest risk observed in patients prescribed ≥ 7 medications. Key predictors of survival, including age, NT-proBNP, NYHA functional class, and heart failure duration, were identified as pivotal contributors to cardiovascular outcomes, alongside the protective roles of sacubitril-valsartan, β-blockers, and ACEI-ARB. These findings underscore the importance of personalized medication management, routine pharmacologic evaluations, and judicious prescribing practices to optimize patient care. Future research should focus on developing targeted intervention strategies to balance the therapeutic benefits and risks of polypharmacy in heart failure management.