Abstract
BACKGROUND: Depressive symptoms are highly prevalent in individuals with obsessive-compulsive disorder (OCD) and substantially complicate clinical management. However, the feature structure associated with depressive symptoms in OCD remains insufficiently characterized, particularly from an integrative, multivariate perspective. This study aimed to identify key features associated with depressive symptoms in OCD and to elucidate their interrelationships using machine learning and network analysis. METHODS: A multicenter sample of 1,293 patients with OCD was recruited from 15 specialized OCD clinics across China. An extreme gradient boosting (XGBoost) model was developed to predict depressive symptoms, with hyperparameter optimization conducted using Optuna and feature contributions quantified via SHAP values. Multivariable logistic regression was used to examine independent associations, and network analysis was applied to explore the co-occurrence structure among key features. RESULTS: The XGBoost model identified anxiety, psychosocial functioning, mental state, obsessing, functional impairment, perceived stress, and gender as the most informative features associated with depressive symptoms in OCD. SHAP analyses indicated that higher anxiety levels, poorer psychosocial functioning, and a more negative self-rated mental state contributed most strongly to increased predicted risk. Network analysis further demonstrated that anxiety, mental state, obsessing, and psychosocial functioning occupied central positions within the network. Anxiety showed prominent bridging properties, exhibiting strong associations with obsessing, perceived stress, and mental state, suggesting its integrative role across emotional, cognitive, and functional domains. CONCLUSIONS: Depressive symptoms in OCD are embedded within a tightly interconnected configuration of emotional, cognitive, and functional features, with anxiety occupying a central and bridging position across analytical approaches. The combined application of machine learning and network analysis provides a complementary framework for identifying salient features and elucidating their interrelationships in OCD patients with depressive symptoms, with potential implications for clinical assessment and targeted intervention. SUPPLEMENTARY INFORMATION: The online version contains supplementary material available at 10.1186/s12888-026-07854-z.