The aim of this study was to develop a model for early prediction of adverse events and treatment effectiveness in patients with hyperkalemia. We collected clinical data from patients with hyperkalemia in the First Hospital of Zhejiang University School of Medicine between 2015 and 2021. The least absolute shrinkage and selection operator (LASSO) and multivariate logistic regression were used to analyze the predictors on the full dataset. We randomly divided the data into a training group and a validation group, and used LASSO to filter variables in the training set. Six machine learning methods were used to develop the models. The best model was selected based on the area under the curve (AUC). Shapley additive exPlanations (SHAP) values were used to explain the best model. A total of 1074 patients with hyperkalemia were finally enrolled. Diastolic blood pressure (DBP), breathing, oxygen saturation (SPO2), Glasgow coma score (GCS), liver disease, oliguria, blood sodium, international standardized ratio (ISR), and initial blood potassium were the predictors of the occurrence of adverse events; peripheral edema, estimated glomerular filtration rate (eGFR), blood sodium, actual base residual, and initial blood potassium were the predictors of therapeutic effect. Extreme gradient boosting (XGBoost) model achieved the best performance (adverse events: AUC = 0.87; therapeutic effect: AUC = 0.75). A model based on clinical characteristics was developed and validated with good performance.