ABSTRACT
Introduction
Accurate prediction of liver disease is vital for early intervention, given its potential severity. This study aims to improve the prediction of advanced liver fibrosis and investigate its associations with factors, ultimately contributing to healthier lifestyle choices and timely management of liver disease.
Methods
This cross‐sectional study included adults from the US National Health and Nutrition Examination Survey (2017–2020). Questionnaires captured demographic, dietary, exercise, and mental health information. Advanced fibrosis was defined using liver stiffness measurement (LSM) with a 9.5 kPa threshold. XGBoost, a machine learning model, predicted fibrosis, assessed using AUROC. SHAP provided visual explanations of the model's predictions and feature contributions. Model gain, cover, and frequency measured feature importance, enabling transparent, and interpretable analysis.
Results
There were 6979 adults (age > 18) that were included in the study with an average age of 49.02 and 3523 (50%) female. The machine learning model had an area under the receiver operator curve of 0.885. The top eight covariates include waist circumference (gain = 0.185), GGT (gain = 0.101), platelet count (gain = 0.059), AST (gain = 0.057), weight (gain = 0.049), HDL‐cholesterol (gain = 0.032), and ferritin (gain = 0.034).
Conclusion
In conclusion, the utilization of machine learning models proves to be highly effective in accurately predicting the risk of liver fibrosis. By considering various factors such as demographic information, laboratory results, physical examination findings, and lifestyle factors, these models successfully identify crucial risk factors associated with liver fibrosis.
Keywords: machine learning, NHANES, Shapley additive explanations, XGBoost
Abbreviations
- NCHS
National Center for Health Statistics
- NHANES
National Health and Nutrition Examination Surveys
- SHAP
Shapley additive explanations
1. Introduction
Effective therapies to prevent or delay the progression of cirrhosis toward decompensation are currently lacking. Ideally, the focus would be on early identification and treating the underlying liver disease to halt the development of cirrhosis. However, once a patient's liver has reached the cirrhotic stage, they remain at a significantly elevated risk of decompensation. The lifetime risk of experiencing ascites is approximately 50%, and for hepatic encephalopathy, it is around 40%. This has sparked considerable interest in discovering factors that lead to cirrhosis [1, 2].
Metabolic dysfunction‐associated steatotic liver disease (MASLD) affects over 80 million individuals of the US population and is a leading cause of liver‐related morbidity and mortality. Advanced fibrosis in MASLD patients poses the greatest long‐term risks [3]. The incidence of liver fibrosis continues to rise due to changes in dietary habits, lifestyle factors, and overall health, leading to substantial socioeconomic burdens. MASLD encompasses various stages, including simple liver steatosis, MASLD cirrhosis, and hepatocellular carcinoma (HCC). The development of MASLD involves multiple pathophysiological stressors from lipotoxicity, inflammatory markers, oxidation, the microbiota, and insults to the gut–liver axis [4].
To aid in our understanding of the development of liver fibrosis, machine learning can be employed to identify factors that are associated with the progression. In this study, we use the National Health and Nutrition Examination Surveys (NHANES), a robust sample, to assess liver fibrosis as measured by liver elastography. By employing XGBoost, which has strong backing from medical literature supporting it as a predictive machine learning model and a transparent machine learning process by the name of Shapley additive explanations (SHAP), our findings will identify hidden patterns and relationships that may not be evident through traditional statistical methods and provide valuable insights into the risk factors for advanced fibrosis [5].
2. Methods
The authors utilized information from the publicly accessible NHANES to conduct a cross‐sectional cohort study involving participants who completed a comprehensive questionnaire encompassing demographic details, dietary patterns, exercise routines, mental health, as well as undergoing laboratory tests and physical examinations. The data collection and analysis of this study were authorized by the Ethics Review Board of the National Center for Health Statistics (NCHS). To protect the privacy and anonymity of the participants, all data, including medical records, survey responses, and demographic information, were de‐identified before analysis. Moreover, prior to the commencement of the study, written consent was obtained from all participants, granting permission to share their data publicly.
2.1. Dataset and Cohort Selection
The NHANES 2017–2020 was developed by the NCHS to evaluate the health and nutritional status of the American population. The Centers for Disease Control and Prevention (CDC) conducted a comprehensive series of cross‐sectional, multistage surveys to collect data on health, nutrition, and physical activity for the NHANES dataset. Our investigation focused on adult participants (aged 18 and above) in the NHANES dataset who completed demographic, dietary, exercise, and mental health questionnaires, as well as underwent physical and laboratory examinations. This sample was selected to represent the national population of the United States.
2.2. Assessment of Liver Fibrosis
The utilization of liver elastography, specifically the FibroScan technique, has demonstrated promising potential in the diagnosis of liver fibrosis. By employing a noninvasive approach, FibroScan utilizes mechanical vibration and ultrasound technology to measure liver stiffness, providing a reliable quantitative assessment of fibrosis burden. Numerous studies have compared FibroScan to liver biopsy, the gold standard for fibrosis diagnosis, and have reported high accuracy and diagnostic performance [6]. Systematic reviews have shown an average area under the receiver operating characteristic (ROC) curve of 0.89, indicating a strong ability to distinguish severe liver fibrosis [7]. Sensitivity and specificity values have been reported as 82% and 86%, respectively, further highlighting the effectiveness of FibroScan in identifying advanced fibrosis. Moreover, the prognostic value of FibroScan results has been demonstrated, emphasizing its potential to provide valuable insights into disease progression and outcomes [7]. The incorporation of the controlled attenuation parameter (CAP) within the FibroScan machine enhances its diagnostic capabilities by assessing hepatic steatosis, contributing to a more comprehensive evaluation of liver health. Advanced fibrosis was defined as liver stiffness measurement (LSM) dichotomized using a 9.5 kPa as per literature [8].
2.3. Model Construction and Statistical Analysis
In NHANES, the datasets of demographics, dietary information, physical examination, laboratory results, and medical questionnaires encompassed a total of 700 covariates for modeling purposes, and all covariates were utilized as the initial dataset. The univariate logistic models were employed to investigate the association between these covariates and advanced liver fibrosis as the outcome variable. During the univariate analysis, the machine learning model selected covariates with a p value below 0.0001 to identify strong independent covariates among the 700 variables before assessing their interactions in the bigger model. For this study, the XGBoost algorithm was employed due to its widespread usage in the literature and improved predictive accuracy in healthcare predictions. Previous studies utilizing the NHANES cohort have identified XGBoost as the most effective algorithm, offering a balanced combination of training efficiency, model accuracy, and transparency. The dataset was divided into a train: test set split of 80:20 to calculate the final model fit parameters. The model fit parameters utilized in this study included the area under the receiver operator characteristic curve (AUROC), sensitivity, specificity, positive predictive value, negative predictive value, prevalence, detection rate, detection prevalence, and balanced accuracy. These parameters were utilized to assess and evaluate the performance of the model.
2.4. Model Feature Importance Statistics and SHAP Visualization
The gain metric quantifies the contribution of a feature to the model by calculating its individual contribution for each tree. A higher gain value compared to other features indicates a greater importance in generating predictions. The cover metric represents the relative number of observations associated with a specific feature. For instance, if there are 200 observations, 5 features, and 4 trees, and Feature 1 is used to determine the leaf node for 15, 10, 8, and 5 observations in Tree 1, Tree 2, Tree 3, and Tree 4, respectively, the cover metric for Feature 1 would be calculated as 15 + 10 + 8 + 5 = 38 observations. This calculation is performed for all features, and the cover metric is expressed as a percentage based on the total cover for all features. The frequency metric denotes the percentage representing the relative occurrence of a particular feature in the model's trees. In the previous example, if feature one appeared in three splits, two splits, four splits, and one split within Tree 1, Tree 2, Tree 3, and Tree 4, respectively, the weightage for feature one would be 3 + 2 + 4 + 1 or 10. The frequency for Feature 1 is determined by calculating its percentage weight relative to the weights of all features. SHAP visualizations were constructed based on the machine‐learning models with other significant covariates, allowing understanding of their relationships in the context of other covariates.
3. Results
Table 1 shows the 6979 patients that met the inclusion criteria in this study. Individuals reported a mean waist circumference of 100.57 cm (SD = 17.36), gamma‐glutamyl transferase (GGT) levels of 31.29 U/L (SD = 43.73), a mean age of 49.0 (SD = 18.06), a platelet count of 246 670 (SD = 65.14), aspartate aminotransferase levels of 21.74 U/L (SD = 13.21), a body mass index of 29.93 kg/m2 (SD = 7.50, total cholesterol levels of 184.70 mg/dL (SD = 40.59), hip circumference of 107.49 cm (SD = 14.78), fasting glucose levels of 112.87 mg/dL (SD = 37.42), total bilirubin levels of 7.84 μmol/L (SD = 4.76), and direct HDL‐cholesterol levels of 1.38 mmol/L (SD = 0.41). Compared to those that had advanced liver fibrosis those that did not have liver fibrosis had a mean age of 56.09 (SD = 15.83) compared to 48.48 (SD = 18.11), mean waist circumference of 119.95 cm (SD = 19.27) compared to 99.12 cm (SD = 16.31), GGT U/L of 63.77 (SD = 86.15) compared to 28.79 (SD = 37.44), a platelet count of 238 330 (SD = 74.12) compared to 247 920 (SD = 64.23), a Aspartate aminotransferase level of 31.03 U/L (SD = 31.64) compared to 21.03 U/L (SD = 10.19), a body mass index of 37.80 kg/m2 (SD = 10.48) compared to a BMI of 29.33 kg/m2 (SD = 6.86), a total cholesterol level of 175.49 mg/dL (SD = 43.23) compared to a cholesterol level of 185.75 mg/dL (SD = 40.30), hip circumference of 121.95 cm (SD = 20.16) compared to a hip circumference of 106.40 cm (SD = 13.69), a fasting glucose level of 135.78 mg/dL (SD = 55.25) compared to a fasting glucose of 111.12 mg/dL (35.09), total bilirubin levels of 8.88 μmol/L (SD = 5.61) compared to a total bilirubin of 7.75 μmol/L of 7.75, SD = 4.68), and a direct HDL‐cholesterol level of 1.24 mmol/L (SD = 0.43) compared to a direct HDL‐cholesterol level of 1.39 mmol/L (0.41).
TABLE 1.
Demographic variables.
| Total | Advanced fibrosis | No advanced fibrosis | p | |
|---|---|---|---|---|
| Total | 6979 | 499 | 6480 | |
| Age (years) | 49.02 (18.06) | 56.09 (15.83) | 48.48 (18.11) | < 0.0001 |
| Gender | ||||
| Female | 3523 (0.5) | 209 (0.42) | 3314 (0.51) | < 0.0001 |
| Male | 3456 (0.5) | 290 (0.58) | 3166 (0.49) | < 0.0001 |
| Race/ethnicity | ||||
| Non‐Hispanic White | 2562 (0.37) | 209 (0.42) | 2353 (0.36) | 0.0073 |
| Non‐Hispanic Black | 1797 (0.26) | 126 (0.25) | 1671 (0.26) | 0.7672 |
| Hispanic | 1504 (0.22) | 107 (0.21) | 1397 (0.22) | 0.6029 |
| Other | 1116 (0.16) | 57 (0.11) | 1059 (0.16) | 0.003 |
| Direct HDL‐cholesterol (mmol/L) | 1.38 (0.41) | 1.24 (0.43) | 1.39 (0.41) | < 0.0001 |
| Total cholesterol (mg/dL) | 184.70 (40.59) | 175.38 (43.55) | 185.42 (40.27) | < 0.0001 |
| Total cholesterol (mmol/L) | 4.78 (1.05) | 4.54 (1.13) | 4.80 (1.04) | < 0.0001 |
| Lymphocyte percent (%) | 31.52 (8.89) | 29.54 (9.07) | 31.67 (8.86) | < 0.0001 |
| Monocyte percent (%) | 8.19 (2.22) | 8.40 (2.40) | 8.17 (2.21) | < 0.0001 |
| Monocyte number (1000 cells/μL) | 0.57 (0.21) | 0.63 (0.22) | 0.57 (0.21) | < 0.0001 |
| Red cell distribution width (%) | 13.87 (1.37) | 14.29 (1.64) | 13.84 (1.34) | < 0.0001 |
| Platelet count (1000 cells/μL) | 246.67 (65.14) | 230.33 (74.12) | 247.92 (64.23) | < 0.0001 |
| Mean platelet volume (fL) | 8.26 (0.90) | 8.41 (0.95) | 8.25 (0.90) | < 0.0001 |
| Ferritin (ng/mL) | 155.57 (181.97) | 244.82 (364.57) | 148.67 (157.36) | < 0.0001 |
| HS C‐reactive protein (mg/L) | 3.97 (7.69) | 6.96 (11.64) | 3.74 (7.25) | < 0.0001 |
| Insulin (μU/mL) | 14.86 (23.59) | 31.77 (61.97) | 13.57 (16.85) | < 0.0001 |
| Fasting glucose (mg/dL) | 112.87 (37.42) | 135.78 (55.25) | 111.12 (35.09) | < 0.0001 |
| Fasting glucose (mmol/L) | 6.27 (2.08) | 7.54 (3.07) | 6.17 (1.95) | < 0.0001 |
| Albumin, refrigerated serum (g/dL) | 4.07 (0.34) | 3.93 (0.37) | 4.08 (0.33) | < 0.0001 |
| Albumin, refrigerated serum (g/L) | 40.73 (3.38) | 39.33 (3.74) | 40.84 (3.32) | < 0.0001 |
| Aspartate aminotransferase (AST) (U/L) | 21.74 (13.21) | 31.03 (31.64) | 21.03 (10.19) | < 0.0001 |
| Blood urea nitrogen (mg/dL) | 14.79 (5.77) | 16.85 (7.94) | 14.63 (5.53) | < 0.0001 |
| Creatinine, refrigerated serum (mg/dL) | 0.90 (0.44) | 0.99 (0.65) | 0.89 (0.42) | < 0.0001 |
| Creatinine, refrigerated serum (μmol/L) | 79.50 (38.71) | 87.71 (57.20) | 78.87 (36.83) | < 0.0001 |
| Globulin (g/dL) | 3.09 (0.44) | 3.26 (0.56) | 3.07 (0.42) | < 0.0001 |
| Glutamyl transferase (GGT) (IU/L) | 31.29 (43.73) | 63.77 (86.15) | 28.79 (37.44) | < 0.0001 |
| Lactate dehydrogenase (LDH) (IU/L) | 157.68 (33.94) | 170.49 (48.17) | 156.69 (32.39) | < 0.0001 |
| Total bilirubin (μmol/L) | 7.84 (4.76) | 8.88 (5.61) | 7.75 (4.68) | < 0.0001 |
| Cholesterol, refrigerated serum (mg/dL) | 185.02 (40.60) | 175.49 (43.23) | 185.75 (40.30) | < 0.0001 |
| Cholesterol, refrigerated serum (mmol/L) | 4.78 (1.05) | 4.54 (1.12) | 4.80 (1.04) | < 0.0001 |
| Triglycerides, refrigerated serum (mg/dL) | 137.03 (107.46) | 161.92 (130.09) | 135.11 (105.29) | < 0.0001 |
| Triglycerides, refrigerated serum (mmol/L) | 1.55 (1.21) | 1.83 (1.47) | 1.53 (1.19) | < 0.0001 |
| Uric acid (mg/dL) | 5.40 (1.45) | 6.13 (1.64) | 5.35 (1.42) | < 0.0001 |
| Uric acid (μmol/L) | 321.41 (86.52) | 364.69 (97.56) | 318.08 (84.71) | < 0.0001 |
| BMXWT—weight (kg) | 83.90 (22.97) | 107.60 (31.49) | 82.08 (21.11) | < 0.0001 |
| BMXHT—standing height (cm) | 167.19 (9.87) | 168.70 (9.99) | 167.07 (9.86) | < 0.0001 |
| BMXBMI—body mass index (kg/m2) | 29.93 (7.50) | 37.80 (10.48) | 29.33 (6.86) | < 0.0001 |
| BMXARML—upper arm length (cm) | 37.70 (2.84) | 38.65 (2.96) | 37.62 (2.82) | < 0.0001 |
| BMXARMC—arm (cm) | 33.73 (5.36) | 38.22 (6.55) | 33.39 (5.10) | < 0.0001 |
| BMXWAIST—waist circumference (cm) | 100.57 (17.36) | 119.95 (19.27) | 99.12 (16.31) | < 0.0001 |
| BMXHIP—hip circumference (cm) | 107.49 (14.78) | 121.95 (20.16) | 106.40 (13.69) | < 0.0001 |
| General health condition | 2.75 (1.02) | 3.16 (1.00) | 2.72 (1.02) | < 0.0001 |
| Ever told doctor had trouble sleeping? | 1.71 (0.45) | 1.60 (0.49) | 1.72 (0.45) | < 0.0001 |
| Height (in.) | 66.47 (4.13) | 67.23 (4.17) | 66.41 (4.12) | < 0.0001 |
| How do you consider your weight? | 1.89 (0.99) | 1.45 (0.87) | 1.93 (0.99) | < 0.0001 |
| Days vigorous recreational activities | 0.89 (1.68) | 0.49 (1.33) | 0.92 (1.71) | < 0.0001 |
| Direct HDL‐cholesterol (mg/dL) | 53.29 (15.81) | 47.81 (16.58) | 53.72 (15.67) | < 0.0001 |
| LBXTC—total cholesterol (mg/dL) | 184.70 (40.59) | 175.38 (43.55) | 185.42 (40.27) | < 0.0001 |
| Sleep disorder | 0.29 (0.45) | 0.40 (0.49) | 0.28 (0.45) | < 0.0001 |
Note: Descriptive statistics for demographic characteristics and all covariates within the machine learning model, stratified by having advanced fibrosis.
Table 2 shows the top features ranked by gain, which measures the impact of each variable on the overall algorithm. The top eight covariates include waist circumference (gain = 0.185), GGT (gain = 0.101), platelet count (gain = 0.059), AST (gain = 0.057), weight (gain = 0.049), HDL‐cholesterol (gain = 0.032), and ferritin (gain = 0.034).
TABLE 2.
Displays the statistical model metrics evaluated by sensitivity, specificity, positive predictive value (PPV), negative predictive value (NPV), Prevalence, Detection Rate, Detection Prevalence, and Balanced Accuracy.
| Metric | Value |
|---|---|
| Sensitivity | 0.9613 |
| Specificity | 0.3588 |
| Positive predictive value (precision) | 0.9354 |
| Negative predictive value | 0.4896 |
| Prevalence | 0.9062 |
| Detection rate (true positive rate) | 0.8711 |
| Detection prevalence | 0.9312 |
| Balanced accuracy | 0.66 |
Note: The statistical model metrics evaluated by sensitivity, specificity, positive predictive value (PPV), negative predictive value (NPV), prevalence, detection rate, detection prevalence, and balanced accuracy.
The machine learning model had 67 features that were found to be significant on univariate analysis (p < 0.0001 used). These were fitted into the XGBoost model; Figure 1 and Table 2 show an AUROC = 0.885, sensitivity = 0.960, specificity = 0.3588, positive predictive value = 0.935, and negative predictive value = 0.4896 were observed. Table 3 shows that the top five highest ranked features by gain, a measure of the percentage contribution of the covariate to the overall model prediction, were SFA 8.0 octanoic intake (g) (gain = 8.8%), eosinophil percent (gain = 7.9%), BMXHIP—hip circumference (cm) (gain = 7.2%), BMXHT—standing height (cm) (gain = 6.2%) and HS C‐reactive protein (mg/L) (gain 6.1%). Despite the moderate specificity (0.3588), this value was justified in the context of the model's performance, as a high sensitivity of 0.960 was prioritized to minimize false negatives and ensure accurate identification of individuals at risk for advanced liver fibrosis. This trade‐off between sensitivity and specificity is clinically relevant, particularly in a screening context where missing high‐risk individuals can have serious consequences. The relatively lower specificity may also reflect characteristics of the NHANES cohort, which represents a broadly generalizable population and may necessitate a higher diagnostic threshold compared to more narrowly defined study populations.
FIGURE 1.

Receiver operator characteristic curve and model statistics. The receiver operating characteristic curve for the machine‐learning model predicting whether the patient had advanced fibrosis. AUROC = 0.885 (p < 0.001).
TABLE 3.
Model gain statistics.
| Feature | Gain | Cover | Frequency |
|---|---|---|---|
| BMXWAIST—Waist circumference (cm) | 0.185 | 0.139 | 0.068 |
| Gamma glutamyl transferase (GGT) (IU/L) | 0.101 | 0.086 | 0.056 |
| Platelet count (1000 cells/μL) | 0.059 | 0.067 | 0.054 |
| Aspartate aminotransferase (AST) (U/L) | 0.057 | 0.055 | 0.044 |
| BMXWT—Weight (kg) | 0.049 | 0.033 | 0.033 |
| Direct HDL‐cholesterol (mmol/L) | 0.039 | 0.054 | 0.074 |
| Ferritin (ng/mL) | 0.034 | 0.032 | 0.034 |
| Total cholesterol (mg/dL) | 0.032 | 0.031 | 0.053 |
| BMXHIP—Hip circumference (cm) | 0.029 | 0.061 | 0.037 |
| HS C‐reactive protein (mg/L) | 0.025 | 0.064 | 0.039 |
| Fasting glucose (mg/dL) | 0.025 | 0.043 | 0.031 |
| BMXBMI—Body mass index (kg/m2) | 0.025 | 0.040 | 0.026 |
| Total bilirubin (μmol/L) | 0.025 | 0.004 | 0.020 |
| Age | 0.024 | 0.035 | 0.028 |
| Lymphocyte percent (%) | 0.023 | 0.017 | 0.042 |
| Globulin (g/dL) | 0.020 | 0.031 | 0.026 |
| Lactate dehydrogenase (LDH) (IU/L) | 0.019 | 0.004 | 0.021 |
| BMXARMC—Arm circumference (cm) | 0.017 | 0.025 | 0.024 |
| Blood urea nitrogen (mg/dL) | 0.017 | 0.018 | 0.020 |
| BMXHT—Standing height (cm) | 0.016 | 0.006 | 0.020 |
| Uric acid (mg/dL) | 0.016 | 0.017 | 0.019 |
| Insulin (μU/mL) | 0.016 | 0.034 | 0.025 |
| BMXARML—Upper arm length (cm) | 0.015 | 0.006 | 0.020 |
| Cholesterol, refrigerated serum (mg/dL) | 0.014 | 0.020 | 0.016 |
| Triglycerides, refrigerated serum (mg/dL) | 0.013 | 0.007 | 0.018 |
| Monocyte percent (%) | 0.013 | 0.011 | 0.024 |
| Creatinine, refrigerated serum (mg/dL) | 0.013 | 0.006 | 0.016 |
| Red cell distribution width (%) | 0.012 | 0.016 | 0.022 |
| Albumin, refrigerated serum (g/dL) | 0.011 | 0.005 | 0.016 |
| Mean platelet volume (fL) | 0.009 | 0.006 | 0.017 |
| Monocyte number (1000 cells/μL) | 0.006 | 0.008 | 0.011 |
| MCQ160b—Ever told had congestive heart failure | 0.004 | 0.001 | 0.003 |
| Weight loss 10 lbs | 0.003 | 0.000 | 0.004 |
| MCQ366b—Doctor told you to exercise | 0.003 | 0.005 | 0.003 |
| MCQ300c—Close relative had diabetes? | 0.003 | 0.001 | 0.002 |
| Days vigorous recreational activities | 0.003 | 0.000 | 0.003 |
| MCQ560—Ever had gallbladder surgery? | 0.002 | 0.007 | 0.004 |
| Height (in.) | 0.002 | 0.001 | 0.002 |
| General health condition | 0.002 | 0.001 | 0.003 |
| General health | 0.002 | 0.000 | 0.002 |
| Ever told doctor had trouble sleeping? | 0.002 | 0.000 | 0.002 |
| MCQ371a—Are you now controlling or losing weight | 0.002 | 0.000 | 0.002 |
| Female gender | 0.002 | 0.000 | 0.001 |
| MCQ366a—Doctor told you to control/lose weight | 0.001 | 0.000 | 0.002 |
| MCQ160a—Doctor ever said you had arthritis | 0.001 | 0.000 | 0.002 |
| How do you consider your weight? | 0.001 | 0.000 | 0.002 |
| MCQ160e—Ever told you had heart attack | 0.001 | 0.001 | 0.001 |
| Like to weight | 0.001 | 0.000 | 0.001 |
| MCQ366d—Doctor told you to reduce fat/cal | 0.001 | 0.001 | 0.001 |
| MCQ550—Has DR ever said you have gallstones | 0.001 | 0.000 | 0.001 |
| MCQ080—Doctor ever said you were overweight | 0.001 | 0.001 | 0.001 |
| MCQ366c—Doctor told you to reduce salt in diet | 0.001 | 0.000 | 0.001 |
| MCQ371c—Are you now reducing salt in diet | 0.000 | 0.000 | 0.001 |
| MCQ160c—Ever told you had coronary heart disease | 0.000 | 0.000 | 0.000 |
| BMILEG | 0.000 | 0.001 | 0.000 |
Note: The gain, cover, and frequency of all covariates within the XGBoost model. The gain represents the relative contribution of the feature to the model and is the most important metric of model importance within this study. Covariates ordered according to the gain statistic.
In Figure 2, overall SHAP explanations can be seen for all the statistically significant covariates on univariable regression.
FIGURE 2.

Overall SHAP explanations. SHAP explanations, purple color representing higher values of the covariate while yellow representing lower values of the covariate. x‐axis is the change in log odds for advanced fibrosis.
In Figure 3a,b, SHAP visualizations were conducted for the top eight continuous covariates by overall SHAP explanations. Trends included an increasing GGT that had a sharp increasing parabolic association with advanced fibrosis, increases in BMI that were associated with advanced fibrosis, and increases in platelet count that were associated with less advanced liver fibrosis. In Figure 3a, SHAP visualizations revealed two discrete regions in the GGT values, suggesting stratification among subgroups with differing baseline characteristics. This pattern may reflect individuals with elevated GGT levels, such as those with recent alcohol use, who have not yet developed advanced fibrosis. These findings further support the nuanced relationship between GGT and fibrosis risk captured by the model.
FIGURE 3.

(a) SHAP explanations, covariate value on the x‐axis, change in log odds on the y‐axis, red line represents the relationship between the covariate and log odds for liver fibrosis attacks, each black dot represents an observation. Covariates: Top left—gamma glutamyl transferase levels (U/L), top right—age, bottom left—body mass index (kg/m2), bottom right—total cholesterol (mg/dL). The red line shows a line of expected fit based upon the SHAP representation and each covariate is on the x‐axis with its SHAP prediction value as the y‐axis. (b) SHAP explanations, covariate value on the x‐axis, change in log odds on the y‐axis, red line represents the relationship between the covariate and log odds for liver fibrosis attacks, each black dot represents an observation. Covariates: Top left—platelet count (cells/μL), top right—aspartate aminotransferase (U/L), bottom left—hip circumference (cm), bottom right—fasting glucose (mg/dL).
4. Discussion
In this cross‐sectional cohort study of US adults, machine learning models that utilized information from the NHANES on demographic, laboratory, physical examination, and lifestyle factors demonstrated a high predictive accuracy with an AUROC of 0.885. This indicates that the models were able to effectively predict advanced liver fibrosis, a significant marker of liver disease severity. Covariates that had significant associations with liver fibrosis in the machine learning model based off SHAP value included waist circumference, GGT, age, platelet count, aspartate aminotransferase, body mass index, and total cholesterol. The top eight covariates ranked by gain, which is a measure of the relative contribution of the corresponding feature to the model calculated by taking each feature's contribution for each tree in the model, include waist circumference (gain = 0.185), GGT (gain = 0.101), platelet count (gain = 0.059), AST (gain = 0.057), weight (gain = 0.049), HDL‐cholesterol (gain = 0.032), and ferritin (gain = 0.034).
The machine learning model was able to reflect the fact that liver fibrosis is associated with MASLD and alcoholic liver but can also be elevated in other conditions by identifying relationships consistent with the literature, including those that had CHF and associations with cholestasis as those with increased risk of liver fibrosis (Table 2). The findings of our machine learning model are in line with the existing literature, particularly regarding the etiology of MASLD, which is closely linked to obesity, Type 2 diabetes mellitus (T2DM), and metabolic syndromes [9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]. The study highlights the significance of these relationships by identifying key anthropomorphic measurements such as waist circumference, BMI, hip circumference, arm circumference, and upper arm circumference, as well as indicators of excess adiposity like cholesterol values and triglycerides, as significant predictors of advanced liver fibrosis. T2DM, another significant risk factor for liver fibrosis, was reflected in our study through the inclusion of glucose and insulin as important covariates. Elevated blood glucose levels and insulin resistance are hallmark features of T2DM and are closely associated with the development of liver fibrosis [20]. The robust associations observed in our study underscore the importance of maintaining glycemic control and enhancing insulin sensitivity to prevent and manage liver fibrosis effectively [21].
The fact that our study's findings align with existing literature supports our confidence in the machine learning model's ability to accurately capture the genuine physiological relationships associated with liver fibrosis. The algorithmic approach used in our study has the advantage of identifying significant covariates without subjective influence from researchers by systematically searching through numerous variables based on mathematical relationships. Facilitated by the model's methodology, nonlinear patterns can be uncovered, and the covariates can be ranked based upon performance metrics that assess the overall accuracy and reliability of the machine learning model in predicting liver fibrosis [22]. SHAP visualizations allow researchers to compare their own understanding of the relationships of the variables with the machine learning models assessment and to test for physiologic plausibility. We will highlight that applying machine learning methods and interpreting key predictors can help identify signs of liver fibrosis earlier, guiding more proactive screening and targeted interventions. This perspective underscores the potential of these models to inform more timely patient care and improve long‐term outcomes.
4.1. Limitations
The study carries the strengths and weaknesses inherent in cross‐sectional multistage survey questionnaire studies. While these surveys typically employ multistage sampling techniques to ensure a representative sample and allow for generalizability to the larger population, they only provide a snapshot at a single point in time, limiting the ability to establish causal or temporal sequences. These surveys, on one hand, are cost‐effective and efficient in collecting data from a large number of participants within a relatively short period, but there is a potential for recall and response bias. It is crucial to consider these limitations when interpreting findings from cross‐sectional multistage survey questionnaire data.
5. Conclusion
Machine learning models have demonstrated their efficacy in accurately predicting liver fibrosis by leveraging a range of covariates including demographic, laboratory, physical examination, and lifestyle factors. Among these covariates, waist circumference emerges as a particularly strong predictor of liver fibrosis. The model also identifies other significant predictors such as age, total cholesterol, total platelets, and family history of liver disease, underscoring their importance in determining the likelihood of liver fibrosis development.
Conflicts of Interest
The authors declare no conflicts of interest.
Huang A. A. and Huang S. Y., “The Visualization of the Importance of Covariance Importance in a Machine Learning Model for Advanced Liver Fibrosis in a Nationally Representative Sample,” JGH Open 9, no. 7 (2025): e70200, 10.1002/jgh3.70200.
Funding: The authors received no specific funding for this work.
Data Availability Statement
The data from this cohort can be found on the NHANES section of the CDC website. Data described in the manuscript are free available without restriction at: https://wwwn.cdc.gov/nchs/nhanes/continuousnhanes/default.aspx?cycle=2017‐2020.
References
- 1. Moon A. M., Singal A. G., and Tapper E. B., “Contemporary Epidemiology of Chronic Liver Disease and Cirrhosis,” Clinical Gastroenterology and Hepatology 18, no. 12 (2020): 2650–2666, 10.1016/j.cgh.2019.07.060. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 2. Yoo S. H., Kim S. S., Kim S. G., et al., “Current Status of Ultrasonography in National Cancer Surveillance Program for Hepatocellular Carcinoma in South Korea: A Large‐Scale Multicenter Study,” Journal of Liver Cancer 23, no. 1 (2023): 189–201, 10.17998/jlc.2023.03.11. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 3. Pouwels S., Sakran N., Graham Y., et al., “Non‐Alcoholic Fatty Liver Disease (NAFLD): A Review of Pathophysiology, Clinical Management and Effects of Weight Loss,” BMC Endocrine Disorders 22 (2022): 63, 10.1186/s12902-022-00980-1. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 4. Friedman S. L., Neuschwander‐Tetri B. A., Rinella M., and Sanyal A. J., “Mechanisms of NAFLD Development and Therapeutic Strategies,” Nature Medicine 24, no. 7 (2018): 908–922, 10.1038/s41591-018-0104-9. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 5. Huang A. A. and Huang S. Y., “Use of Machine Learning to Identify Risk Factors for Insomnia,” PLoS One 18, no. 4 (2023): e0282622, 10.1371/journal.pone.0282622. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 6. Martinou E., Pericleous M., Stefanova I., Kaur V., and Angelidi A. M., “Diagnostic Modalities of Non‐Alcoholic Fatty Liver Disease: From Biochemical Biomarkers to Multi‐Omics Non‐Invasive Approaches,” Diagnostics 12, no. 2 (2022): 407, 10.3390/diagnostics12020407. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 7. Soresi M., Giannitrapani L., Cervello M., Licata A., and Montalto G., “Non Invasive Tools for the Diagnosis of Liver Cirrhosis,” World Journal of Gastroenterology 20, no. 48 (2014): 18131–18150, 10.3748/wjg.v20.i48.18131. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 8. Pang J. X., Zimmer S., Niu S., et al., “Liver Stiffness by Transient Elastography Predicts Liver‐Related Complications and Mortality in Patients With Chronic Liver Disease,” PLoS One 9, no. 4 (2014): e95776, 10.1371/journal.pone.0095776. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 9. Bergantini L., Baldassarri M., d'Alessandro M., et al., “Ultra‐Rare RTEL1 Gene Variants Associate With Acute Severity of COVID‐19 and Evolution to Pulmonary Fibrosis as a Specific Long COVID Disorder,” Respiratory Research 24 (2023): 158, 10.1186/s12931-023-02458-7. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 10. Breit H. C., Vosshenrich J., Heye T., et al., “Assessment of Hepatic Function Employing Hepatocyte Specific Contrast Agent Concentrations to Multifactorially Evaluate Fibrotic Remodeling,” Quantitative Imaging in Medicine and Surgery 13, no. 7 (2023): 4284–4294, 10.21037/qims-22-884. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 11. Huang H., Awuah W. A., Garg T., et al., “Prospects of Evolution‐Based Artificial Intelligence Models in Genome‐Wide Studies to Stratify Genetic Risk Variants in Nonalcoholic Fatty Liver Disease,” Annals of Medicine and Surgery 85, no. 6 (2023): 2743–2748, 10.1097/MS9.0000000000000743. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 12. Li J., Zhang Y., Ye H., et al., “Machine Learning‐Based Development of Nomogram for Hepatocellular Carcinoma to Predict Acute Liver Function Deterioration After Drug‐Eluting Beads Transarterial Chemoembolization,” Academic Radiology 30 (2023): S40–S52, 10.1016/j.acra.2023.05.014. [DOI] [PubMed] [Google Scholar]
- 13. Maji R. K., Czepukojc B., Scherer M., et al., “Alterations in the Hepatocyte Epigenetic Landscape in Steatosis,” Epigenetics & Chromatin 16 (2023): 30, 10.1186/s13072-023-00504-8. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 14. Mamandipoor B., Wernly S., Semmler G., et al., “Machine Learning Models Predict Liver Steatosis but Not Liver Fibrosis in a Prospective Cohort Study,” Clinics and Research in Hepatology and Gastroenterology 47, no. 7 (2023): 102181, 10.1016/j.clinre.2023.102181. [DOI] [PubMed] [Google Scholar]
- 15. Otero Sanchez L., Zhan C. Y., da Silveira Cauduro C. G., et al., “A Machine Learning‐Based Classification of Adult‐Onset Diabetes Identifies Patients at Risk of Liver‐Related Complications,” JHEP Reports 5, no. 8 (2023): 100791, 10.1016/j.jhepr.2023.100791. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 16. Richards S. M., Guo F., Zou H., et al., “Non‐Invasive Candidate Protein Signature Predicts Hepatic Venous Pressure Gradient Reduction in Cirrhotic Patients After Sustained Virologic Response,” Liver International 43 (2023): 1984–1994, 10.1111/liv.15657. [DOI] [PubMed] [Google Scholar]
- 17. Singh S., Hoque S., Zekry A., and Sowmya A., “Radiological Diagnosis of Chronic Liver Disease and Hepatocellular Carcinoma: A Review,” Journal of Medical Systems 47 (2023): 73, 10.1007/s10916-023-01968-7. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 18. Al‐Hasani M., Sultan L. R., Sagreiya H., Cary T. W., Karmacharya M. B., and Sehgal C. M., “Ultrasound Radiomics for the Detection of Early‐Stage Liver Fibrosis,” Diagnostics 12, no. 11 (2022): 2737, 10.3390/diagnostics12112737. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 19. Cao L. L., Peng M., Xie X., et al., “Artificial Intelligence in Liver Ultrasound,” World Journal of Gastroenterology 28, no. 27 (2022): 3398–3409, 10.3748/wjg.v28.i27.3398. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 20. Galicia‐Garcia U., Benito‐Vicente A., Jebari S., et al., “Pathophysiology of Type 2 Diabetes Mellitus,” International Journal of Molecular Sciences 21, no. 17 (2020): 6275, 10.3390/ijms21176275. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 21. Ormazabal V., Nair S., Elfeky O., Aguayo C., Salomon C., and Zuniga F. A., “Association Between Insulin Resistance and the Development of Cardiovascular Disease,” Cardiovascular Diabetology 17 (2018): 122, 10.1186/s12933-018-0762-4. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 22. Huang A. A. and Huang S. Y., “Increasing Transparency in Machine Learning Through Bootstrap Simulation and Shapley Additive Explanations,” PLoS One 18, no. 2 (2023): e0281922, 10.1371/journal.pone.0281922. [DOI] [PMC free article] [PubMed] [Google Scholar]
Associated Data
This section collects any data citations, data availability statements, or supplementary materials included in this article.
Data Availability Statement
The data from this cohort can be found on the NHANES section of the CDC website. Data described in the manuscript are free available without restriction at: https://wwwn.cdc.gov/nchs/nhanes/continuousnhanes/default.aspx?cycle=2017‐2020.
