Objective To analyze influencing factors for spontaneous preterm birth (SPB) in pregnant women based on the clinical data in the second trimester of pregnancy, according to which to build a prediction model. Methods The clinical data of 1,051 pregnant women were retrospectively analyzed, among them, pregnant women who delivered at gestational week <37 were the SPB group, and pregnant women who delivered at gestational week ≥ 37 were the full-term group. The multivariate logistic regression model was used to explore influencing factors for SPB in pregnant women. Pregnant women were randomly divided into the training set and the validation set in a ratio of 7∶3. The decision tree algorithm was used to establish a prediction model for SPB in pregnant women, whose performance was evaluated by the receiver operating characteristic (ROC) curve. Results The results of multivariate analysis showed that the age at the delivery (OR=1.070, 95%CI: 1.001~1.144) and times of pregnancy (OR=1.888, 95%CI: 1.023~3.485), as well as white blood cell count (OR=1.144, 95%CI: 1.026~1.276), neutrophil-to-lymphocyte ratio (NLR) (OR=1.603, 95%CI: 1.152~2.232), fetal fibronectin (fFN) (OR=6.961, 95%CI: 3.740~12.955), and vaginal clearing degree (OR=6.673, 95%CI: 3.661~12.161) in the second trimester of pregnancy, were influencing factors for SPB in pregnant women (all P<0.05). The areas under the ROC curves of the decision tree model in the training set and validation set were 0.796 (95%CI: 0.720~0.871) and 0.786 (95%CI: 0.658~0.913), respectively, and the accuracy rates were 93.99% and 94.83%, respectively. The Delong test results showed that there was no statistically significant difference in the area under the ROC curve between the decision tree models in the training set and the validation set (D=0.126, P=0.786), which indicated that the model had a good prediction performance. Conclusion Age at the delivery and times of pregnancy, as well as white blood cell count, NLR level, fFN, and vaginal clearing degree in the second trimester of pregnancy, are influencing factors for the occurrence of SPB in pregnant women, and the decision tree model based on these factors has a good prediction performance, which can provide a reference for the personalized prediction for the risk of SPB in pregnant women.