Diabetic foot ulcer (DFU) is one of the most serious and alarming diabetic complications, which often leads to high amputation rates in diabetic patients. Machine learning is a part of the field of artificial intelligence, which can automatically learn models from data and better inform clinical decision-making. We aimed to develop an accurate and explainable prediction model to estimate the risk of in-hospital amputation in patients with DFU. A total of 618 hospitalised patients with DFU were included in this study. The patients were divided into non-amputation, minor amputation or major amputation group. Light Gradient Boosting Machine (LightGBM) and 5-fold cross-validation tools were used to construct a multi-class classification model to predict the three outcomes of interest. In addition, we used the SHapley Additive exPlanations (SHAP) algorithm to interpret the predictions of the model. Our area under the receiver-operating-characteristic curve (AUC) demonstrated a 0.90, 0.85 and 0.86 predictive ability for non-amputation, minor amputation and major amputation outcomes, respectively. Taken together, our data demonstrated that the developed explainable machine learning model provided accurate estimates of the amputation rate in patients with DFU during hospitalisation. Besides, the model could inform individualised analyses of the patients’ risk factors.