Editor’s introduction
SHAP analysis identified key predictors including age, marital relationship quality, prenatal depressive symptoms, income, and sleep disturbance. A four-predictor web calculator was created to support clinical use. However, the external validation cohort had limited positive cases and was drawn from a single regional healthcare context in China, which may limit generalizability. These limitations suggest the model requires further prospective validation before routine clinical use.
Introduction
Postpartum depression (PPD) is one of the most prevalent psychiatric disorders during the perinatal period and is characterized by persistent low mood, anhedonia, and diminished interest in daily activities. A large-scale meta-analysis involving 296,284 postpartum women across 56 countries reported a pooled global prevalence of 17.7%, with rates reaching approximately 38% in some regions (–). Recent social stressors, including the COVID-19 pandemic, may have further increased this burden. The adverse consequences of PPD affect both mothers and their offspring. In mothers, PPD is associated with an increased risk of self-harm and suicidal ideation and, in severe cases, infanticide (–). In offspring, maternal PPD has been associated with increased vulnerability to psychiatric disorders and delayed cognitive development later in life (–). PPD therefore represents an important global public health concern, with substantial consequences for individual health, family well-being, and healthcare systems. Developing practical risk prediction tools to identify women at elevated risk may facilitate timely assessment and targeted management.
Machine learning (ML) provides flexible approaches for integrating multidimensional and potentially complex data and has increasingly been applied to clinical prediction research. Previous studies suggest that postpartum depressive symptoms are associated with a range of demographic, physiological, psychological, social, and obstetric factors (–). Integrating these multidimensional predictors may therefore facilitate individualized risk estimation and early screening. Although several ML-based prediction models for PPD have shown promising performance, important limitations remain. Some studies have relied on limited feature selection or modeling strategies, while others have lacked independent external validation, limiting assessment of model transportability across populations and clinical settings. In addition, relatively few studies have translated prediction models into accessible tools for individualized risk estimation.
Data collection and predictor definitions
Informed by previous literature, candidate predictors were collected across demographic, obstetric, neonatal, and psychosocial domains. To clarify the temporal relationship between predictors and the outcome, all candidate predictors were available before the 6-week postpartum outcome assessment. Demographic variables, including age, years of education, and monthly personal income, were obtained using structured questionnaires at enrollment during delivery hospitalization. Obstetric and neonatal variables, including gravidity, parity, gestational age, mode of delivery, infant feeding method, neonatal health status, gestational hypertension, and gestational diabetes mellitus, were extracted from electronic medical records before or at postpartum discharge. Consistent with established approaches in perinatal prediction studies, psychosocial predictors were assessed using structured self-report questionnaire items during hospitalization or postpartum follow-up before the outcome assessment. Prenatal depressive symptoms were defined as self-reported depressive symptoms during pregnancy and coded as present or absent. Postpartum negative life events were defined as self-reported negative or stressful life events occurring after delivery and before the 6-week postpartum assessment and coded as yes or no. Sleep disturbance was defined as self-reported sleep-related problems during the perinatal period and coded as yes or no. Marital relationship quality was assessed according to participants’ self-reported overall marital relationship and categorized as good or poor. Perceived living conditions were evaluated based on satisfaction with the current living environment and categorized as satisfied or dissatisfied. These psychosocial variables were used as candidate predictors rather than diagnostic measures, and no variables measured after the outcome assessment were used for model development.
Outcome definition
The primary outcome was screening-positive postpartum depressive symptoms assessed at 6 weeks postpartum using the Chinese version of the Edinburgh Postnatal Depression Scale (EPDS). The EPDS consists of 10 items, each scored from 0 to 3, yielding a total score ranging from 0 to 30, with higher scores indicating more severe depressive symptoms. In this study, an EPDS score ≥9 was used to define a positive screen for postpartum depressive symptoms. This threshold was selected to prioritize early risk identification and reduce missed cases in the context of postpartum screening, consistent with previous studies that applied this threshold for early postpartum screening. Because no structured clinical psychiatric interview was conducted, an EPDS score ≥9 should be interpreted as indicating screening-positive postpartum depressive symptoms rather than a definitive clinical diagnosis of postpartum depression. For clarity and brevity, participants with EPDS scores ≥9 were classified as the EPDS-positive group, whereas those with EPDS scores <9 were classified as the EPDS-negative group.
Data preprocessing and feature selection
Missingness was assessed for all candidate predictors and the 6-week EPDS outcome. As no missing values were identified among the 553 participants included in the final analysis, no missing-data imputation was performed. All preprocessing procedures were performed after the development cohort had been divided into the training and held-out internal test sets. Continuous variables were standardized using Z-score transformation, binary categorical variables were coded as 0 or 1, and monthly personal income, which comprised three categories, was transformed using one-hot encoding.
Recursive feature elimination (RFE) was used for feature selection by iteratively removing the least informative predictors. Preprocessing and RFE were incorporated into the five-fold stratified cross-validation procedure within the training set. Within each cross-validation iteration, preprocessing parameters and feature selection were fitted using only the training folds and then applied to the corresponding validation fold without refitting. Thus, information from each validation fold was not used to estimate preprocessing parameters or select predictors. After model development, the final preprocessing procedure and predictor set were determined using the full training set and were subsequently applied without refitting to the held-out internal test set and independent external validation cohort.
Machine learning models
Five machine learning algorithms were developed and systematically compared: support vector machine (SVM), logistic regression (LR), random forest (RF), Light Gradient Boosting Machine (LightGBM), and eXtreme Gradient Boosting (XGBoost). SVM identifies a separating hyperplane by maximizing the margin between classes, whereas LR provides an interpretable linear probabilistic model. RF improves predictive robustness by aggregating multiple decision trees constructed from bootstrap samples and randomly selected predictors. LightGBM and XGBoost are gradient-boosting tree algorithms capable of capturing nonlinear relationships and interactions, with LightGBM emphasizing computational efficiency and XGBoost incorporating regularization to reduce overfitting.
After hyperparameter tuning, each model was refitted using the entire training set with the selected hyperparameters. The final model was selected according to its cross-validated performance in the training set and was subsequently evaluated in the held-out internal test set. For comparative purposes, all five candidate models were additionally evaluated in the independent external validation cohort. Neither the held-out internal test set nor the external validation cohort was used for preprocessing parameter estimation, feature selection, hyperparameter tuning, or model selection. The EPDS screening outcome was used only as the supervised learning label and was not included as a predictor.
Statistical analysis
Statistical analyses were conducted using R version 4.4.1 and Python version 3.11.4. The Python-based machine learning workflow included NumPy version 1.23.5, pandas version 2.0.3, SciPy version 1.11.1, and scikit-learn version 1.2.2, with XGBoost version 1.7.4 and LightGBM version 3.3.5 used for gradient-boosting model development. Model interpretation was conducted using SHAP version 0.41.0, and figures were generated using Matplotlib version 3.7.1 and Seaborn version 0.12.2. Categorical variables were presented as frequencies and percentages and compared using the χ² test or Fisher’s exact test. Continuous variables were expressed as mean ± standard deviation or median with interquartile range, depending on distribution, and compared using the Student’s t-test or nonparametric tests as appropriate. All statistical tests were two-sided, and a P-value <0.05 was considered statistically significant. This study was reported in accordance with the Transparent Reporting of a multivariable prediction model for Individual Prognosis Or Diagnosis plus Artificial Intelligence (TRIPOD+AI) reporting guideline.
Principal findings
In this dual-cohort study, we developed and externally validated machine learning models for predicting postpartum depressive symptoms at 6 weeks postpartum. XGBoost was selected for subsequent analyses and achieved AUCs of 0.845 in the internal test set and 0.820 in the external validation cohort. SHAP analysis indicated that age, marital relationship quality, prenatal depressive symptoms, monthly personal income, and sleep disturbance were important model-based contributors. A web-based calculator was developed using a simplified predictor set to support individualized risk estimation. Collectively, these findings provide preliminary external support for the model and suggest potential value for risk stratification in perinatal care, although further validation is required to establish broader generalizability.
Methodological implications
Regarding model development, XGBoost achieved the numerically highest AUC and showed well-balanced performance among the evaluated algorithms. This finding is broadly consistent with previous postpartum depression prediction studies, which have reported AUC values ranging from 0.70 to 0.90. For example, Hochman et al. developed an XGBoost-based model using Israeli electronic health records to predict 1-year postpartum depression, achieving an AUC of 0.712. Similarly, Huang et al. reported favorable performance of XGBoost compared with several other machine learning algorithms. Methodologically, its ability to capture nonlinear relationships and predictor interactions while incorporating regularization may partly explain its performance in multidimensional clinical data. However, the differences among XGBoost, LightGBM, and random forest were small, and no formal pairwise statistical comparisons were performed. Therefore, the selection of XGBoost should be interpreted as reflecting a slight numerical advantage rather than statistically established superiority. Beyond discrimination, calibration was generally acceptable in the internal test set, whereas the negative calibration intercept indicated overestimation of absolute risk in the external validation cohort. This may partly reflect differences in outcome prevalence and population characteristics and suggests that recalibration may be needed when the model is applied to new populations. Decision curve analysis further indicated potential net clinical benefit relative to the treat-all and treat-none strategies across a range of threshold probabilities. Together, these findings support further evaluation of the model for risk stratification while highlighting the need for additional validation and recalibration before broader clinical implementation.
Sample size adequacy and validation rigor are important methodological considerations in prediction model development. In the development cohort, 153 EPDS-positive events were observed among 403 women, and 16 raw candidate predictors were considered before feature selection, providing a reasonable basis for exploratory model development. Nevertheless, one-hot encoding of categorical variables increases the number of input features, thereby increasing model dimensionality, while machine learning models may remain susceptible to overfitting in modest-sized datasets. To reduce this risk, we applied recursive feature elimination, five-fold cross-validation for hyperparameter tuning, and regularized ensemble modeling. Furthermore, the dual-cohort design enabled independent external validation, in which the XGBoost model achieved acceptable discriminative performance with an AUC of 0.820. External validation is recommended to assess model reproducibility and transportability, because performance estimates based only on internal validation may be overly optimistic. The external validation cohort was kept separate from all model development procedures, including feature selection, hyperparameter tuning, model training, model selection, and predictor simplification, thereby minimizing the risk of information leakage and providing a more independent assessment of model performance. However, both cohorts were recruited from the same regional healthcare context in China, and the external validation cohort had a relatively modest sample size with only 39 EPDS-positive events. Therefore, these findings should be interpreted cautiously, and further validation in larger, prospective, multicenter cohorts across diverse regions and healthcare settings is needed to confirm the generalizability of the model.
Clinical implications and model interpretation
SHAP analysis identified age, marital relationship quality, prenatal depressive symptoms, monthly personal income, and sleep disturbance as important contributors to model predictions. Younger age was associated with higher predicted risk within the model, consistent with previous evidence identifying younger maternal age as a relevant predictor of postpartum depressive symptoms. However, elevated risk has also been reported among women older than 35 years, suggesting heterogeneity in age-related associations. Poor marital relationship quality was associated with higher predicted risk, consistent with previous studies linking partner conflict, poor marital adjustment, and insufficient social support with postpartum depressive symptoms. Prenatal depressive symptoms were another major contributor, which may reflect the persistence of depressive trajectories from pregnancy into the postpartum period or increased vulnerability among women with previous or ongoing emotional symptoms. Lower monthly personal income was associated with higher predicted risk, consistent with meta-analytic evidence linking low socioeconomic status to postpartum depression or depressive symptoms. Similarly, sleep disturbance was associated with higher predicted risk, in line with previous studies suggesting potential roles of impaired emotional regulation, serotonergic dysregulation, altered prefrontal control, and inflammatory activation in postpartum depressive symptoms (–). Importantly, these variables should be interpreted as predictors contributing to model output rather than causal determinants of postpartum depressive symptoms. Nevertheless, their clinical accessibility is an important advantage. Most of these predictors can be obtained from routine obstetric records or brief self-report assessments, making them feasible for early screening in perinatal care settings. In clinical practice, the model may help clinicians identify women who warrant closer follow-up, further psychological assessment, or timely referral for mental health support.
To facilitate clinical translation, we developed a web-based calculator based on a simplified predictor set. This tool provides an intuitive interface for individualized risk estimation and may support risk stratification during postpartum follow-up. However, the calculator should be regarded as a screening support tool rather than a diagnostic instrument, and women identified as high risk should receive further evaluation using validated screening scales or structured clinical assessment. Before routine implementation, the calculator requires prospective validation in broader populations and different healthcare settings. If implemented in future clinical settings, its discrimination and calibration should be periodically monitored, with recalibration, model updating and ongoing maintenance performed as needed to maintain reliability and clinical relevance.
Limitations and future directions
Several limitations of this study warrant careful consideration. First, the retrospective design and modest overall sample size may introduce selection bias and restrict causal inference. In addition, the exclusion of participants with substantially incomplete data may have affected the representativeness of the study sample and model performance estimates. Second, although an independent external validation cohort was included, both cohorts were recruited from hospitals within the same regional healthcare context in China, and the external validation cohort contained a limited number of EPDS-positive events. These factors may limit the precision of external performance estimates and restrict the broader generalizability of the model to other regions, healthcare systems, and populations. Third, the outcome was assessed using the self-reported EPDS without confirmation by structured clinical diagnostic interviews. Therefore, the model predicts EPDS-defined postpartum depressive symptoms rather than clinically confirmed postpartum depression. The use of an EPDS cut-off of ≥9 may increase sensitivity for early screening but reduce specificity compared with higher thresholds, which may introduce measurement bias and limit comparability with studies using different EPDS cut-offs. Fourth, reliance on self-reported psychosocial predictors may introduce recall and reporting bias. Additionally, collecting certain postpartum variables close to the 6-week outcome assessment may limit the model’s utility for early prediction during pregnancy or delivery. Moreover, objective biological markers, such as hormonal, inflammatory, or genetic indicators, were not incorporated. Finally, although a web-based calculator was developed, its prospective clinical impact on screening efficiency, clinical decision-making, and patient outcomes has not yet been evaluated. Future multicenter, prospective, and cross-cultural studies with larger and more diverse populations, structured diagnostic assessments, standardized psychosocial instruments, multimodal biological data, clinical impact evaluations, and planned model updating strategies are needed to further validate and improve the model.


