$$\rightleftharpoonup{xx}$$
$$\longleftharp{xx}$$,
$$\longrightharp{xx}$$,
Patients and study design
The first dataset of this study was obtained from the National Health and Nutrition Examination Survey (NHANES) database for the 2017–2018 period. This specific timeframe was selected because the survey data included liver ultrasound transient elastography measurements using FibroScan® technology. NHANES employs a stratified, multi-stage probability sampling design and serves as a nationwide, population-based survey conducted biennially. It systematically gathers nationally representative health-related data on the non-institutionalized U.S. population to evaluate the nutritional and health status of the general civilian population in the United States1. The NHANES is a nationally representative cross-sectional study administered by the National Center for Health Statistics (NCHS). The survey protocol received approval from the NCHS Research Ethics Review Board, with documented informed consent obtained from all participants. The study was conducted in accordance with both the Declarations of Helsinki and Istanbul, and was approved by the ethics committee of the First Affiliated Hospital of Wenzhou Medical University (2016–246, 1 December 2016), and written informed consent was obtained from each participant.
The first dataset consisted of 5494 individuals from the NHANES 2017–2018 survey who underwent FibroScan examination. Following the exclusion below, a total of 2677 participants were included in the analysis, comprising 718 individuals with NAFLD and 1959 with non- NAFLD. These participants were then randomly divided into a training set (n = 1785) and a testing set (n = 892). The second dataset comprised 582 individuals from the Department of Infectious Diseases at the First Affiliated Hospital of Wenzhou Medical University (2018–2020). After applying the same exclusion criteria, a total of 200 individuals were included, consisting of 159 individuals with NAFLD and 41 individuals with non-NAFLD. This cohort was utilized as an independent validation set. The study design was developed to construct and validate the model using multi-center data, thereby enhancing the reliability and generalizability of the findings. Baseline clinical characteristics of the NAFLD and non-NAFLD groups were summarized using the table one package (Table 1). Additionally, the process of patient selection and the overall study flow are illustrated in Figure 1.
Diagnostic criteria and exclusion criteria for NAFLD
NAFLD diagnosis was based on the following criteria16: age 18 years or older, participation in transient elastography (FibroScan) screening with alcohol intake limited to ≤140 g/week for women and ≤ 210 g/week for men over the prior 12 months, a controlled attenuation parameter (CAP) value of ≥ 302 dB/m as measured using the FibroScan 502 V2 Touch system (Echosens, Paris, France) with either a medium (M) or extra‑large (XL) probe, or a diagnosis confirmed by liver biopsy pathology at the Department of Infectious Diseases of the First Affiliated Hospital of Wenzhou Medical University23.
The exclusion criteria for NAFLD are outlined as follows:.high alcohol consumption (average daily intake > 20 g for women and > 30 g for men according to the NHANES alcohol use survey5), presence of hepatitis B or C, HIV infection, autoimmune hepatitis, primary biliary cholangitis, Wilson’s disease, long‑term use of nonsteroidal anti‑inflammatory drugs, calcium channel blockers, tamoxifen, amiodarone, corticosteroids, isoniazid, or methotrexate, pregnancy or breastfeeding, and a diagnosis of liver cancer or any other benign or malignant tumor.
Data collection and variable selection
The potential predictor variables included in this study are listed below:
Demographic characteristics (i.e., age and gender); Body mass index (BMI); CAP values of participants in the NHANES database; General biochemistry tests [i.e., Albumin(ALB), Globulin (GLO), Total Protein (TP), Lactate Dehydrogenase (LDH), Blood Urea Nitrogen (BUN), Uric Acid (UA), Gamma-Glutamyl Transferase (GGT), Triglyceride (TG), Serum-Glucose (Glu), Serum Creatinine (SCr), Total Bilirubin (TBIL), Sodium (Na⁺), Chloride (Cl⁻), Potassium (K⁺), Calcium (Ca), Bicarbonate (HCO₃), Total Cholesterol(TC), Aspartate Aminotransferase (AST) and Alanine Aminotransferase (ALT)]; Standard hematological parameters [i.e., Red Blood Cells counts (RBC), White blood cell counts (WBC), Neutrophil Counts (NEUT), Eosinophil counts (EOS), lymphocyte counts (LYM), Monocyte counts (MON), Red cell distribution width (RDW) and Platelet counts (PLT)]; History of hypertension and diabetes mellitus (DM). Among the subjects included in the study, the diagnostic criteria for diabetes and hypertension were obtained from a prior machine-learning-based prediction model study focused on NAFLD24.
Missing data handling and feature selection
The cohort data utilized in this study included missing values. Excluding all incomplete records would not only diminish the analysis sample size but also compromise data quality and potentially bias the prediction results. Therefore, any data with missing values exceeding 20% were excluded. For datasets with missing values ≤20%, different imputation methods were applied based on the data type: "norm" for continuous variables, "logreg" for binary classification variables, and "polyreg" for multiclass variables. These imputations were conducted using the "mice" package in R for multiple imputation25. In this study, all continuous variables were dichotomized into binary variables, with optimal classification thresholds determined via receiver operating characteristic (ROC) curve analysis. Specifically, the cut-off point corresponding to the maximum Youden Index on the ROC curve was selected as the optimal classification criterion, thereby optimizing classification performance while maintaining an appropriate balance between sensitivity and specificity. Subsequently, partial least squares discriminant analysis (PLS-DA) was employed to cluster the data effectively.
For further feature selection, individuals were randomly allocated into training and testing sets at a 7:3 ratio using the "caret" package. First, the least absolute shrinkage and selection operator (LASSO) regression was utilized for feature selection, identifying 14 key variables for subsequent analysis. Next, ChatGPT-4 was applied to assign an importance score to each variable. To systematically evaluate feature importance while controlling for potential bias and stochastic variation, a standardized assessment protocol was implemented. The specific prompt provided to the model was: "Based on established clinical literature regarding non-alcoholic fatty liver disease (NAFLD), assign an importance score ranging from 1 (lowest) to 10 (highest) for each of the following 14 variables identified via LASSO regression." By restricting the evaluation strictly to the variables pre-selected by LASSO regression, the risk of incorporating hallucinated or irrelevant features was minimized. To strictly prevent potential data leakage and inadvertent use of outcome prevalence, the language model was entirely blinded to the empirical dataset. The scoring was isolated to synthesizing pre-existing medical knowledge regarding the variable names. This procedure enhances traditional methodologies, such as LASSO stability selection or SHAP-based pruning, by ensuring that purely data-driven features exhibit robust pathophysiological plausibility before final model integration. Additionally, to mitigate single-response variance, this procedure was iterated 10 times independently. The mean score for each variable was computed across these iterations, ensuring an objective prioritization. Variables were then ranked in descending order based on their mean scores. Finally, the selection was narrowed down to include only those variables with an average importance score exceeding 5, resulting in 8 key variables: SCr, UA, GGT, Glu, Hypertension, Diabetes, TG, and BMI.
Development of AutoML - based prediction models for NAFLD
In this study, a comprehensive suite of classical and advanced machine learning algorithms was integrated using H2O AutoML for the effective diagnosis of NAFLD. By leveraging the AutoML capabilities of the H2O.ai platform, machine learning analyses for binary classification tasks were conducted. The algorithms utilized included eXtreme Gradient Boosting (XGBoost), Gradient Boosting Machine (GBM), Generalized Linear Model (GLM), Extremely Randomized Trees (XRT), Deep Learning (DL), and Stacked Ensemble. These algorithms were systematically evaluated to identify the optimal model for disease diagnosis. To ensure rigorous methodological reproducibility, the execution parameters of H2O AutoML were explicitly defined. The automated search was limited to a maximum runtime of 11,687 seconds and a maximum of 302 models, utilizing a fixed random seed of 13. Internal preprocessing flags included automatic imputation of residual missing values using mean/mode algorithms, as well as target encoding for high-cardinality categorical variables. The selected optimal architecture (labeled GBM_grid_1_model77) was a gradient boosting machine with the following specific hyperparameters: a total of 28 trees, a maximum tree depth of 5, and a learning rate of 0.1.
To enhance model robustness and mitigate overfitting risks, an AutoML framework incorporating systematic hyperparameter tuning and validation protocols was implemented. The process began with automated exploration of 200 distinct model configurations through hyperparameter optimization, employing 5-fold cross-validation where the training dataset was partitioned into five mutually exclusive subsets. During iterative training, each configuration utilized four subsets (80%) for model building while reserving one subset (20%) for validation, with this validation role rotating sequentially across all folds. To balance computational efficiency with performance optimization, dynamic early stopping was implemented based on the area under the ROC curve (AUC) metric. This mechanism suspended training when AUC improvements fell below a 0.001 threshold for three consecutive cycles, applying to both individual model refinement and the overall AutoML search process. Final model selection prioritized configurations demonstrating maximum average AUC across both training and validation sets, while simultaneously requiring consistent performance between these sets and minimal metric variance across cross-validation iterations. This integrated approach ensured optimal predictive accuracy while maintaining strong generalizability through rigorous validation protocols and automated optimization constraints.
Model performance evaluation and interpretation of prediction results
Model performance and the interpretation of prediction results were comprehensively assessed using ROC curves, F1 scores, and SHapley additive explanation (SHAP) analysis. The model's performance and the interpretation of its prediction results were comprehensively evaluated using ROC curves, F1 scores, and SHapley Additive Explanation (SHAP) analysis. Initially, predictions were generated on the test dataset using the trained model, and the predicted probabilities for the positive class (i.e., class 1) were extracted (pred_prob). The ROC curve was constructed using the pROC package, and the model’s AUC, along with its 95% confidence interval, was calculated. The optimal threshold on the ROC curve was determined using Youden's J statistic (J = Sensitivity + Specificity − 1) for binary classification label determination. Based on this threshold derived from the ROC curve, the predicted probabilities were converted into binary prediction labels (0 or 1), and a confusion matrix was subsequently generated. The F1 score on the test set was computed using the confusion matrix function, and a visualization of the confusion matrix was produced and saved. Additionally, the model was further validated on an independent external validation dataset consisting of 200 cases (from the First Affiliated Hospital of Wenzhou Medical University). SHAP values were analyzed using the “shapviz” package to elucidate the impact of each variable on the model’s prediction outcomes, thereby providing insights into the interpretation of individual NAFLD likelihood predictions.
Statistical methods
“Statistical analysis and software development were performed using R version 4.2.3 (R Foundation for Statistical Computing, Vienna, Austria). Continuous variables were initially assessed for normality using the Shapiro-Wilk test or visual inspection of Q-Q plots. Normally distributed data were presented as mean ± standard deviation (SD), and comparisons between two independent groups were conducted using independent samples t-tests. For multiple group comparisons, one-way ANOVA was employed with post-hoc Tukey’s HSD tests when appropriate. Non-normally distributed continuous data were summarized as median [interquartile range (IQR), P25–P75], and group comparisons were carried out using the Mann-Whitney U test for two independent groups or the Kruskal-Wallis test for multiple groups, followed by Dunn’s post-hoc test if necessary. Categorical variables were expressed as frequencies and percentages (%), and comparisons of proportions across groups were analyzed using the chi-square test (χ2 test) or Fisher’s exact test when expected cell counts were less than 5. The significance level was set at α = 0.05 (two-tailed), and a p-value < 0.05 was considered statistically significant.