A machine learning‑enhanced serum metabolomics model for non‑invasive detection of gastric cancer Authors: Xiaoyu Ye, Jialiang Xing, Limin Niu, Shanshan Ding, Xingguo Song Published: 2026 ABSTRACT BackgroundGastric cancer (GC) is a leading cause of cancer-related deaths globally, with early detection crucial for improving survival. Current non-invasive biomarkers lack sensitivity in early stages, necessitating more accurate diagnostic tools.MethodsUntargeted metabolomics was performed on serum samples from 151 GC patients and 103 healthy controls using LC-MS. A machine learning (ML) pipeline involving LASSO regression, Random Forest, and Decision Tree was applied for feature selection and model building. Ten ML classifiers were evaluated, with final selection based on cross-validation and test-set performance. Model interpretability was assessed via SHAP analysis, and clinical utility via decision curve analysis (DCA).ResultsFrom 2136 detected metabolites, four core metabolites, including ribothymidine (rT), phytocassane B (PCB), enalapril (ENP), and sinapaldehyde (SA), were selected as a diagnostic panel. The random forest (RF) model achieved an AUC of 0.97 on the test set, significantly outperforming conventional biomarkers. Pathway analysis revealed dysregulation in lipid and amino acid metabolism. The model showed strong calibration and provided higher net clinical benefit than treat-all or treat-none strategies across a wide threshold range.ConclusionsThis study developed and internally evaluated a high-performance, metabolomics-based ML model for early GC detection using a four-metabolite serum signature. The approach provides a non-invasive and interpretable diagnostic strategy with promising clinical potential.Supplementary InformationThe online version contains supplementary material available at 10.1007/s11306-026-02460-2. Introduction Gastric cancer (GC) is the fifth most common malignancy and the third leading cause of cancer-related deaths globally (Bray et al. 2024). Notably, China bears a disproportionately heavy burden of this disease. According to recent epidemiological data, the country accounts for nearly 37% of all newly diagnosed GC cases and 39% of GC-associated deaths globally (Ferlay et al. 2024). Patient prognosis depends heavily on the disease stage at diagnosis, those detected early have a five-year survival rate of over 85%, while late-stage patients typically see rates below 30% (Chen et al. 2025). This gap highlights the urgent need for accurate, non-invasive early detection methods to improve survival and ease healthcare pressure. Metabolomics, defined as the systematic analysis of small-molecule metabolites, yields a global biochemical profile and holistic view of the metabolic state by capturing the full outcomes of gene-environment interplay. This approach offers profound insights into disease aetiology, therapeutic development and early diagnosis, and has also been broadly applied to clarify metabolic changes, discover biomarkers and locate potential therapeutic targets across various diseases (Adam et al. 2021, Huang et al. 2025, Trefny et al. 2025). Previous research has demonstrated the value of metabolomics in elucidating GC pathogenesis and identifying biomarkers for its prediction and prognosis (Chen et al. 2024, Kwon et al. 2020, Deng et al. 2012). By detecting distinct metabolic alterations in blood, urine, and gastric juice, this approach has revealed significantly dysregulated metabolites, such as amino acids and bile acids, which provide high diagnostic accuracy for early-stage tumors that are often missed by conventional serum biomarkers like carcinoembryonic antigen (CEA) and carbohydrate antigen 19 − 9 (CA19-9). For instance, a recent review reported that specific plasma inflammation-related biomarkers were associated with subsequent GC risk, suggesting their utility as predictive biomarkers (Khalili-Tanha et al. 2024). Likewise, distinct alterations in amino acid and energy metabolism-related pathways in GC patients have been reported, achieving an AUC (area under the curve) above 0.85 in distinguishing early-stage GC from non-GC participants (Xu et al. 2023). Furthermore, a targeted multi-center metabolomics analysis not only identified a sensitive 10-metabolite diagnostic signature that outperformed conventional protein markers but also developed a prognostic model that stratified patients into risk groups, offering superior guidance for postoperative interventions (Chen et al. 2024). These findings collectively underscore the significant potential of plasma metabolomics in delivering non-invasive biomarkers for the early detection and risk stratification of GC, thereby advancing precision medicine for this disease. Nonetheless, metabolomics faces significant limitations, its inherently high-dimensional, complex data causes the “curse of dimensionality” that impairs conventional statistical methods, metabolites function in elaborate, interconnected regulatory networks with nonlinear dynamic interactions beyond simple differential analyses (Xu and Fu 2022), and extracting biologically relevant, clinically applicable biomarkers from extensive datasets is highly demanding due to experimental noise, significant inter-individual variability, and batch effects (Al Zubaidi et al. 2025, Ribbenstedt et al. 2018, Roth and Powers 2022). It is precisely these constraints that create an urgent need for computational approaches capable of automatically learning from high-dimensional data to build predictive models, a niche where Machine Learning (ML) excels. As a suite of algorithms designed to automatically identify complex patterns and learn models from data without explicit programming, ML’s core capabilities directly address the field’s bottlenecks. The application of ML in metabolomics delivers value across multiple fronts. By leveraging feature selection and dimensionality reduction algorithms, ML can efficiently and automatically pinpoint the most critical feature combinations from thousands of metabolites, substantially boosting the efficiency and accuracy of biomarker discovery (Yaqoob et al. 2024). Furthermore, its powerful nonlinear models are capable of capturing complex interactions among metabolites, enabling the construction of more accurate predictive models for disease diagnosis or subtyping. Unsupervised learning methods, such as clustering and principal component analysis, further contribute by uncovering intrinsic data structures without the need for prior knowledge, potentially revealing novel metabolic patterns or patient subtypes (Franco et al. 2021, Rong et al. 2022). As a result, ML not only helps overcome the limitations of conventional analytical methods but also elevates metabolomics from a largely descriptive tool into a powerful predictive and discovery platform, profoundly advancing its applications in areas such as precision medicine and drug development. In the current study, we integrated untargeted metabolomics with ML algorithms to develop a non-invasive diagnostic model for GC. Serum samples from 151 newly diagnosed GC patients and 103 healthy controls were analyzed via liquid chromatography-mass spectrometry (LC-MS)-based metabolomics, and a novel diagnostic framework was established by combining serum metabolomics with ML-driven feature selection to identify metabolite signatures for early detection. Using a well-defined clinical cohort, we constructed an interpretable and robust model, with findings that highlight promising biomarkers and provide a practical approach for the non-invasive, accurate diagnosis of the disease. Materials and methods Patients and healthy donors A total of 151 treatment-naïve GC patients and 103 healthy controls were enrolled from Shandong Cancer Hospital Affiliated to Shandong First Medical University and Shandong Academy of Medical Sciences between January 2025 and May 2025. All GC cases were diagnosed and staged according to the 8th edition of the AJCC TNM classification. Control subjects had no known history of malignancy or gastrointestinal disorders and were deemed clinically healthy based on physician assessment and laboratory tests. This study was approved by the Ethics Committee of Shandong Cancer Hospital Affiliated to Shandong First Medical University and Shandong Academy of Medical Sciences, which granted a waiver of informed consent for the analysis of residual clinical samples remaining after routine diagnostic testing. All information obtained from patient files was treated confidentially, and no patient-identifying information was captured. Serum preparation Peripheral venous blood samples were collected in yellow-top serum-separation tubes. After clotting at room temperature for 30 min, samples were centrifuged at 3,000 × g for 10 min to obtain serum, followed by a second centrifugation at 12,000 × g for 10 min at 4 °C to remove residual cellular debris. Serum untargeted metabolite profiling Serum samples were thawed at 4 °C. Aliquots of 100 µL were mixed with 400 µL of ice-cold methanol for protein precipitation, incubated at −20 °C for 30 min, and then centrifuged at 20,000 × g for 15 min at 4 °C. The supernatant was collected for UPLC-HRMS analysis, and quality control (QC) samples were prepared by pooling equal volumes of supernatant from all samples. Metabolite separation was performed on an ACQUITY UPLC HSS T3 column (100 mm × 2.1 mm, 1.8 μm) at 40 °C, with a mobile phase of 5 mmol/L ammonium acetate/acetic acid in water (A) and acetonitrile (B). A gradient elution (2–99% B) was applied at 0.35 mL/min with 4 µL injection volume. Mass spectrometric analysis was performed on a Q-Exactive Plus instrument (Thermo Fisher Scientific, Bremen, Germany) equipped with an electrospray ionization source operating in both positive and negative modes. Key ESI parameters included spray voltages of + 3.8 kV and − 3.4 kV, and a source temperature of 350 °C. Full-scan MS data were acquired over m/z 70–1050 (resolution: 70,000), followed by data-dependent MS² scans on the top 5 ions (resolution: 17,500). Key parameters included an automatic gain control target of 3 × 10⁶, maximum injection times of 100 ms (MS) and 50 ms (MS²), and a dynamic exclusion duration of 6 s. MS data analysis and metabolic differential analysis Raw MS data were converted to mzXML format and processed using the R package XCMS for feature detection, alignment, retention time correction, and peak grouping. Total ion current (TIC) of each sample was examined for quality assessment. Subsequent annotation of isotopes and adducts was performed with CAMERA. Each feature, defined by its retention time and m/z, was quantified based on peak intensity to construct a three-dimensional data matrix. For statistical analysis, features with > 80% missing values in study samples (or > 50% in quality control (QC) samples) were removed. Missing values were imputed using the k-nearest neighbor (KNN) algorithm, and data normalization was performed by probabilistic quotient normalization (PQN). Pooled QC samples were injected every 10 runs to monitor system stability. Unsupervised analysis included principal component analysis (PCA) and hierarchical clustering heatmaps (using pheatmap and metaX), while supervised partial least squares–discriminant analysis (PLS-DA) was conducted with the ropls package to derive variable importance in projection (VIP) scores. Differential metabolites were identified using the combined criteria of q-value < 0.05, VIP ≥ 1, and fold change (FC) > 1.15 or < 0.85, and 578 metabolites were obtained. KEGG pathway enrichment of these significant metabolites was performed using a hypergeometric test with a significance threshold of P < 0.05. A secondary filtering was then applied to the 578 metabolites using stricter thresholds of q-value < 0.05, VIP ≥ 1, and FC ≥ 2 or ≤ 0.5, resulting in 131 metabolites, which were subsequently subjected to Mfuzz trend clustering and model pre-screening. Metabolite annotation and metadata Metabolite annotation was performed by searching accurate m/z values against the KEGG and HMDB databases with a mass accuracy threshold of < 10 ppm. Putative annotations were further supported by isotopic distribution patterns and MS/MS spectral matching against an in-house MS/MS database. According to the Metabolomics Standards Initiative (MSI), the four core metabolites reported in this study were classified as putatively annotated compounds (level 2). Definitive level 1 identification was not achieved, as authentic reference standards were unavailable. Supplementary Table S1 provides comprehensive annotation metadata for all 578 differential metabolites, including precursor m/z values, retention times, matched MS/MS fragments, MS2 matching scores, molecular formulae, database identifiers (HMDB/KEGG), as well as fold changes and statistical significance metrics. The four core metabolites are highlighted in the table for easy reference. Model building strategy An integrated ML framework was established, incorporating a panel of 131 differential metabolites identified for early GC detection. To mitigate collinearity and reduce redundancy among candidate predictors, a sequential feature selection strategy was adopted. Specifically, LASSO regression with 10-fold cross-validation was first applied to the 131 differential metabolites to identify a reduced set of candidate variables. Eighteen candidate metabolites were retained after LASSO screening. These candidates were then further refined by random forest (RF)-based feature ranking and decision tree (DT)-based screening, ultimately yielding four core metabolites for model construction. These metabolomic features were employed to build and optimize predictive models by systematically evaluating ten machine learning classifiers, including naïve Bayes (NB), KNN, logistic regression (LR), DT, RF, artificial neural network (ANN), Gradient-Boosting (GBDT), Light Gradient Boosting Machine (LGBM), Adaptive Boosting (AdaBoost), and Extreme Gradient Boosting (XGB). The computational implementation was carried out in Python 3.10, utilizing standardized libraries such as scikit-learn, XGB, and LGBM. The framework employed rigorous 7:3 dataset partitioning for training and testing. Hyperparameter tuning was performed on the training set using GridSearchCV with 10-fold cross-validation to minimize overfitting. Due to the inherent randomness of the tuning process, repeated runs may yield marginally different optimal hyperparameters, leading to slight variations in model outputs. Model selection followed a rigorous two-stage process to avoid subjectivity and reduce overfitting risk. In the first (quantitative pre-screening) stage, models were optimized and evaluated on the training set via cross-validation. Primary performance metrics, including mean cross-validated AUC, F1-score, accuracy, and kappa, were calculated. Models failing to meet pre-defined thresholds (e.g., mean CV AUC < 0.90, accuracy < 0.85, or a train–validation AUC discrepancy > 0.05) were excluded. In the second (graphical validation) stage, the remaining high-performing models were evaluated on the held-out test set. Final assessment was based on ROC (receiver operating characteristic) and PR (Precision-Recall) curves for discrimination and calibration plots for probability accuracy, and decision curve analysis (DCA) for clinical net benefit. No model parameters were re-tuned based on test-set results. Final model performance was comprehensively reported using AUC (with 95% CI), accuracy, sensitivity, specificity, F1-score and kappa. To enhance interpretability and clinical relevance, SHAP (SHapley Additive exPlanations) analysis was employed to elucidate feature contributions, and DCA was conducted to evaluate net clinical benefit. Statistical analysis Statistical analyses were performed using IBM SPSS Statistics 27.0.1 (IBM Corp, Armonk, NY, USA) and GraphPad Prism software 9.5 (San Diego, CA, USA). The Kolmogorov-Smirnov test was used to test the normality of the data. If normal, the unpaired t-test was used for the analysis of two groups of data and a one-way analysis of variance (ANOVA) for the analysis of multiple groups. If not, Mann-Whitney U test was used for two groups of data and the Kruskal-Wallis test for multiple groups of analysis. Two-tailed p < 0.05 was defined as statistically significant. Results Reprogrammed serum metabolic landscape in GC patients Untargeted metabolomic profiling was performed on serum samples from 151 GC patients and 103 healthy controls (HC). A total of 2,136 metabolites were detected, among which 578 showed significant differences between the two groups (q < 0.05, FC > 1.15 or < 0.85), including 316 upregulated and 262 downregulated metabolites (Fig. 1A). PCA showed an overall separation trend between GC and HC samples, indicating global metabolic differences between the two groups (Fig. 1B). To further evaluate group discrimination under a supervised framework, PLS-DA and permutation testing were performed, and the corresponding results are presented in Fig. S1. KEGG pathway enrichment analysis identified 20 significantly enriched pathways (Fig. 1C), primarily involved in linoleic acid metabolism, arachidonic acid metabolism, phenylalanine metabolism, PPAR signaling, and steroid hormone biosynthesis. These findings reflect perturbations in lipid and amino acid metabolism associated with GC. A hierarchical clustering heatmap of the top 20 and the 92nd metabolites further demonstrated distinct metabolic patterns between GC and HC (Fig. 1D). To refine candidate biomarkers for subsequent model construction and to characterize their dynamic patterns across disease stages, 131 metabolites meeting the criteria of q < 0.05, VIP ≥ 1, and FC ≥ 2 or ≤ 0.5 were selected for Mfuzz clustering analysis. This analysis delineated four distinct temporal clusters (Clusters 1–4) (Fig. 1E). A four-cluster solution was adopted because the overall trajectories could be summarized into four representative patterns, whereas larger cluster numbers produced largely redundant subpatterns and reduced interpretability. Fig. 1Identification of differential serum metabolites and pathway enrichment analysis in gastric cancer. A Volcano plot illustrating all detected metabolites, including 578 significant differential metabolites (316 upregulated, 262 downregulated); B PCA score plot showing the overall distribution and partial separation of GC and HC samples; C KEGG enrichment bubble plot of the top 20 significantly enriched metabolic pathways derived from the 578 differential metabolites; D Heatmap of the significantly altered metabolites between GC (n = 151) and HC (n = 103); E Mfuzz clustering plots of 131 differential metabolites grouped into four representative temporal clusters across HC and GC stages I–IV. PCA: principal component analysis; GC: gastric cancer patients; HC: healthy controls; KEGG: Kyoto Encyclopedia of Genes and Genomes Identification of differential serum metabolites and pathway enrichment analysis in gastric cancer. A Volcano plot illustrating all detected metabolites, including 578 significant differential metabolites (316 upregulated, 262 downregulated); B PCA score plot showing the overall distribution and partial separation of GC and HC samples; C KEGG enrichment bubble plot of the top 20 significantly enriched metabolic pathways derived from the 578 differential metabolites; D Heatmap of the significantly altered metabolites between GC (n = 151) and HC (n = 103); E Mfuzz clustering plots of 131 differential metabolites grouped into four representative temporal clusters across HC and GC stages I–IV. PCA: principal component analysis; GC: gastric cancer patients; HC: healthy controls; KEGG: Kyoto Encyclopedia of Genes and Genomes ML-based screening and diagnostic evaluation of serum metabolite biomarkers The analytical workflow of the study is summarized in Fig. 2. A total of 131 differential metabolites identified above were subsequently subjected to a multi-step feature selection process. The features were initially reduced to 18 candidate metabolites by LASSO regression (Fig. 3A and B). The top 10 features were then ranked by RF analysis based on mean decrease in accuracy. Finally, four core metabolites, ribothymidine (rT), phytocassane B (PCB), enalapril (ENP), and sinapaldehyde (SA), were selected by a decision tree model for model development (Fig. 3C and D). Specifically, ENP was assigned to Cluster 1, which showed a progressive decline across GC stages, whereas rT belonged to Cluster 2, characterized by an early sharp decrease followed by sustained low abundance. In contrast, PCB and SA were both assigned to Cluster 3, which displayed an overall upward trend across disease stages, as represented in Fig. 1E. Association of four selected metabolites with clinicopathological characteristics in GC patients was demonstrated in Table 1. No statistical significance was observed. Fig. 2Overall workflow of metabolomics-based biomarker selection and diagnostic model construction Overall workflow of metabolomics-based biomarker selection and diagnostic model construction Fig. 3Feature selection and diagnostic evaluation of candidate serum metabolites for gastric cancer. A-D Feature selection via LASSO regression (A, B), RF (C) and DT (D) for key predictors in intracranial infection ML model. E Box plots comparing the serum levels of selected metabolites between GC and HC; F ROC curves assessing the diagnostic performance of individual metabolites. RF: random forest; DT: decision tree; ROC: receiver operating characteristic Feature selection and diagnostic evaluation of candidate serum metabolites for gastric cancer. A-D Feature selection via LASSO regression (A, B), RF (C) and DT (D) for key predictors in intracranial infection ML model. E Box plots comparing the serum levels of selected metabolites between GC and HC; F ROC curves assessing the diagnostic performance of individual metabolites. RF: random forest; DT: decision tree; ROC: receiver operating characteristic Table 1Association of four selected metabolites with clinicopathological characteristics in patients with gastric cancerCharacteristicsrTPCBENPSACase No.P valueCase No.P valueCase No.P valueCase No.P valueAge≤ 6240/380.80937/410.46245/330.06137/410.571> 6236/3739/3431/4238/35SexFemale20/170.60223/140.09819/180.88623/140.080Male56/5853/6157/5752/62T stageT1–221/180.50518/210.72117/220.25117/220.403T3–449/5451/5256/4753/50Lymph node metastasisN014/190.42015/180.68314/190.31816/170.917N1–353/5252/5355/5052/53DistantmetastasisM042/480.25442/480.86043/470.12143/470.815M123/1718/2225/1520/20TNM stageI–II18/260.13820/240.44227/170.08225/190.260III–IV58/4956/5149/5850/57Data are presented as Low/High counts. Chi-square test was used for comparisons. Cases with missing data were excluded from the corresponding analyses Table 1Association of four selected metabolites with clinicopathological characteristics in patients with gastric cancerCharacteristicsrTPCBENPSACase No.P valueCase No.P valueCase No.P valueCase No.P valueAge≤ 6240/380.80937/410.46245/330.06137/410.571> 6236/3739/3431/4238/35SexFemale20/170.60223/140.09819/180.88623/140.080Male56/5853/6157/5752/62T stageT1–221/180.50518/210.72117/220.25117/220.403T3–449/5451/5256/4753/50Lymph node metastasisN014/190.42015/180.68314/190.31816/170.917N1–353/5252/5355/5052/53DistantmetastasisM042/480.25442/480.86043/470.12143/470.815M123/1718/2225/1520/20TNM stageI–II18/260.13820/240.44227/170.08225/190.260III–IV58/4956/5149/5850/57Data are presented as Low/High counts. Chi-square test was used for comparisons. Cases with missing data were excluded from the corresponding analyses Association of four selected metabolites with clinicopathological characteristics in patients with gastric cancer Distant metastasis Data are presented as Low/High counts. Chi-square test was used for comparisons. Cases with missing data were excluded from the corresponding analyses Metabolomic analysis showed that serum levels of these four metabolites were significantly dysregulated in GC patients compared to HC. Specifically, rT and ENP levels were decreased, while PCB and SA levels were elevated in the GC group (Fig. 3E). We further evaluated the diagnostic performance of these differential metabolites using ROC curve analysis, revealing that PCB exhibited the highest diagnostic accuracy with an AUC of 0.8809, followed by a metabolite abbreviated as ENP with an AUC of 0.8304, then rT with a moderate AUC of 0.7873, and SA with an AUC of 0.7833 (Fig. 3F), indicating their potential utility as biomarkers for discriminating GC patients from healthy individuals. Development and comparative performance of ML models Based on the four core metabolites, we evaluated ten machine learning algorithms using a training set (70%) and a held-out test set (30%) (Fig. 4A). To develop a robust predictive model, we initially evaluated 10 ML algorithms on the training set using cross-validation. Models with cross-validation ROC-AUC (CV/AUC) ≥ 0.97 were retained, resulting in six candidates: LR, RF, GBDT, XGB, LGBM, and AdaBoost (Fig. 4A-B). These six candidate models were then evaluated on the held‑out test set using multiple metrics, including test ROC-AUC (Test/AUC) (Fig. 4C), precision-recall AUC (PR-AUC) (Fig. 4D), F1-score, and kappa. The performance metrics, including accuracy, sensitivity, specificity, positive and negative precision, F1 score, kappa, and AUC with 95% confidence intervals, are presented in Table 2. Fig. 4Comparative evaluation and selection of machine learning models for gastric cancer diagnosis. A Workflow illustrating the two-stage model selection strategy; B ROC curves of multiple ML algorithms in the training cohort; C ROC curves of the retained ML in the test cohort; D PR curves comparing model performance under class imbalance in the test cohort; E Bar plots summarizing normalized cross-validation AUC and test-set performance scores for different machine learning classifiers. ML: machine learning; PR: precision-recall Comparative evaluation and selection of machine learning models for gastric cancer diagnosis. A Workflow illustrating the two-stage model selection strategy; B ROC curves of multiple ML algorithms in the training cohort; C ROC curves of the retained ML in the test cohort; D PR curves comparing model performance under class imbalance in the test cohort; E Bar plots summarizing normalized cross-validation AUC and test-set performance scores for different machine learning classifiers. ML: machine learning; PR: precision-recall Table 2Performance of 10 ML algorithms in diagnosing GCDataKindModelsoptimal_thresholdAccuracySensitivitySpecificityPositive PrecisionNegative PrecisionF1_scorekappaAUCAUC 95% CITrainingNB1.00000.40680.00001.00000.00000.40680.23520.00000.88830.8413–0.9293KNN0.50000.90400.84760.98610.98890.81610.90480.80730.98460.9707–0.9951LR0.48550.94350.94290.94440.96120.91890.94360.88340.98470.9693–0.9964RF0.60950.96610.96190.97220.98060.94590.96620.93010.99630.9908–0.9996DT0.71430.94350.90481.00001.00000.87800.94390.88540.99740.9938–0.9996ANN1.00000.40680.00001.00000.00000.40680.23520.00000.90520.8664–0.9434GBDT0.95130.99440.99051.00001.00000.98630.99440.98831.00001.0000–1.0000LGBM0.51900.98870.99050.98610.99050.98610.98870.97660.99970.9984–1.0000XGB0.76680.99440.99051.00001.00000.98630.99440.98831.00001.0000–1.0000AdaBoost0.53050.99440.99051.00001.00000.98630.99440.98831.00001.0000–1.0000TestNB1.00000.40260.00001.00000.00000.40260.23110.00000.84780.7826–0.9100KNN0.50000.89610.82611.00001.00000.79490.89710.79270.96140.9110–0.9931LR0.35180.89610.93480.83870.89580.89660.89550.78170.96420.9252–0.9907RF0.62140.88310.86960.90320.93020.82350.88380.76080.96560.9271–0.9918DT1.00000.40260.00001.00000.00000.40260.23110.00000.90670.8457–0.9686ANN1.00000.40260.00001.00000.00000.40260.23110.00000.86990.7942–0.9412GBDT0.78610.87010.84780.90320.92860.80000.87110.73560.96000.9178–0.9885LGBM0.15210.88310.93480.80650.87760.89290.88200.75310.96280.9176–0.9913XGB0.39680.89610.91300.87100.91300.87100.89610.78400.95370.9039–0.9894AdaBoost0.52850.87010.80430.96770.97370.76920.87140.74090.96630.9291–0.9930 Table 2Performance of 10 ML algorithms in diagnosing GCDataKindModelsoptimal_thresholdAccuracySensitivitySpecificityPositive PrecisionNegative PrecisionF1_scorekappaAUCAUC 95% CITrainingNB1.00000.40680.00001.00000.00000.40680.23520.00000.88830.8413–0.9293KNN0.50000.90400.84760.98610.98890.81610.90480.80730.98460.9707–0.9951LR0.48550.94350.94290.94440.96120.91890.94360.88340.98470.9693–0.9964RF0.60950.96610.96190.97220.98060.94590.96620.93010.99630.9908–0.9996DT0.71430.94350.90481.00001.00000.87800.94390.88540.99740.9938–0.9996ANN1.00000.40680.00001.00000.00000.40680.23520.00000.90520.8664–0.9434GBDT0.95130.99440.99051.00001.00000.98630.99440.98831.00001.0000–1.0000LGBM0.51900.98870.99050.98610.99050.98610.98870.97660.99970.9984–1.0000XGB0.76680.99440.99051.00001.00000.98630.99440.98831.00001.0000–1.0000AdaBoost0.53050.99440.99051.00001.00000.98630.99440.98831.00001.0000–1.0000TestNB1.00000.40260.00001.00000.00000.40260.23110.00000.84780.7826–0.9100KNN0.50000.89610.82611.00001.00000.79490.89710.79270.96140.9110–0.9931LR0.35180.89610.93480.83870.89580.89660.89550.78170.96420.9252–0.9907RF0.62140.88310.86960.90320.93020.82350.88380.76080.96560.9271–0.9918DT1.00000.40260.00001.00000.00000.40260.23110.00000.90670.8457–0.9686ANN1.00000.40260.00001.00000.00000.40260.23110.00000.86990.7942–0.9412GBDT0.78610.87010.84780.90320.92860.80000.87110.73560.96000.9178–0.9885LGBM0.15210.88310.93480.80650.87760.89290.88200.75310.96280.9176–0.9913XGB0.39680.89610.91300.87100.91300.87100.89610.78400.95370.9039–0.9894AdaBoost0.52850.87010.80430.96770.97370.76920.87140.74090.96630.9291–0.9930 Performance of 10 ML algorithms in diagnosing GC To objectively compare the models and select the final candidate, we employed a weighted composite scoring strategy (Makarious et al. 2022), as illustrated in Fig. 4E. First, each test-set metrics were normalized across the six retained models using min-max scaling:\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\:{X}_{norm}=\frac{X-{X}_{min}}{{\mathrm{X}}_{max}-{X}_{min}}$$\end{document} A Test Score was then computed as a weighted combination of the normalized metrics using subjective weighting. Weights were assigned based on diagnostic needs. AUC, which measures discriminative ability across thresholds and handles class imbalance, is most important (weight 0.35). Precision (PR) is weighted 0.25 for its value when positives are rare. F1 and Kappa are equally weighted at 0.20 each:\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$ \begin{gathered} TestScore = 0.35 \times \:Test/AUC_{{norm}} + 0.25 \hfill \\ \times \:PR_{{norm}} + 0.20 \times \:F1_{{norm}} + 0.20 \times \:Kappa_{{norm}} \hfill \\ \end{gathered} $$\end{document} Optionally, a Composite Score integrating cross-validation stability and test performance was derived as:\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\:\mathrm{C}\mathrm{o}\mathrm{m}\mathrm{p}\mathrm{o}\mathrm{s}\mathrm{i}\mathrm{t}\mathrm{e}\:\mathrm{s}\mathrm{c}\mathrm{o}\mathrm{r}\mathrm{e}=0.30\times\:CV/AUC+0.70\times\:TestScore$$\end{document} Based on this scoring framework, RF achieved the highest composite score, with a test-set ROC-AUC of 0.97, cross-validation AUC of 0.97, and an average precision (AP) of 0.9760 (95% CI: 0.9474–0.9943) (Fig. 4B-D). Given its superior balance between predictive performance, computational efficiency, and stability across validation phases, RF was selected as the final model for subsequent analyses. RF model performance and interpretability Following the comparative evaluation of the six candidate models using the weighted composite scoring strategy, RF was selected as the final predictive model. The model demonstrated excellent discriminative performance, achieving a ROC‑AUC of 0.97 on the held‑out test set (Fig. 5A). Furthermore, its probability estimates were well‑calibrated, with predictions closely aligning with observed outcomes (Fig. 5B), indicating high reliability and suitability for decision‑support applications. The model also maintained strong precision‑recall performance under conditions of class imbalance (Fig. 5C). Fig. 5Evaluation and interpretability of the final RF model for gastric cancer detection. A ROC curve of the RF model, demonstrating excellent discriminative performance; B Calibration curve showing close agreement between predicted probabilities and observed outcomes; C PR curve confirming robust model performance under class imbalance; D DCA illustrating substantial net clinical benefit of the RF model across a wide range of threshold probabilities compared with treat-all and treat-none strategies; E SHAP summary plot illustrating the contributions of the four core metabolites to the RF model predictions. DCA: decision curve analysis; SHAP: SHapley Additive exPlanations Evaluation and interpretability of the final RF model for gastric cancer detection. A ROC curve of the RF model, demonstrating excellent discriminative performance; B Calibration curve showing close agreement between predicted probabilities and observed outcomes; C PR curve confirming robust model performance under class imbalance; D DCA illustrating substantial net clinical benefit of the RF model across a wide range of threshold probabilities compared with treat-all and treat-none strategies; E SHAP summary plot illustrating the contributions of the four core metabolites to the RF model predictions. DCA: decision curve analysis; SHAP: SHapley Additive exPlanations We further assessed the clinical utility of the model through decision curve analysis (DCA) (Fig. 5D). The results indicated that the RF model provides greater net benefit across a wide range of probability thresholds compared to strategies of treating all or no patients, suggesting potential clinical utility within this cohort. To elucidate the underlying decision logic, SHAP (SHapley Additive exPlanations) analysis was performed (Fig. 5E). This analysis identified PCB, ENP, SA and rT as the most influential features, offering a transparent and interpretable framework for understanding how the model integrates multiple inputs to generate individual predictions. Discussion GC remains a global health challenge, particularly in high-incidence regions such as China, where late diagnosis significantly contributes to poor patient outcomes. This study integrated untargeted serum metabolomics with machine learning to develop and internally evaluate a non-invasive, metabolite-based diagnostic model for the early detection of GC. Leveraging a clinical cohort comprising 151 newly diagnosed GC patients and 103 HC, we identified a panel of four metabolites, including rT, PCB, ENP, and SA, that effectively discriminates GC patients from healthy individuals, with the optimized RF model achieving an AUC of 0.97 on the held-out test set. Our findings demonstrate that systemic metabolic reprogramming in GC can be captured through metabolomic profiling, and ML-driven feature selection enables the identification of a concise yet powerful metabolite signature for accurate early detection. The analytical workflow was designed to address several inherent challenges in metabolomics-based biomarker discovery, including high dimensionality, data noise, and complex metabolite interactions (Al Zubaidi et al. 2025, Ribbenstedt et al. 2018, Roth and Powers 2022). By employing a sequential feature selection strategy that integrated LASSO regression, RF, and DT algorithms, we effectively narrowed down the initial panel of differentially expressed metabolites to a concise yet informative set of four biomarkers (Vaida et al. 2024). This approach not only enhanced model interpretability but also reduced the risk of overfitting, a common concern in high-dimensional data modeling (Vaida et al. 2024, Teixeira et al. 2024). Furthermore, a weighted composite scoring system was used for model selection, ensuring that the final RF model was selected based on a balanced evaluation of cross-validation stability and held-out test-set performance. To enhance clinical transparency, SHAP analysis was applied to interpret the contribution of each metabolite to model predictions, identifying PCB, ENP, SA and rT as the most influential features (Ali et al. 2023, Sumon et al. 2024). Such interpretability may help improve clinician confidence and support the future translation of computational models into practical diagnostic tools (Ali et al. 2023). From a biological perspective, the identified metabolites participate in diverse physiological processes potentially linked to gastric carcinogenesis (Rong et al. 2025). rT, a modified nucleoside, may reflect alterations in RNA metabolism or mitochondrial function, both frequently dysregulated in cancer. PCB, a phytoalexin commonly found in plants, has been seldom reported in human metabolic studies of GC; its elevation in patient serum could suggest dietary influences, microbial metabolism, or a stress-related response (Noerman and Landberg 2023). ENP, an angiotensin-converting enzyme inhibitor typically used to treat hypertension, was significantly reduced in GC patients, possibly indicating dysregulation of the renin-angiotensin system, which has been implicated in tumor angiogenesis and microenvironment remodeling (Li et al. 2022). SA, a phenylpropanoid with anti-inflammatory properties, may reflect oxidative stress or disturbances in phenylalanine metabolism, a pathway also highlighted in our pathway enrichment analysis (McMahon et al. 2025). Consistent with previous reports, our metabolic pathway analysis revealed significant alterations in lipid-related pathways such as linoleic acid and arachidonic acid metabolism, reinforcing the notion that metabolic reprogramming is a hallmark of early GC (Jin et al. 2023). When compared with existing diagnostic approaches, the metabolite panel identified in this study appears to offer several advantages. Unlike conventional protein biomarkers such as CEA and CA19-9, which often lack sensitivity in early-stage disease, or routine biochemical parameters that reflect broad systemic metabolic states with limited specificity for gastric carcinogenesis, our metabolomics-driven signature captures tumor-specific biochemical pathways with higher discriminatory power (Shimada et al. 2014). Interestingly, the incremental contribution of traditional biochemical parameters including ALT, AST, total protein, albumin, bilirubin, GGT to model performance appears limited (data not shown), likely because their variations are indirectly embedded within the broader metabolic networks already captured through our untargeted metabolomics approach. DCA further suggests the potential clinical utility of our model within this cohort, indicating that it may provide net benefit across a range of probability thresholds (Calster et al. 2018). Nevertheless, practical implementation would require careful consideration of factors such as cost, analytical throughput, and seamless integration into existing clinical workflows. Despite the encouraging results, several limitations should be acknowledged. The sample cohort was derived from a single center, which may affect the generalizability of the findings. External validation using multi-center and ethnically diverse populations is necessary to confirm the robustness and broad applicability of the model. Additionally, while untargeted metabolomics provides a broad survey of metabolic changes, the identification of certain metabolites, particularly PCB and SA, remains putative without confirmation using authentic chemical standards. Targeted quantification methods would strengthen the verification of these candidates as reliable biomarkers. The case-control design also limits our ability to establish temporal causality; prospective longitudinal studies are needed to evaluate whether these metabolic changes precede clinical diagnosis. In conclusion, our study shows that integrating untargeted serum metabolomics with RF can support the development of a non-invasive diagnostic model for GC. The four-metabolite signature (rT, PCB, ENP, SA) and the RF model outperformed conventional biomarkers in this cohort and provided an interpretable framework for early GC discrimination. Future work should focus on multi-center validation, prospective evaluation, and mechanistic studies to further assess the clinical potential of these findings. Supplementary Information Below is the link to the electronic supplementary material. Supplementary Material 1 Supplementary Material 1 Supplementary Material 2 Supplementary Material 2