A machine-learning model for staging autoimmune gastritis based on endoscopic and serological features Authors: Jingna Tao, Linghan Meng, Tong Li, Jiaqi Wang, Liju Zhang, Xiyan Zhang, Zhihong Li Published: 2026 ABSTRACT ObjectivesAutoimmune gastritis (AIG) lacks a unified, practical staging system. The AIG-atrophic stage (AIG-AS) scheme, based on the proportional area of remnant oxyntic mucosa (ROM), is promising but observer-dependent. We developed machine-learning models to stage AIG using endoscopic and serological features.MethodsThis single-center cross-sectional study enrolled 203 patients with AIG confirmed by integrated endoscopic, histological, and serological criteria between December 2023 and December 2025. White-light endoscopy (WLE), magnifying endoscopy with narrow-band imaging (ME-NBI), and a serum panel were collected. Patients were classified under AIG-AS as Stage 1 (50%50% missingness (anti–H. pylori type I/II antibodies, intrinsic factor antibody, thyroid function tests) were excluded from modeling. Image interpretation was performed independently by two senior endoscopists with adjudication by a third in case of disagreement; histology was independently reviewed by two pathologists. Statistical analysis Continuous variables are reported as mean ± SD or median (Q1–Q3); categorical variables as n (%). Three-group comparisons used one-way ANOVA or Kruskal–Wallis tests for continuous variables and χ² or G-tests for categorical variables; binary comparisons used independent t-tests or Mann–Whitney U tests, and χ²/Fisher exact tests. Bonferroni-corrected pairwise tests followed significant overall differences. Effect sizes were η²/ϵ² (continuous, three-group), Cramér V (categorical), Cohen d (continuous, binary), or rank-biserial r. Two-sided α=0.05. Analyses used SPSS 30.0 (IBM, Armonk, NY, USA). Machine-learning modeling Five feature sets were constructed: (i) WLE (n=203); (ii) WLE+ME-NBI (n=160); (iii) core serum (7 indicators with missingness <50%: PGI, PGII, PGI/PGII ratio, PCA titer, G-17, folate, vitamin B12); (iv) extended serum (11 indicators, adding TPOAb, TgAb, TRAb, hemoglobin); (v) combined endoscopy+serology (WLE + core serum, 31 variables). Each set was modeled with seven algorithms—LASSO logistic regression, elastic net, random forest, XGBoost, support vector machine, gradient boosting, and a stacking ensemble (random forest, XGBoost, and SVM base learners, logistic regression meta-learner). Stratified 5-fold cross-validation was used, with nested 3-fold randomized search (ten candidate combinations per model) for hyperparameter tuning inside each training fold. Preprocessing—per-feature median imputation, zero-variance removal, Z-score standardization—and SMOTE for class imbalance (Stage 2, n=36) were applied only inside training folds to prevent information leakage; test folds retained the original class distribution. The primary metric was macro-averaged AUC for the three-class task and AUC for the binary task. Feature importance was extracted with Gini importance (tree models), standardized coefficients (linear models), or permutation importance (SVM and stacking); the best tree-based model per set was further analyzed with SHAP. Multicollinearity in the combined set was assessed with Pearson correlation (|r|>0.7) and the variance inflation factor (VIF>10). Implementation used Python 3.13 with scikit-learn, XGBoost, imbalanced-learn, and SHAP. Results Patient characteristics Of 203 patients, 131 (64.5%) were women and 72 (35.5%) men, a 1:1.8 ratio; the median age was 62 years (Q1–Q3, 54–67). The AIG-AS distribution was 87 (42.9%) Stage 1, 36 (17.7%) Stage 2, and 80 (39.4%) Stage 3; the binary distribution was 123 (60.6%) early-to-intermediate and 80 (39.4%) advanced. Age and sex did not differ significantly across stages (P>0.05) (Table 1; Figure 1A). One hundred and sixty patients additionally underwent ME-NBI (68 Stage 1, 26 Stage 2, 66 Stage 3). Table 1AIG-AS staging based on the proportional area of remnant oxyntic mucosa (ROM) and corresponding endoscopic findings.AIG-ASROM areaEndoscopic findingsStage 1 (early)50% < ROM ≤ 100%Redness and swelling of the areae gastricae (granular, mosaic, or salmon-roe appearance)Stage 2 (florid)10% < ROM ≤ 50%ROM of varied morphology and size; medium-to-large hyperplastic polyps; white globe appearanceStage 3 (advanced)ROM ≤ 10%Marked atrophy with prominent visible submucosal vessels; sticky adherent dense mucus; white globe appearance; small hyperplastic polyps AIG-AS staging based on the proportional area of remnant oxyntic mucosa (ROM) and corresponding endoscopic findings. Stage distribution and frequency of endoscopic features across AIG-AS stages. (A) Distribution of patients across the three-class and binary schemes. (B) Heatmap of WLE feature frequency across stages — corpus and fundus. (C) Heatmap of WLE feature frequency — antrum and incisura angularis. (D) Heatmap of ME-NBI feature frequency across stages. Endoscopic features across stages On WLE, two oppositely directed feature clusters defined the staging spectrum (Figures 1B, C). Atrophy-related features increased monotonically with stage: mucosal thinning rose from 34.5% (Stage 1) to 90.0% (Stage 3); visible submucosal vessels from 20.7% to 75.0%; and loss of gastric folds from 14.9% to 85.0% (all P<0.001). Loss of the regular arrangement of collecting venules reached 100% at Stages 2–3 (P<0.001). Sticky adherent dense mucus was more frequent at Stages 2–3 (69.4% and 67.5%) than at Stage 1 (34.5%) (P<0.001). Conversely, inflammation- and edema-related features decreased with stage: mucosal edema fell from 74.7% to 32.5% (P<0.001), swelling of the areae gastricae from 71.3% to 35.0% (P<0.001), and enlarged folds from 29.9% to 12.5% (P<0.01). Redness features (spotty, map-like, diffuse) were most common at Stage 1 and largely absent thereafter (all P<0.05). Bonferroni-corrected pairwise tests confirmed that loss of gastric folds discriminated every stage transition (Stage 1 vs Stage 2, P = 0.003; Stage 2 vs Stage 3, P<0.001). Among 160 patients with ME-NBI (Figure 1D), CSA rose sharply from 32.4% (Stage 1) to 88.5% (Stage 2) and 77.3% (Stage 3) (P<0.001), and WGA followed a similar pattern (17.6%, 46.2%, 42.4%; P = 0.002); MCE swelling decreased with stage (72.1%, 61.5%, 33.3%; P<0.001), mirroring the WLE pattern of areae-gastricae swelling. CO Grade 4 (absent openings) predominated at Stages 2–3 (73.1% and 87.3% vs 25.4% at Stage 1; P<0.001). Barrett esophagus was strikingly prevalent: overall 66.8% (short-segment 41.3%; long-segment 25.5%). Long-segment Barrett esophagus rose from 13.4% (Stage 1) to 43.0% (Stage 3) (P<0.001), whereas short-segment Barrett esophagus was most common at Stage 1 (54.9%). Serological features PGI fell progressively across stages (medians 67.6 → 30.2 → 23.7 μg/L; P<0.001), as did the PGI/PGII ratio (4.21 → 1.89 → 2.10; P<0.001). PGII decreased modestly (P = 0.002). G-17 followed a non-linear trajectory, peaking at Stage 2 (median 34.8 pmol/L) and lowest at Stage 1 (7.4 pmol/L) (P<0.001). Vitamin B12 declined progressively (581.5 → 411.0 → 375.0 pg/mL; P = 0.010). PCA positivity rose from 61.7% (Stage 1) to 85.3% (Stage 2) and 81.8% (Stage 3) (P = 0.005), while PCA titer did not differ across stages. TgAb was highest at Stage 3 (P<0.05); TPOAb, TRAb, folate, and hemoglobin did not differ significantly. Pairwise tests showed that PGI and the PGI/PGII ratio discriminated Stage 1 from Stages 2 and 3 but not Stage 2 from Stage 3—an intrinsic ceiling on serological staging in advanced disease. Machine-learning performance Best-model performance per feature set is shown in Table 2. For the three-class task, the combined endoscopy+serology random forest achieved the highest macro-AUC (0.878 ± 0.051) and accuracy (74.9%), followed by the WLE stacking ensemble (0.853 ± 0.056) and the WLE+ME-NBI elastic net (0.841 ± 0.038). Serology-only models lagged substantially (core stacking 0.693 ± 0.075; extended random forest 0.659 ± 0.051). For the binary task, the WLE+ME-NBI random forest achieved the highest AUC (0.913 ± 0.046), with sensitivity 0.816 ± 0.089 and specificity 0.827 ± 0.134; the combined random forest reached AUC 0.907 ± 0.065 with the highest specificity (0.886 ± 0.033) and accuracy (85.2%); the WLE-only random forest achieved AUC 0.887 ± 0.068. Both serology-based binary models remained ≤0.693. Overlaid ROC curves (Figure 2) showed the combined and endoscopy-based curves consistently above the serology curves; confusion-matrix analysis indicated that Stage 1 and Stage 3 were correctly identified in over 80% of cases by the best models, whereas Stage 2 was most often misclassified into the adjacent stages. Table 2Best-model performance per feature set in three-class and binary AIG staging tasks.Feature setBest modelThree-class macro-AUCThree-class accuracyBinary AUCBinary specificityEndoscopy (WLE)Stacking/RF0.853 ± 0.0560.680 ± 0.0790.887 ± 0.0680.886 ± 0.017Endoscopy (WLE+ME-NBI)Elastic net/RF0.841 ± 0.0380.731 ± 0.065 0.913 ± 0.046 0.827 ± 0.134Serology (core)Stacking0.693 ± 0.0750.493 ± 0.0730.693 ± 0.0460.586 ± 0.040Serology (extended)Random forest/Elastic net0.659 ± 0.0510.532 ± 0.0670.677 ± 0.0430.504 ± 0.067Combined (endoscopy + serology)Random forest 0.878 ± 0.051 0.749 ± 0.0400.907 ± 0.0650.886 ± 0.033Values are mean ± SD across stratified 5-fold cross-validation.AUC, area under the receiver operating characteristic curve; ME-NBI, magnifying endoscopy with narrow-band imaging; RF, random forest; WLE, white-light endoscopy.Bold values indicate the best-performing model for each feature set and task. Best-model performance per feature set in three-class and binary AIG staging tasks. Values are mean ± SD across stratified 5-fold cross-validation. AUC, area under the receiver operating characteristic curve; ME-NBI, magnifying endoscopy with narrow-band imaging; RF, random forest; WLE, white-light endoscopy. Bold values indicate the best-performing model for each feature set and task. ROC curves comparing the best models across the five feature sets. (A) Three-class task (macro-averaged). (B) Binary task (early-to-intermediate vs advanced). Feature importance and SHAP interpretability Loss of gastric folds ranked first in every endoscopy-based model. Mucosal thinning and visible submucosal vessels consistently entered the top five; sticky adherent dense mucus and swelling of the areae gastricae also contributed. In the WLE+ME-NBI binary model, CO grade and Barrett esophagus grade ranked second and third. Among serum indicators, G-17 and PGI alternated in the top two ranks across the three-class models; PGI moved to first place in the binary serology models, and the PGI/PGII ratio was strongly informative in the combined model. PCA titer, folate, and vitamin B12 had modest discriminative value. SHAP analysis (Figure 3) showed that the presence of loss of gastric folds, mucosal thinning, visible submucosal vessels, CSA, absent CO, low PGI/PGI–PGII ratio, and long-segment Barrett esophagus pushed predictions toward advanced disease, whereas mucosal edema, swelling of the areae gastricae, MCE swelling, high PGI, and low G-17 pushed predictions toward early disease. Class-specific beeswarm plots showed that Stage 1 was strongly associated with inflammation features and the absence of atrophic features; Stage 3 was strongly associated with atrophic features and long-segment Barrett esophagus; and Stage 2 showed a diffuse SHAP distribution with small-magnitude contributions in both directions, providing an interpretability-level explanation for its relatively lower classification accuracy. SHAP analyses for serology-based and combined feature sets. (A) Core serum panel. (B) Extended serum panel. (C) Combined endoscopy + serology — the best three-class model overall. Each sub-panel contains the three-class beeswarm plot, the binary beeswarm plot, and the corresponding mean(|SHAP|) bar plots. Atrophy-related features and low pepsinogen I push predictions toward advanced disease; inflammation-related features push toward early disease. Multicollinearity In the combined set (31 variables), VIFs were 8.89 for PGI and 6.89 for the PGI/PGII ratio—mechanistic, as the ratio derives from PGI—with all other VIFs <5.0. Pearson |r|>0.7 occurred only between PGI and the PGI/PGII ratio. All features were retained because the best combined model (random forest) is robust to collinear inputs. Discussion To our knowledge, this is the first machine-learning study to address within-AIG stage prediction. Across five feature sets and seven algorithms in 203 integrated-criteria patients, endoscopic features substantially outperformed serological features, combining the two modalities yielded the best three-class performance (combined macro-AUC 0.878), and the binary “advanced vs earlier” distinction was achievable from endoscopy alone (WLE+ME-NBI AUC 0.913). The cohort is among the larger Chinese AIG series to date, and nested cross-validation with leakage-controlled SMOTE provides a conservative estimate of generalization. We contextualize the principal findings below. Stage 2 as a transitional, intervention-relevant window Stage 2 was consistently the hardest class to identify—not a methodological artifact, but a biological consequence. Its phenotype combines residual early inflammation (mucosal edema, swelling of the areae gastricae) with emerging atrophy (sticky adherent mucus, CSA, partial loss of folds). SHAP distributions for Stage 2 were diffuse, with small-magnitude contributions in both directions. Mechanistically, Stage 2 corresponds to peak G-17 elevation (median 34.8 pmol/L) and maximal G-cell compensation, with the most active glandular metaplasia (17). Pseudopyloric and intestinal metaplasia are still progressing and parietal-cell injury is ongoing (18); this is the disease window in which interrupting autoimmune injury could plausibly retard progression, and any future trial of immunomodulatory therapy should prioritize Stage 2. Loss of gastric folds: a near-linear surrogate of ROM Across every endoscopy-based model, loss of gastric folds was the dominant predictor; mucosal thinning and visible submucosal vessels consistently entered the top five. Mechanistically this is expected: when oxyntic glands are lost the corpus folds lose their turgor, and once ROM falls below ~10% the folds disappear entirely. The three features therefore form a compact, reproducible endoscopic surrogate for advanced AIG that is more readily standardized than visual ROM estimation. Sticky adherent dense mucus, observed in 67.5% of Stage 3 patients and attributed to overgrowth of non–H. pylori urease-producing bacteria in the achlorhydric stomach (9), provides a further visual cue. Swelling of the areae gastricae and MCE swelling—classical inflammation signatures—declined with stage and pushed SHAP toward early disease, consistent with the deep-lamina-propria lymphocytic infiltration characteristic of early AIG (19, 20). Barrett esophagus link The most novel finding is the 66.8% prevalence of Barrett esophagus in our cohort—an order of magnitude higher than the ~7% in unselected gastroesophageal reflux disease (21)—with a clear shift from short-segment to long-segment Barrett esophagus across stages (long-segment 13.4% at Stage 1 vs 43.0% at Stage 3). The classical reflux model cannot easily explain this, because AIG progressively eliminates gastric acid (22). Two acid-independent mechanisms are plausible. First, weakened mucosal barrier function in the atrophic stomach allows duodenal bile reflux into the esophagus, producing direct chemical injury (23). Second, sustained hypergastrinemia stimulates CCK2R-positive cardiac progenitor cells to give rise to Barrett-like columnar epithelium (24). AIG combines achlorhydria with hypergastrinemia and provides an unusually favorable substrate for Barrett progression. The practical implication is that explicit esophageal evaluation should be a routine component of endoscopic follow-up in AIG. Endoscopy versus serology Serology-only models reached only AUC ~0.69 in either task (26). PGI and G-17 did not differ significantly between Stages 2 and 3, indicating an intrinsic ceiling on serological staging (25). Adding thyroid autoantibodies and hemoglobin did not improve performance and may have added noise. Combining endoscopy with the core serum panel improved the three-class task (0.878 vs 0.853) but not the binary task beyond endoscopy alone, suggesting that fine-grained staging benefits modestly from serology as an adjunct while binary advanced-disease identification can rely on endoscopy. Comparison with prior work Image-based deep-learning systems for AIG diagnosis [e.g., CorpusNet-AIG (11) and multi-site fusion models (12)] achieve diagnostic AUCs above 0.97 but address AIG-vs-non-AIG classification rather than within-AIG staging; the present work complements rather than competes with that literature. Our SHAP-based interpretability quantifies the direction and magnitude of each clinical feature’s contribution, complementing the pixel-level Grad-CAM saliency used in image-based AI. Our findings should be interpreted within the broader clinical and pathological spectrum of autoimmune gastritis and chronic gastritis (27, 28). Limitations This is a single-center, retrospective study; multicenter external validation is needed. ROM area is still observer-judged near stage cut-offs, and an objective, automated quantification method is a natural next step. We did not perform feature-by-feature histologic correlation; prospective biopsy-anchored cohorts will strengthen pathologic interpretation. Larger Stage 2 cohorts may improve fine-grained discrimination. Conclusions In 203 integrated-criteria AIG patients, machine learning provided a feasible, interpretable framework for staging within-disease severity. Endoscopic features—dominated by loss of gastric folds, mucosal thinning, and visible submucosal vessels on WLE, and by crypt-opening grade and cast-off skin appearance on ME-NBI—outperformed serological indicators. Combining endoscopy with core serum markers yielded the best three-class staging (combined macro-AUC 0.878), while endoscopy alone was sufficient for binary advanced-disease identification (WLE+ME-NBI AUC 0.913, sensitivity >0.80). Stage 2 emerged as a transitional, intervention-relevant window in which autoimmune injury is still active and glandular metaplasia is at its peak. The 66.8% prevalence of Barrett esophagus, with long-segment disease enriched 3.3-fold in advanced AIG, supports routine, explicit esophageal evaluation during AIG surveillance. After multicenter external validation, this multi-feature atlas and machine-learning workflow may inform precision surveillance and individualized clinical management of AIG, particularly for the timely initiation of neoplastic surveillance in advanced disease.