1 Introduction

Since 1990, the prevalence of hypertension has seen a twofold increase, with current estimates indicating that 1.28 billion adults worldwide are affected by this condition [1,2,3]. Established risk factors for hypertension include genetics, diet, and lifestyle [4]. Additionally, emerging evidence suggests a potential role of metal exposure in influencing both the risk and mortality associated with hypertension [5]. Metals can enter the human body through various pathways, including inhalation, dermal contact, and ingestion [6]. Essential elements play a critical role in numerous physiological processes such as immunity, metabolism, and development [7]. However, both deficiencies and excesses of these elements can adversely affect human health [7, 8]. Toxic metals, in particular, can disrupt bodily homeostasis and organ function [9]. A substantial body of epidemiological research has been dedicated to examining the impact of metal exposure on hypertension [10]. Nevertheless, there is a paucity of studies investigating the relationship between heavy metal levels and the increased risk of premature death in individuals with hypertension, underscoring the importance of identifying modifiable risk factors to mitigate adverse health outcomes in this population.

Research on the health effects of metal mixtures has typically focused on isolated exposures, utilizing conventional statistical or machine learning (ML) analyses [5, 9, 11,12,13,14]. This highlights the need for novel analytical methodologies to elucidate the link between heavy metal exposure and mortality among those suffering from hypertension more effectively.

Traditional approaches to disease prediction or mortality risk assessment require stringent data preparation standards [15,16,17]. However, advancements in computer science and the proliferation of data sources pose significant challenges in extracting actionable insights from large datasets [18]. Machine learning, with its capacity to handle less rigorously pre-processed data, offers a promising avenue for exploring vast information landscapes, potentially enhancing hazard identification and health-related decision-making [19].

In our study, we utilized datasets from the National Health and Nutrition Examination Survey (NHANES) for the years 2013–2018, which include specific information on metal exposure not available in other data release cycles. Our aim was to explore the relationship between heavy metal exposure and mortality among individuals with hypertension. We employed five ML models to predict mortality based on heavy metal exposure, assessed the performance of these models, and subsequently applied GA to optimize the performance of the most effective model. Additionally, our study incorporated advanced EMR mining techniques, such as SHapley Additive exPlanation (SHAP) [20] and local interpretable model-agnostic explanations (LIME) [21], to evaluate the contribution of heavy metals to mortality risk, potentially facilitating earlier interventions for hypertension patients.

2 Methods

2.1 Participants

The NHANES study in the United States employed diverse survey methodologies to gather demographic, dietary, clinical examination, laboratory, questionnaire, and mortality data on the US population. This data is accessible on the website of American Centers for Disease Control and Prevention (https://www.cdc.gov/nchs/nhanes). Our analysis includes data from three consecutive NHANES cycles, spanning from 2013 to 2018, augmented by mortality data from 2019.

Inclusion criteria for our study population were: age above 18 years; completion of blood and urine tests for heavy metals; provision of hypertension status in NHANES questionnaire data; and hypertension information derived from the multi-cause mortality data. Exclusion criteria were: participants with over 10% missing data and those with inconsistent information. Our final cohort for follow-up analysis comprised 2347 individuals.

3 Data Collection

3.1 Demographics Characteristics of the Study Participants

The NHANES database provided demographic and other pertinent characteristics of participants, including gender, age (in years at screening), Race/Hispanic origin w/NH Asian, education level (college or above, high school or equivalent, and less than high school), poverty-to-income ratio (PIR) (≤ 1, 1–4, and ≥ 4) [22], and body mass index (BMI, kg/m2).

3.2 Heavy Metals

Our analysis included urinary and blood concentrations of 13 heavy metals, measured at the National Center for Environmental Health using stringent quality control procedures [23].

3.3 Mortality Ascertainment

Mortality status was acquired from the NHANES 2019 Public-use Linked Mortality File (LMF), linked to the National Death Index. Disease-specific mortality was identified according to the International Statistical Classification of Diseases and Related Health Problems, Tenth Revision (ICD-10), with hypertension diagnosed using code I10 since the 2013-2014 data cycle [24].

3.4 Pre-processing of Features

For machine learning applications, with the involvement of medical experts, we selected 22 variables (also known as features in ML field), 19 continuous and 3 categorical. We excluded data with more than 10% missing values. Missing values for continuous variables were imputed with medians, and modes were used for unordered categorical variables [25]. Standard Scaler was utilized for normalizing features, and one-hot encoding was applied to categorical variables. Feature extraction employed principal component analysis (PCA) and select K best (SKB) algorithms [26], discarding variables with minimal model impact to mitigate overfitting.

3.5 Model Establishment

The dataset was partitioned into training and test sets via repeated K-fold cross-validation. We evaluated five machine learning algorithms: deep neural networks (DNN), support vector machine (SVM), Gaussian Naive Bayes (GNB), decision tree (DT), and extreme gradient boosting (XGB), to predict mortality among hypertension patients exposed to heavy metals, each with distinct characteristics and advantages. The DNN method is usually more accurate with simple structure for data training; meanwhile, it also has strong black-box characteristics, that is, it is more difficult for people to understand its discrimination principle [28]. SVM is data-insensitive, but can process nonlinear, multidimensional datasets [29]. GNB performs well on small-scale data, can handle multiple classification tasks, and is suitable for incremental training, but there will be noise and redundancy [30, 31]. Visual analytics are supported by DT, which is easy to comprehend and interpret, but it is susceptible to problems with over-fitting [32]. XGB is a library optimized to increase distributed gradient and designed to be highly efficient, flexible, and portable [33]; however, XGB's model parameters are too many to adjust for the optimal efficiency [34].

After assessing each model's discriminative ability, we selected the most appropriate model for mortality prediction, optimizing parameters using genetic algorithms (GA) [35]. genetic algorithms (GA) are used in our study to optimize model parameters, ensuring the highest possible accuracy and robustness. GA not only explores a wide parameter space but also helps infer the importance of risk factors by optimizing model performance. The SHAP and LIME methods were employed for model interpretation, assessing risk factors for hypertension-associated mortality from 2013 to 2018.

3.6 Statistical Analysis

Continuous variables were summarized as medians (interquartile range), and categorical variables as counts (percentage). Group-specific characteristics were compared using chi-square tests, and heavy metal levels were described using geometric means (standard deviations). Trends over the 6-year period (3 data release cycles) were analyzed with the Mann–Kendall test.

The indicators used for model effectiveness testing included average area under the curve (AAUC) [36] and 95% confidence intervals (95% CI), best area under the curve (BAUC), average precision score (APS), average recall, average f1 score, average accuracy, average brier score loss, average cross-entropy loss, average Jaccard index, and average Cohen’s kappa of each model by repeated K-Fold cross validation.

Analyses were performed using Python 3.9.7, with a significance threshold set at P < 0.05. A schematic overview of our methodology is presented in Fig. 1.

Fig. 1
figure 1

Overview plot

4 Results

4.1 Participants’ Demographics Characteristics

Table 1 presents a summary of the demographic characteristics of the 2347 study participants, all of whom were diagnosed with hypertension. Of these participants, 2003 were alive at the conclusion of the study. The cohort consisted of 1167 men, with an average age of 64.15 years. Deceased participants were more likely to be female, older, have a higher BMI, be of Hispanic ethnicity, possess a higher level of education, and have a lower family income, with all observed differences being statistically significant (P < 0.05).

Table 1 The study participants’ characteristics in NHANES (2013–2020.3)

4.2 Heavy Metals’ Concentrations

Table 2 delineates the concentrations of heavy metals detected in the urine and blood samples across different data release cycles. Significant trends in the concentrations of barium, cadmium, cobalt, cesium, manganese, molybdenum, lead, antimony, tin, thallium, and tungsten in urine, and lead, cadmium, mercury, selenium, and manganese in blood were identified (all Pfor trend < 0.05).

Table 2 Mean values of heavy metal concentration by each NHANES (2013–2020.3) data release cycle

4.3 Models’ Preprocessing

In the process of feature selection, PCA revealed that a minimum of 19 variables were necessary to retain over 95% of the original dataset's information content. Feature scores determined by SKB ranged from 4.23 to 148.73. The top 19 features were selected based on these scores to tailor our ML models. Subsequently, 5 ML algorithms were applied to the NHANES dataset using repeated K-Fold cross-validation for training purposes.

4.4 Models' Performance

The XGB model has the optimal AAUC (AUC 0.943; 95% CI 0.937–0.948), BAUC (1), and APS (0.946) performance which were significantly higher than the AUC values of the other 4 models (P < 0.05). To enhance the AAUC and APS in mortality prediction, parameters were refined using GA, resulting in the GA-XGB model achieving the best performance of AAUC (AUC 0.959; 95% CI 0.953–0.966), and APS (0.996). The best receiver operating characteristic (ROC) curve and precision-recall curve of 6 ML models (including GA-XGB) are shown in Fig. 2. DNN (93.6%), XGB (96.9%), and GA-XGB (96.8%) showed good accuracy when predicting mortality.

Fig. 2
figure 2

The best receiver operating characteristic curve and precision-recall curve for models

4.5 Models’ Comparison

Table 3 shows the performances' comparison of the ML models. The AAUC, BAUC, APS, average recall, average f1 score, average accuracy, average brier score loss, average cross-entropy loss, average Jaccard index, and average Cohen's kappa for all 5 ML models are shown in Table 3. XGB reached the best of the 5 models in 8 of the 10 performance indicators. Typically, the AAUC (AUC 0.943; 95% CI 0.937–0.948), BAUC (1), and APS (0.946) of XGB performed the best of all 5 ML models. The comparison results demonstrate that XGB has the best performance of the five for mortality prediction among hypertension patients. After parameter optimization using GA, the XGB model's effectiveness further improved, as detailed on the right side of Table 3.

Table 3 Comparison of ML models’ performance

4.6 Feature Importance Visualization

SHAP and LIME were used to visualized features' influence on mortality prediction among hypertension patients of the GA-XGB model. The SHAP and LIME summary plot demonstrates the impact of each selected feature of the model to predict hypertension (Fig. 3).

Fig. 3
figure 3

The SHAP and LIME-GA-XGB summary plot

The SHAP value plot on the left side of Fig. 3 globally indicates that cadmium (0.094), cobalt (2.048), lead (1.12), tungsten (0.129) in urine, and lead (2.026), mercury (1.703) in blood positively influence the model, while barium (− 0.001), molybdenum (− 2.066), antimony (− 0.398), tin (− 0.498), thallium (− 2.297) in urine, and selenium (− 0.842), manganese (− 1.193) in urine negatively influence the model. Additionally, the SHAP and LIME summary plot shows that being old, non-Hispanic, having a lower education level, having a higher PIR, and having a higher BMI are related to higher hypertension risk. The SHAP interaction value plot on the upper right side of Fig. 3 demonstrates the interaction between main features. The LIME value plot on the lower right side of Fig. 3 locally indicates the feature importance of single sample discrimination (the 2088th sample). SHAP values illustrate features’ contributions to mortality prediction of the model.

4.7 Prediction Interpretation

The SHAP decision plot, illustrated in Fig. 4, represents individual participant predictions with lines converging at a decision point of 0.968, ordered by feature importance based on the observations plotted. Additionally, the tree plot reveals the optimal discrimination logic, serving as a foundational element of the decision-making process.

Fig. 4
figure 4

The SHAP-GA-XGB decision plot

5 Discussions

In our study, for predicting mortality among hypertension patients in 2013–2018 NHANES data, we developed a ML strategy that can be understood in relation to heavy metal exposure. The GA-XGB model was chosen to predict mortality because it performed the best of the 5 ML algorithms. The GA-XGB model performed well with an average AUC of 0.959, and an accuracy of 0.968. To address the limitations of these algorithms, we integrated the SHAP game theory method with LIME, enhancing the interpretation of model features on both global and local scales through summary and decision plots. Our findings suggest that the SHAP and LIME-GA-XGB model shows promising potential for predicting mortality in hypertension patients exposed to heavy metals.

This research builds upon prior studies that employed ML algorithms for disease prediction [27, 33, 35], underscoring the benefits of advanced classification algorithms in improving prediction accuracy. ML, a branch of artificial intelligence, utilizes mathematical algorithms to identify patterns in diverse data sets, facilitating decision-making processes [18, 37]. However, the complexity of ML algorithms often hampers their understandability, posing challenges to medical decision-making [38].

Our SHAP and LIME-GA-XGB model leverages multi-source NHANES data, including demographics, examinations, laboratory results, and questionnaires, avoiding the need for new data collection efforts. Since 2013, significant attention has been directed towards heavy metal exposure in the United States [39], coinciding with the adoption of the ICD-10 for recording NHANES disease data [40]. We employed extensive data, particularly focusing on the concentration of heavy metals in participants' urine and blood samples. The GA-XGB model demonstrated high efficiency, and among 6 ML algorithms tested, it provided the best performance in terms of classification robustness, aided by strategies such as repeated K-Fold cross-validation to prevent overfitting [41]. SHAP and LIME analyses offered comprehensive interpretability of the GA-XGB model, highlighting the significance of various features in hypertension mortality prediction.

The findings of SHAP were comparable to those of previous studies, which primarily focused on determining how heavy metal exposure affects mortality. Exposure to heavy metals has been linked to increased mortality rates, particularly from cancer and cardiovascular disease [42]. This is a significant concern given the prevalence of heavy metal contamination in drinking water and its potential health impacts [43]. The toxic effects of heavy metals, including oxidative damage and DNA modification, can lead to a range of health issues, from brain damage to cancer [44]. On the positive correlation with mortality, Chen [45] found that higher blood cadmium levels were associated with increased all-cause, cardiovascular, and Alzheimer's disease mortality in these patients. Obeng-Gyasi [46] revealed that the combined effect of lead exposure and chronic physiological stress significantly increased the likelihood of cardiovascular disease mortality. Fardin [47] found that chronic mercury exposure can accelerate the development of hypertension, potentially increasing the risk of cardiovascular diseases. On the negative correlation with mortality, Kuria [48] and Al‐Mubarak [49] found that high selenium levels were associated with a reduced risk of cardiovascular disease (CVD) incidence and mortality. Dietary manganese intake has been associated with a reduced risk of mortality from cardiovascular disease in the Japanese population [50]. The specific impact of other metals’ exposure on mortality among hypertension patients was not directly addressed in previous studies. Further research is needed to explore these potential relationships.

Future research should continue to monitor and analyze key features, aiding experts in drawing informed conclusions rather than relying solely on algorithmic predictions. Expanding the database and incorporating clinician insights could further validate the model's performance [51].

Our study faces several limitations. First, due to computational limits, we were unable to disaggregate other potentially dynamic correlations within the limited data. Secondly, the self-reported nature of hypertension diagnoses in NHANES questionnaire data, despite adherence to ICD-10 standards, may introduce information bias [52]. Third, the strict inclusion criteria for study participants led to significant data missing, potentially introducing bias. Lastly, the complexity of model interpretation may affect the reproducibility of our findings.

6 Conclusions

In our study among US NHANES 2013–2018 participants, the SHAP and LIME-GA-XGB model was found to be an interpretable ML model with high efficiency and robustness that predicts mortality among hypertension patients based on heavy metal exposure. Cadmium, cobalt, lead, tungsten in urine, and mercury in blood positively contribute to mortality among hypertension patients, while barium, molybdenum, antimony, tin, thallium in urine, and lead, selenium, manganese in blood negatively contributes to mortality among hypertension patients.