BackgroundThe conversion from a temporary to a permanent stoma (PS) following rectal cancer surgery significantly impacts the quality of life of patients. However, there is currently a lack of practical preoperative tools to predict PS formation. The purpose of this study is to establish a preoperative predictive model for PS using machine learning algorithms to guide clinical practice. MethodsIn this retrospective study, we analyzed clinical data from a total of 655 patients who underwent anterior resection for rectal cancer, with 552 patients from one medical center and 103 from another. Through machine learning algorithms, five predictive models were developed, and each was thoroughly evaluated for predictive performance. The model with superior predictive accuracy underwent additional validation using both an independent testing cohort and the external validation cohort. The Shapley Additive exPlanations (SHAP) approach was employed to elucidate the predictive factors influencing the model, providing an in-depth visual analysis of its decision-making process. ResultsEight variables were selected for the construction of the model. The support vector machine (SVM) model exhibited superior predictive performance in the training set, evidenced by an AUC of 0.854 (95 % CI:0.803–0.904). This performance was corroborated in both the testing set and external validation set, where the model demonstrated an AUC of 0.851 (95%CI:0.748–0.954) and 0.815 (95%CI:0.710–0.919), respectively, indicating its efficacy in identifying the PS. ConclusionsThe model(https://yangsu2023.shinyapps.io/psrisk/) indicated robust predictive performance in identifying PS after anterior resection for rectal cancer, potentially guiding surgeons in the preoperative stratification of patients, thus informing individualized treatment plans and improving patient outcomes.