Objective The primary objective of this study was to develop and evaluate a machine learning (ML) model for predicting preterm birth (PTB) and spontaneous preterm birth (SPTB) using biopsychosocial data. Design Secondary analysis of a cohort data. Sample Data from a prospective longitudinal pregnancy cohort, All Our Families, were used in the current study. Pregnant individuals prior to 25 weeks gestation with a medically low-risk pregnancy were eligible for recruitment. Methods ML classification models were trained to predict both SPTB and PTB using a total of 52 input features. Main Outcome Measures Machine learning model accuracy and the features selected. Results Moderate accuracies were achieved by the PTB (ROC-AUC = 0.62±0.03) and SPTB models (ROC-AUC = 0.57±0.05). For PTB, the most informative variables were a diagnosis of hypertensive disorder of pregnancy (HDP), feelings towards pregnancy, use of fertility treatment, satisfaction with social support, and exercise. For SPTB, the top predictive factors were use of fertility treatment, feelings towards pregnancy, diagnosis of HDP, household income, and satisfaction with social support. Conclusions The current study sets the stage for further research to use ML models to predict perinatal outcomes and examine novel and potentially modifiable biopsychosocial factors contributing to the overall risk of PTB.