【Abstract】 Objective To compare the prediction effects of risk prediction models, constructed by nomograms, decision trees, and random forests, for complicated pulmonary infection during hospitalization in patients with acute cerebral infarction (ACI). Methods Clinical data of 380 ACI patients treated in the First Affiliated Hospital of Guangxi Medical University from December 2021 to October 2022 were retrospectively analyzed. According to whether they had complicated pulmonary infection during hospitalization, the patients were divided into an infected group (n=97) or an uninfected group (n=283). Univariate analysis and multivariate logistic regression model were used to screen the influencing factors for complicated pulmonary infection during hospitalization in ACI patients. Risk prediction models were constructed by three statistical methods, nomograms, decision trees, and random forests, respectively, and their prediction effects were evaluated by accuracy, sensitivity, specificity, recall, precision, and area under the receiver operating characteristic (ROC) curve (AUC). Results There were statistically significant differences in the smoking history, dysphagia, Glasgow coma scale (GCS) score, and white blood cell count at admission between the infected and uninfected groups (all P<0.05). Results of multivariate logistic regression analysis showed that dysphagia, smoking history, a low GCS score, and a high white blood cell count at admission were independent risk factors for complicated pulmonary infection during hospitalization in ACI patients (all P<0.05). For predicting the risk of complicated pulmonary infection during hospitalization in ACI patients, there was no statistically significant difference in the ROC AUC between the nomogram model and the random forest model [0.898(0.819-0.977) vs 0.908(0.841-0.974)] (P>0.05), but the ROC AUCs of the two abovementioned models were greater than that of the decision tree model [AUC=0.797(0.693-0.901)] (all P<0.05); the accuracy, sensitivity, specificity, recall, and precision of the nomogram model were higher than or equal to those of the others. Conclusion Nomogram and random forest models constructed on four common clinical indexes, including dysphagia, smoking history, GCS score, and white blood cell count at admission, have superior efficacy in predicting the risk of complicated pulmonary infection during hospitalization in ACI patients, and their prediction effects are better than the decision tree model's.