Patients visiting the emergency department (ED) or hospitalized for heart failure (HF) are at increased risk for subsequent adverse outcomes, however effective risk stratification remains challenging. We utilized a machine-learning (ML)-based approach to identify HF patients at risk of adverse outcomes after an ED visit or hospitalization using a large regional administrative healthcare data system. Patients visiting the ED or hospitalized with HF between 2002-2016 in Alberta, Canada were included. Outcomes of interest were 30-day and 1-year HF-related ED visits, HF hospital readmission or all-cause mortality. We applied a feature extraction method using deep feature synthesis from multiple sources of health data and compared performance of a gradient boosting algorithm (CatBoost) with logistic regression modelling. The area under receiver operating characteristic curve (AUC-ROC) was used to assess model performance. We included 50,630 patients with 93,552 HF ED visits/hospitalizations. At 30-day follow-up in the holdout validation cohort, the AUC-ROC for the combined endpoint of HF ED visit, HF hospital readmission or death for the Catboost and logistic regression models was 74.16 (73.18-75.11) versus 62.25 (61.25-63.18), respectively. At 1-year follow-up corresponding values were 76.80 (76.1-77.47) versus 69.52 (68.77-70.26), respectively. AUC-ROC values for the endpoint of all-cause death alone at 30-days and 1-year follow-up were 83.21 (81.83-84.41) versus 69.53 (67.98-71.18), and 85.73 (85.14-86.29) versus 69.40 (68.57-70.26), for the CatBoost and logistic regression models, respectively. ML-based modelling with deep feature synthesis provided superior risk stratification for HF patients at 30-days and 1-year follow-up after an ED visit or hospitalization using data from a large administrative regional healthcare system.