Introduction

According to the 2021 Global Burden of Disease study, mental disorders ranked among the top 10 leading causes of global health burden [1, 2]. As a highly prevalent mental disorder, depression constitutes a primary cause of global disability and suicide [3, 4]. Core symptoms of depression include mood changes such as sadness, cognitive impairments and somatic complaints, all of which substantially interfere with daily life, study, and work [5]. Understanding the factors contributing to depression is crucial for informing effective policy development and improving service delivery [6]. The pathogenesis of depression is multifaceted, influenced by genetic, environmental factors and behavioral factors [4, 7]. Although genetic factors account for approximately 30–40% of the risk, identifying modifiable environmental contributors remains pivotal for preventive strategies [8,9,10,11].

Environmental chemical exposures (ECMs) encompass various chemicals and compounds we encounter daily. The impact of these substances on health can range from benign to severely detrimental, even in minute quantities may also cause serious harm [11, 12]. Human exposure to ECMs occurs via multiple pathways, including dermal absorption, oral intake, and inhalation of contaminated air [13]. ECMs exhibit environmental persistence and bioaccumulative potential, facilitating their deposition in human tissues and contributing to chronic health outcomes, including cardiopulmonary impairments and neuropsychiatric disorders [8, 14, 15]. Potential biological mechanisms linking ECMs to depression include neurotoxicity, endocrine disruption, and increased oxidative stress pathways [16, 17]. Recent studies have shown that ECMs are associated with depression. For example, lead exposure has been associated with increased risks of depressive symptoms [18]. Cadmium exposure correlates with a higher prevalence of depressive symptoms and anxiety [19, 20]. Mercury, known for its neurotoxic effects, has been implicated in the development of mood disorders and depression [21,22,23]. Additionally, per- and polyfluoroalkyl substances (PFAS) have also been associated with depression [24, 25]. However, existing epidemiological research predominantly investigates single chemical exposures, inadequately capturing the cumulative and interactive effects inherent in real-world environmental scenarios [26]. Studies exploring prenatal exposure to nonpersistent chemicals suggest complex interactions between chemical mixtures and maternal mental health outcomes, including postpartum depression [27, 28]. The high dimensionality, complex co-exposure patterns, and potential nonlinearity in chemical exposure data pose significant analytical challenges to traditional epidemiological methodologies.

Machine learning (ML), driven by advancements in computational capabilities and growing availability of exposomic datasets, is increasingly recognized as a powerful analytical approach to address these methodological limitations [29]. ML techniques effectively handle the complexities inherent to high-dimensional, nonlinear, and intercorrelated exposure data, demonstrating robust predictive power across diverse toxicological endpoints [30]. For example, support vector machines have successfully classified neurotoxic potentials among structurally diverse solvents, probabilistic classifiers have accurately inferred neurotoxicity from broad chemical classes, and gradient boosting frameworks have efficiently screened previously uncharacterized environmental chemicals for neurotoxic risks [31,32,33]. Despite these advances, ML applications in environmental health have largely focused on neurotoxicology and have rarely been applied to complex psychiatric outcomes such as depression [34]. Furthermore, most current models consider chemicals individually, neglecting interactive or cumulative effects common in environmental mixtures [35]. Additionally, interpretable ML methods, like Shapley Additive Explanations (SHAP), improve model transparency, making results more accessible and actionable for clinical and public health applications [36]. These gaps highlight an urgent need for the development of interpretable, mixture-aware ML frameworks tailored to population-level environmental health data. Such advanced models will enhance the reliability of depression risk assessments, facilitate early detection of environmental determinants, and support evidence-based preventive strategies, thereby significantly advancing public mental health outcomes.

In this study, we used data from NHANES 2011–2016 to develop an interpretable machine learning framework predicting depression risk from ECMs. We effectively identified critical ECMs related to depression. Multiple ML algorithms, including neural networks and traditional models, were evaluated for predictive accuracy and interpretability. Using SHAP, the models clarified individual and interactive ECM contributions. Our findings provide actionable insights into public health interventions targeting environmental risk factors for depression.

Materials and methods

A brief study design is depicted in Fig. 1. The detailed methods are described below.

Fig. 1: The main workflow and key findings.
figure 1

A The cross-sectional data of NHANES 2011–2016 adults. The data covers demographics, questionnaires, laboratory results, and physical exams, covering 1333 participants. Participants were divided into two groups based on PHQ-9 scores: those with scores ≥10 were classified as depressed (N = 126), and those with scores <10 as non-depressed (N = 1207); (B) Data Pre-processing, Generation and Model Analysis. Data was pre-processed and split into training (80%) and validation (20%) sets, with Recursive Feature Elimination (RFE) used to identify significant features from the ECM dataset. Various machine learning models, such as Random Forest (RF), Support Vector Machine (SVM), k-Nearest Neighbors (KNN), AdaBoost, and Multi-Layer Perceptron (MLP), etc., were trained and validated. C Explaining Machine Learning Models: Interpreting SHAP Analyses. SHAP values were applied to interpret the models. The analysis clarified the importance of each feature and its impact on predictions. Additionally, mediation and partial correlation network analyses examined pathways linking ECMs to depression.

Participants of the study

The National Health and Nutrition Examination Survey (NHANES) was approved by the National Center for Health Statistics Institutional Review Board, and all participants provided written informed consent. This research adheres to the Strengthening the Reporting of Observational Studies in Epidemiology (STROBE) guidelines [37, 38]. Our study initially considered a combined sample of approximately 15,000 participants from three consecutive NHANES cycles (2011–2016), with each cycle collecting data for about 5000 individuals annually. The inclusion criteria required participants to be aged ≥18 and to have complete Patient Health Questionnaire-9 (PHQ-9) status information for depression diagnosis confirmation [39]; Exclusion criteria included participants missing ECM data for more than two consecutive years or with substantial missing data across ECM measurements, reducing the effective sample size. Additionally, for variables with values below the limits of detection (LOD), participants were included if data were available after appropriate NHANES corrections. Ultimately, 1333 participants meeting these criteria were included in the final analysis (Fig. 1, Figure S1, Supplementary Table 1).

Measurement of ECMs and outcomes

In this study, we focused on five categories of environmental chemicals: polycyclic aromatic hydrocarbons (PAHs), metals, per- and polyfluoroalkyl substances (PFAS), phthalate esters (PAEs), and phenols, as potential determinants of depression. Although NHANES assesses over 300 environmental chemicals, not all were consistently measured across all cycles. To minimize missing data and improve the robustness of our analysis, we selected chemicals from the 2011–2016 cycles with more complete exposure data in these categories. This limitation excluded other potentially relevant chemicals, such as pesticides, due to insufficient data coverage. Some of the analyzed compounds had values below the limits of detection (LOD) according to the U.S. CDC reports on human environmental chemical exposures (https://www.cdc.gov/exposurereport/pdf/FourthReport_UpdatedTables_Volume1_Jan2019-508.pdf) [40]. Urinary creatinine levels were used for dilution correction, and ECM concentrations were naturally logarithm-transformed to achieve normality [41].

Depression was assessed using the Patient Health Questionnaire-9 (PHQ-9), a standardized and validated tool included in the NHANES dataset for mental health assessment. The PHQ-9 consists of nine items that measure the frequency of depressive symptoms over the past two weeks, with each item scored from 0 (not at all) to 3 (nearly every day). Total scores range from 0–27, with higher scores indicating more severe depressive symptoms. For this study, we followed established PHQ-9 thresholds, defining a score of 10 or above as indicative of moderate to severe depressive symptoms, which is widely used as a cutoff for depression diagnosis in epidemiological studies [39]. This approach allowed us to classify participants as depressed or non-depressed based on clinically relevant criteria, enhancing the outcome’s reliability and relevance for evaluating associations with environmental chemical exposures.

Abnormal values and missing data

Abnormal values were adjusted using the Winsor2 command in the R software, which sets a threshold between the first and ninety-ninth percentiles to readjust other outliers. There were no missing outcome variables. Covariates with less than 20% missing data were imputed using the k-nearest neighbors (KNN) method, while those with more than 20% missing values were excluded.

Feature selection with recursive feature elimination

To optimize feature selection for our machine learning models, we used Recursive Feature Elimination (RFE) with a 10-fold cross-validation control function to identify important features for depression risk prediction. Initially, 84 features (52 chemical exposure variables and 32 demographic and clinical covariates) were included in the machine learning models. First, we implemented RFE with the Random Forest (RF) algorithm as the primary model, evaluating feature subset sizes of 5, 10, and 15 using general control functions (caretFuncs). Subsequently, we applied an alternative RFE process using RF-specific controls (rfFuncs) to test feature subset sizes of 6, 8, and 10. The difference between these two approaches is that the RF-specific controls (rfFuncs) are tailored to optimize feature selection specifically for the RF model, potentially enhancing the interpretability and stability of selected features [42]. Model performance was evaluated with Root Mean Square Error (RMSE), R-squared, and Mean Absolute Error (MAE). RMSE was prioritized in model selection to identify feature sets that minimized prediction error. To ensure robustness, RFE was integrated within a bootstrap framework by iterating the feature selection process over multiple bootstrap samples, which helped validate the consistency of selected features and offered insights into the stability of ECM-depression associations across resampled datasets. This integration was achieved by repeatedly applying the RFE steps over resampled datasets, allowing us to confirm the reproducibility of selected features in predicting depression risk [43].

Machine learning for the prediction of depression

Due to the complexity of the underlying mechanisms, it is crucial to explore diverse algorithmic approaches to address the challenge of accurately predicting neurotoxicity. Therefore, we applied nine supervised machine learning algorithms to model depression risk based on chemical exposure profiles. These included neural network (NN), multilayer perceptron (MLP), gradient boosting machine (GBM), AdaBoost, extreme gradient boosting (XGBoost), random forest (RF), decision tree (DT), support vector machine (SVM), and logistic regression (LR). The neural architectures (NN, MLP) are capable of learning complex nonlinear representations [44]. Ensemble methods (GBM, AdaBoost, XGBoost, RF) combine multiple weak learners to enhance generalization and reduce overfitting [45]. DT offers transparent rule-based partitioning, SVM constructs maximum-margin classifiers in high-dimensional spaces, and LR provides a probabilistic linear baseline [46]. This diverse algorithmic selection facilitates robust comparative evaluation across distinct model families. To predict depression risk based on ECM data, we employed a 10-fold cross-validation (CV) approach instead of a single 80–20% train-test split to provide more precise estimates of model performance and reduce variance in the evaluation metrics. The dataset was divided into ten folds, with each fold used as a testing set once while the other nine folds served as the training set, ensuring that all samples contributed to both training and testing. To prevent data leakage and ensure an unbiased model evaluation, the Recursive Feature Elimination (RFE) process was applied exclusively within the training data for each fold, meaning that feature selection was performed anew within each training subset before testing on the corresponding validation fold. This approach avoided including any information from the test set in feature selection, ensuring that the results were not biased by data leakage [47].

Statistical analysis

We utilized R software (version 4.1.3, available at www.r-project.org) for data processing and model evaluation in statistical analyses. Continuous variables were presented as medians and standard deviations, while categorical variables were reported as numbers and percentages. Univariate logistic regression analysis examined the associations between each ECM and depression risk. Each ECM variable was analyzed independently to assess its impact on depression, which was selected based on established relevance in depression studies. To comprehensively and accurately evaluate the performance of the model, we also use a variety of indicators for evaluation, including area under the curve (AUC) with 95% confidence intervals (95% CI), accuracy score, average precision score (APS), precision, sensitivity/recall, specificity, negative predictive value (NPV), false positive rate (FPR), false negative rate (FNR), false discovery rate (FDR), F1 score, and Brier score.

Results

Characteristics of subjects

Among 1333 eligible adults with complete PHQ-9 data, the mean (SD) age was 46.88 (0.92) years, and 695 (50.1%) were female (Table 1). Using NHANES sampling weights, this sample is representative of approximately 19.2 million noninstitutionalized U.S. residents, allowing for population-level inferences. Those with depression were generally older (mean age 47.95 vs. 46.78 years), had a higher BMI (30.80 vs. 28.36), and had lower education levels (36.94vs. 28.71%). Additionally, they had higher rates of being widowed, divorced, or separated (28.14vs. 17.04%) among those with depression.

Table 1 Characteristics of the participants enrolled in this study (US NHANES 2011–2016).

Univariate logistic regression

Univariate logistic regression analysis revealed several significant associations between ECMs and depression. Higher cadmium levels were associated with a more than twofold increase in depression likelihood (OR = 2.41, 95% CI: 1.80-3.23, P < 0.0001). Elevated lead levels also increased depression odds (OR = 1.21, 95% CI: 1.04-1.42, P = 0.02). Conversely, higher mercury levels were associated with lower odds of depression (OR = 0.79, 95% CI: 0.68–0.92, P = 0.004). Benzophenone-3, Triclosan, Ethylparaben, and 1-hydroxypyrene also showed significant associations (all P < 0.05) (Supplementary Table 2).

Recursive feature elimination (RFE)

We applied Recursive Feature Elimination (RFE) to identify the most relevant features for predicting depression. During this process, each variable was evaluated based on its contribution to the model’s predictive performance, measured by Root Mean Square Error (RMSE) and R-squared values. Variables that achieved an RMSE of 0.2874 or lower and an R-squared of 0.01506 or higher were considered for inclusion. After assessing combinations of variables, we selected a final subset of six key features - Total Arsenic, Arsenous Acid, Blood Cadmium, Cesium, 2,5-dichlorophenol, and 1-Hydroxynaphthalene - to balance model performance with interpretability (Table 2).

Table 2 Performance metrics for feature selection using recursive feature elimination (RFE) in predicting depression.

Testing and comparison of ML models’ performance

We evaluated the trained models to identify depression based solely on environmental chemical exposure (ECM) data. The RF model achieved the highest accuracy (0.9800), sensitivity (0.9800), specificity (0.9980), positive predictive value (PPV = 0.9850), and negative predictive value (NPV = 0.9800), demonstrating its robustness in predicting depression within this ECM-focused framework. The KNN and SVM models also performed well, with KNN achieving an accuracy of 0.9151 and SVM an accuracy of 0.9110. The NN model showed moderate performance, while Adaboost and XGBoost had lower accuracies and prediction values, underscoring the potential of the RF, KNN, and SVM models as strong predictors when analyzing ECM data (Fig. 2A).

Fig. 2: Performance comparison of ten machine learning models for predicting depression using environmental chemical exposures (ECMs).
figure 2

A Comprehensive model comparison from nine metrics. B ROC comparison among ten models. ECMs used in the model included total arsenic, arsenous acid, blood cadmium, blood cesium, 2,5-dichlorophenol, and 1-hydroxynaphthalene. The RF model demonstrated the highest predictive accuracy with an AUC of 0.967 and an F1 score of 0.91. SHAP values were used to interpret the models, highlighting the most significant ECMs contributing to depression risk prediction. Abbreviations: ROC receiver operating curve, SVM support vector machine, NN neural networks, MLP multilayer perceptron, LR logistics regression, NB naive bayes, RF random forest, KNN k-nearest neighbor, GBM gradient boosting machine, DP detection precision, SE sensitivity, SP specificity, PPV positive predictive value, NPV negative predictive value, AP apparent prevalence, DR detection rate.

Notably, these results were obtained without including demographic or clinical variables, such as age, marital status, sex, or health conditions, isolating the effect of ECMs on depression risk prediction. To avoid potential bias, model evaluation incorporated cross-validation, ensuring that feature selection and testing were isolated within each fold, thereby preventing data leakage and supporting the reliability of these high accuracy and AUC values. The RF model also achieved the highest area under the curve (AUC = 0.967, 95% CI: 0.939-1.000), followed by KNN (AUC = 0.945, 95% CI: 0.838–0.983) and SVM (AUC = 0.943, 95% CI: 0.841–0.974), while the NN model displayed moderate performance with an AUC of 0.666 (95% CI: 0.619–0.699) (Fig. 2B).

Feature importance and interpretation of personalized predictions

Using SHAP values, we analyzed the impact of specific features on the RF model’s predictions for depression. The most significant features were cadmium (0.016), cesium (0.012), and 2-hydroxyfluorene (0.012). Lead, 2,5-dichlorophenol, and serum total folate also had positive contributions but to a lesser extent, while arsenous acid and 1-hydroxynaphthalene negatively influenced the predictions (Fig. 3A). Additionally, we used restricted cubic splines (RCS) to the SHAP significant features without adjusting for any variables. The RCS results highlighted the nonlinear relationships between these key features and depression risk. For instance, urine cadmium had an increasing effect on depression risk as its levels rose. Similarly, higher cesium levels were associated with an increased risk of depression. The impact of 2-hydroxyfluorene on depression showed a more complex pattern, with risk increasing at moderate exposure levels and stabilizing at higher levels. Serum total folate exhibited a positive correlation with depression risk, while blood mercury, arsenous acid, and mono (carboxypentyl) phthalate also had significant relationships with depression risk (Figure S2). The decision plot shows the contribution of each feature to the model’s final prediction for each participant, with each line representing individual participant data. All lines converge at the model’s base value of 0.959, indicating the predicted outcome before accounting for individual feature contributions (Fig. 3B, Figure S3).

Fig. 3: Feature importance ranked by SHAP and interpretation of personalized predictions of depression risk using SHAP values and equation.
figure 3

AThis panel illustrates the ranking of mean absolute SHAP values for each feature in the model, reflecting their overall importance in predicting depression. B SHAP Summary Plot: This figure shows the distribution of SHAP values for individual predictions, with positive SHAP values (red) indicating an increase in the prediction of depression and negative SHAP values (blue) indicating a decrease. Features with higher SHAP values have a more significant impact on the model’s prediction, demonstrating the cumulative effect of feature contributions on the final output. Personalized depression risk can then be predicted using the following equation: Base value + ∑ (SHAP value feature × feature value). Base Value: The average model output across the entire dataset before accounting for specific feature contributions. Feature Value: The actual measured value of each feature for an individual.

Mediation of association and network of ECMs to depression by internal proteins

A mediation analysis was used to explore the potential mechanisms between depression and the top 15 features of the RF model. This analysis aimed to identify biochemical mediators that might explain associations between ECMs and depression risk. Specifically, fasting plasma glucose (FPG), hemoglobin A1c (HbA1c), alanine aminotransferase (ALT), aspartate aminotransferase (AST), total bilirubin (TBIL), alkaline phosphatase (ALP), total protein (TP), albumin (ALB), globulin (GLB), creatinine (CRE), uric acid (UA), blood urea nitrogen (BUN), triglycerides (TG), total cholesterol (TC), high-density lipoprotein (HDL), low-density lipoprotein (LDL), and lactate dehydrogenase (LDH) were evaluated as potential mediators in these ECM-depression relationships (Fig. 4A, Supplementary Table 3). To further underscore the relationships between ECMs and these mediators, we conducted a regularized partial correlation network analysis on the mediation scores. This network analysis used a regularization method to manage the high dimensionality and intercorrelation of variables, identifying statistically significant correlations and clustering ECMs within the same category. For example, heavy metals such as lead (Pb), cadmium (Cd), and mercury (Hg) clustered together, demonstrating strong positive correlations. These metals also exhibited strong positive correlations with FPG and negative correlations with blood insulin levels, suggesting potential metabolic pathways underlying the ECM-depression association (Fig. 4B).

Fig. 4: Mediation of the associations between environmental chemical exposures (ECMs) and depression by endogenous proteins.
figure 4

A The mediation effects of environmental chemical exposures (ECMs) on depression via various endogenous proteins. The x-axis represents different ECMs, while the y-axis represents the mediation effect, which is quantified as a percentage. Only significant mediation effects with a threshold of P < 0.05 are included. B Mediation network between ECMs and endogenous proteins. The nodes represent ECMs and internal proteins, while the edges (connecting lines) indicate significant mediation pathways. FPG fasting plasma glucose, HbA1c hemoglobin A1c, Alt alanine aminotransferase, AST aspartate aminotransferase, TBIL total bilirubin, ALP alkaline phosphatase, TP total protein, ALB albumin, GLB globulin, CRE creatinine, UA uric acid, BUN blood urea nitrogen, TG triglycerides, TC total cholesterol, HDL high-density lipoprotein, LDL low-density lipoprotein, LDH lactate dehydrogenase.

Discussion

This study examined the associations between ECMs and depression in US adults from the NHANES (2011–2016). By deploying machine learning (ML) models, including Random Forest (RF), Support Vector Machine (SVM), and others, we identified significant ECMs associated with depression and explored underlying mechanisms. The RF model demonstrated superior predictive performance for depression. SHAP analysis identified cadmium, cesium, and 2-hydroxyfluorene as critical predictors, while mediation analysis indicated that systemic inflammation and oxidative stress pathways play essential roles in the ECM-depression relationship.

The univariate logistic regression analysis revealed associations between specific ECMs and depression. Elevated cadmium levels (OR = 2.41, 95% CI: 1.80–3.23) were strongly correlated with an increased risk of depression, corroborating previous studies that cadmium’s neurotoxic effects and its role in inducing oxidative stress and disrupting neurotransmitter functions [48, 49]. Similarly, higher lead levels (OR = 1.21, 95% CI: 1.04–1.42) were associated with an increased risk of depression. This result is consistent with earlier research on lead’s detrimental cognitive and psychological impacts [22, 50]. Conversely, higher mercury levels (OR = 0.79, 95% CI: 0.68–0.92) were associated with a decreased risk of depression. This finding diverges from some previous research emphasizing mercury’s neurotoxic potential [51,52,53]. The discrepancy may result from variations in study populations, mercury exposure levels, and forms of mercury, such as methylmercury versus inorganic mercury, which have distinct neurotoxic effects [54].

SHAP analysis showed cadmium, cesium, and 2-hydroxyfluorene as the most important features in the RF model’s depression predictions. These findings are consistent with the heavy metals to depressive disorders [49, 55]. Cadmium is known to induce oxidative stress and alter neurotransmitter dynamics, thereby contributing to depressive pathology [8]. Although less studied, cesium and 2-hydroxyfluorene may similarly impact neural pathways and mental health outcomes. The RCS analysis provided nuanced insights into the nonlinear relationships between these key ECMs and depression risk. The dose-response relationship for cadmium indicated an escalating risk of depression with increasing exposure, reflecting its cumulative toxicological impact [56]. Similarly, cesium exposure displayed a progressive risk pattern, while the relationship between 2-hydroxyfluorene and depression exhibited complexity, with risk increasing at moderate levels and stabilizing at higher exposures, necessitating further investigation [57].

Mediation analysis identified systemic inflammation and oxidative stress pathways as significant mediators in the ECM-depression nexus. Key inflammatory biomarkers, such as C-reactive protein (CRP) and interleukin-6 (IL-6), were highlighted, underscoring the pivotal role of inflammatory processes in the pathogenesis of depression [58]. These findings are in line with studies emphasizing the impact of environmental toxins on systemic inflammation and mental health outcomes [59]. The regularized partial correlation network analysis revealed strong intra-category associations among ECMs, particularly between lead, cadmium, and mercury. These elements clustered together and exhibited positive correlations with fasting plasma glucose (FPG) and negative correlations with blood insulin levels, suggesting a synergistic effect on metabolic and psychological health [11]. Previous research supports these findings, indicating that heavy metals can disrupt metabolic processes, which in turn can influence mental health [8, 15]. These findings carry important public health implications. Clarifying ECMs as modifiable risk factors for depression highlights potential targets for preventive interventions. Regulatory measures to limit environmental exposure to identified chemicals—particularly cadmium, lead, and cesium—could effectively mitigate depression incidence. Implementation of community-level screening programs designed to identify individuals at heightened exposure risk, coupled with targeted health education initiatives, could further reduce the population burden of depression linked to these environmental factors [60, 61].

Despite these valuable insights, several limitations warrant consideration. First, the ECMs analyzed here represent only a subset of environmental exposures, highlighting the importance of future studies incorporating broader chemical spectra. Second, the cross-sectional nature of NHANES data precludes definitive conclusions regarding causality between ECMs and depression. Third, the assessment of depression was based on symptom scores rather than clinical diagnosis, which may affect the accuracy of our findings. Additionally, some environmental chemicals were excluded due to detection limits, indicating a need for more sensitive detection methods. Finally, potential confounders, such as genetic predispositions and social factors, may not have been fully accounted for, which could influence the results.

To address these limitations and advance understanding of ECM-depression relationships, future research should prioritize prospective cohort designs capable of establishing causal inferences. Methodological advancements in interpretable machine learning, particularly leveraging Shapley Additive Explanations (SHAP), will be critical for enhancing model transparency and clinical translation. Future studies should also expand their scope to include diverse demographic cohorts and varied environmental contexts, thereby strengthening the external validity and translational relevance of findings, ultimately informing precise and targeted preventive strategies in population mental health.

Conclusions

This study harnessed machine learning to uncover significant associations between multiple environmental chemical exposures and depression, with the random forest model outperforming others. Interpretable machine learning using SHAP further identified cadmium, cesium, and 2-hydroxyfluorene as the top risk factors for depression. Mediation analysis illuminated systemic inflammation and oxidative stress as pivotal pathways linking ECMs to depression. Our work underscores the potential of machine learning to inform environmental health policy and intervention. The findings call for public health strategies to mitigate exposure to these chemicals and highlight the need for further research into their mechanistic roles in depression.