Heart failure with preserved ejection fraction (HFpEF) comprises over half of heart failure presentations, although the availability of proven treatments is restricted owing to the condition’s considerable clinical variability. The current investigation sought to uncover discrete HFpEF subtypes by applying a machine learning algorithm and to assess how treatment outcomes vary among these phenogroups. Data from 2147 patients admitted with heart failure and left ventricular ejection fraction (LVEF) ≥50% at Peking University Third Hospital between 2014 and 2023 formed the training set. Phenogroups were derived using a two-stage DeepCluster model built around a fully connected neural network, incorporating 107 demographic and clinical variables obtained from electronic medical records (EMR). Associations with prognosis and treatment effects were examined through Cox proportional hazards models. Model robustness was tested internally with leave-one-out cross-validation and externally using the TOPCAT trial dataset (n = 1696) together with a detailed HFpEF cohort from the University of Michigan Health System (UMHS, n = 128). Analysis revealed three clearly differentiated HFpEF phenogroups. Phenogroup 1 (n = 815) was marked by an extensive load of metabolic comorbidities, left ventricular hypertrophy, and abnormalities in both systolic and diastolic performance. Phenogroup 2 (n = 608) primarily involved female patients who had atrial fibrillation and notable structural alterations in the atria and right ventricle, with diastolic dysfunction as the dominant feature. Phenogroup 3 (n = 724) consisted of younger male individuals with detrimental lifestyle patterns, elevated rates of hyperlipidemia and liver dysfunction, yet relatively intact cardiac structure and function. Phenogroup 1 carried the highest overall risk of death from any cause. Standard heart failure medications did not produce clear survival improvements across the whole study population. Within phenogroup 1, however, the post-diagnosis administration of sodium-glucose cotransporter 2 inhibitors (SGLT2i) corresponded to a 55% lower likelihood of HF rehospitalization (HR = 0.45, 95% CI 0.20–0.99). Angiotensin receptor-neprilysin inhibitors (ARNIs) were associated with a 66% decrease in all-cause mortality risk (HR = 0.34, 95% CI 0.14–0.79). The impact of ARNIs on mortality varied meaningfully between phenogroups (p for interaction = 0.048). In phenogroup 2, treatment with calcium channel blockers linked to diminished risks of both all-cause mortality (HR = 0.62, 95% CI 0.38–0.99) and HF rehospitalization (HR = 0.58, 95% CI 0.38–0.88). The DeepCluster model achieved 96.0% consistency on internal validation. External testing in the TOPCAT and UMHS populations confirmed comparable clinical and pathophysiological patterns for each of the three phenogroups. A machine learning algorithm can successfully distinguish HFpEF phenogroups that exhibit unique clinical characteristics and respond differently to therapies. The results highlight potential benefits of SGLT2i and ARNI for individuals burdened by metabolic comorbidities and dual systolic–diastolic dysfunction, and of calcium channel blockers for those with atrial fibrillation. Additional prospective validation of these observations is warranted.