Abstract Background Abnormal serum potassium levels are associated with an increased risk of mortality in patients with myocardial infarction (MI); however, it is unclear whether the impact of potassium levels on mortality risk varies depending on the characteristics of MI patients. Purpose We aimed to classify MI patients according to their clinical characteristics and explore the relationship between potassium levels and in-hospital mortality in distinct clusters of MI. Methods Using Medical Information Mart for Intensive Care (MIMIC) IV database, we identified 3,159 patients who admitted for the first time to the intensive care unit with a primary diagnosis of acute MI. Machine learning clustering was performed on this population based on available clinical and laboratory data. Results Three distinct clusters of MI patients were identified using clustering analysis: 1,455 (46%) in cluster 1, 587 (19%) in cluster 2, and 1,117 (35%) in cluster 3. Patients in cluster 2 were older, had the highest comorbidity burden, Sequential Organ Failure Assessment (SOFA) score, peak lactate, creatinine, peak troponin, N-terminal B-type natriuretic peptide (NT-proBNP) levels and the lowest hemoglobin levels among the 3 clusters. Patients in cluster 3 were younger, had the lowest comorbidity burden, SOFA score, peak lactate, creatinine, NT-proBNP levels. Patients belonging to cluster 1 had clinical characteristics intermediate to those of cluster 2 and 3, except for the lowest troponin level. In-hospital mortality was highest in cluster 2, followed by cluster 1 and then cluster 3. Patients in cluster 2 had the highest in-hospital mortality risk with hypokalemia (OR 3.71, 95% 1.81-7.63) and patients in cluster 3 had highest in-hospital mortality risk with hyperkalemia (OR 2.77, 95% CI 0.84-9.06). Patients in cluster 1 did not exhibit a linearly increasing mortality with hyperkalemia. Conclusions The use of clustering analysis in patients with acute MI could characterize baseline clinical data into clinically distinct clusters with different in-hospital mortality across the dyskalemia continuum. The results suggest that the optimal range of potassium levels in patients with MI may vary depending on patient characteristics.Figure - clusteringTable - K and In-hospital mortality