Gastric retention risk prediction system based on machine learning model and construction method thereof

By constructing a machine learning model based on the extreme gradient boosting algorithm and integrating 12 key predictive factors, the problem of low accuracy in predicting the risk of gastric retention in existing technologies has been solved. This enables individualized quantitative prediction and interpretable analysis, thereby improving the ability to identify and prevent the risk of gastric retention.

CN122117418APending Publication Date: 2026-05-29THE FIRST AFFILIATED HOSPITAL OF XIAMEN UNIV

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
THE FIRST AFFILIATED HOSPITAL OF XIAMEN UNIV
Filing Date
2026-04-28
Publication Date
2026-05-29

AI Technical Summary

Technical Problem

Existing technologies cannot effectively integrate multi-dimensional clinical data, resulting in low accuracy in predicting the risk of gastric retention and a lack of individualized assessment capabilities. This makes it difficult to identify high-risk groups and implement precise preventive interventions, increasing the risk of aspiration, aspiration pneumonia, and other complications.

Method used

A machine learning model based on the extreme gradient boosting algorithm is constructed, which automatically learns nonlinear relationships using 12 key predictors, outputs individualized gastric retention risk prediction results, and provides decision-making basis by combining interpretability analysis technology.

Benefits of technology

It enables individualized quantitative prediction of the risk of gastric retention before gastroscopy, improves prediction accuracy and stability, provides a reliable basis for clinical decision-making, reduces data collection costs, and enhances the effectiveness of preventive measures.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122117418A_ABST
    Figure CN122117418A_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of medical information technology and clinical risk prediction, in particular to a gastric retention risk prediction system based on a machine learning model and a construction method thereof, the system comprising a data acquisition module, a feature processing module and a risk prediction module, wherein the feature processing module is based on 12 clinical features screened by LASSO regression, and the risk prediction module adopts an extreme gradient boosting model constructed by an SMOTE enhanced training queue to output a gastric retention risk probability value; the present application integrates 12 key features collected by clinical routine, and introduces a SHAP algorithm to realize visualized explanation of the model decision process, thereby providing a precise and interpretable individualized risk assessment tool before gastroscopy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of medical information technology and clinical risk prediction technology, and in particular to a gastric retention risk prediction system based on machine learning models and its construction method. Background Technology

[0002] Gastric retention (GR) is a clinically significant condition characterized by delayed food emptying and can be diagnosed via gastroscopy. Although fasting for 6-8 hours prior to gastroscopy is routine, some patients still fail to achieve the desired outcome. Previous studies have shown that patients with diabetes and those with a history of gastrointestinal surgery are more prone to GR. Patients with GR face a higher risk of aspiration, which can lead to pneumonia or even suffocation, especially during gastroscopy under anesthesia. Furthermore, traditional risk stratification methods lack precision in identifying high-risk populations, particularly those with heterogeneous metabolic characteristics or those using multiple medications. There is an urgent need for predictive tools that integrate multivariate clinical data to achieve early risk stratification and personalized management.

[0003] First, traditional risk stratification methods rely heavily on the subjective experience of clinicians, failing to objectively and accurately integrate multidimensional clinical information about patients. This is especially true when dealing with patients with heterogeneous metabolic characteristics or those using multiple drugs, where the accuracy in identifying high-risk individuals is severely insufficient. Second, existing technologies are mostly qualitative assessments based on single indicators or a few factors, making it difficult to capture the complex nonlinear interactions between multiple risk factors and their combined impact on the occurrence of gastric retention. In clinical practice, patients often have multiple underlying diseases (such as diabetes and thyroid disease), a history of multiple medications (such as anticholinergic drugs and analgesics), and varying degrees of abnormal laboratory indicators (such as hypoalbuminemia and hypokalemia). The combined effect of these factors is far more than a simple additive effect. Current technology lacks effective analytical methods to integrate these multidimensional heterogeneous data, resulting in low accuracy of risk assessment and an inability to achieve effective early warning and personalized intervention. This problem makes it difficult to accurately identify high-risk patients for gastric retention in clinical practice, thus preventing the timely implementation of preventive measures such as extending fasting time and adjusting medication regimens. This increases the risk of serious complications such as aspiration, aspiration pneumonia, and even suffocation.

[0004] Therefore, in response to the problems mentioned above, this invention proposes a gastric retention risk prediction system based on a machine learning model and its construction method. Summary of the Invention

[0005] To overcome the problems of low accuracy and lack of individualized assessment capabilities in the prediction of gastric retention risk due to the inability to effectively integrate multi-dimensional clinical data of patients, thus hindering the implementation of precise preventive interventions, this invention proposes a gastric retention risk prediction system based on a machine learning model and its construction method. This system constructs and trains a machine learning model based on an extreme gradient boosting algorithm. This model takes multiple key predictive factors selected from patients' routine clinical data as input, automatically learns and quantifies the complex nonlinear relationship between each predictive factor and the risk of gastric retention, and finally outputs an individualized prediction result of gastric retention risk. Combined with interpretability analysis technology, it provides a basis for decision-making, thereby achieving high-precision and individualized prediction of gastric retention risk.

[0006] The technical solution of this invention is: a gastric retention risk prediction system based on a machine learning model, comprising: The data acquisition module is used to acquire the clinical data of the target object. The clinical data includes at least the following 12 features, specifically: use of anticholinergic drugs, pyloric obstruction, use of analgesics, prevalence of systemic diseases, history of gastrointestinal surgery, symptoms of indigestion, intestinal obstruction, hypoproteinemia indicators, body mass index, use of antihistamines, prevalence of diabetes, and hypokalemia indicators. The feature processing module is used to input clinical data into a pre-trained extreme gradient boosting model. The extreme gradient boosting model is constructed using a training queue enhanced by synthetic minority class oversampling technology, and 12 features are selected from the original clinical features through LASSO regression. The risk prediction module is used to run the extreme gradient boosting model and output the probability value of gastric retention risk. The extreme gradient boosting model achieved an area under the receiver operating characteristic (AUC) of 0.710 in the independent validation cohort and an AUC of 0.806 in the SMOTE boosted training cohort.

[0007] This invention provides a method for constructing a gastric retention risk prediction system based on a machine learning model, comprising the following steps: S1. Collect clinical data of patients undergoing gastroscopy, divide patients into gastric retention group and non-gastric retention group according to the gastroscopy results, and exclude cases with incomplete data. The clinical data includes demographic data, surgical history, laboratory data and medication history. S2, uses synthetic minority class oversampling technology to oversample the gastric retention group samples in the training queue, and constructs a balanced SMOTE enhanced training queue; S3, on the SMOTE enhanced training cohort, LASSO regression was used for feature selection, and the optimal regularization parameter λ was determined by 10-fold cross-validation to screen out 12 key clinical features that are significantly related to gastric retention. S4, based on 12 selected key clinical features, constructs various machine learning models, including logistic regression, decision tree, random forest, support vector machine, extreme gradient boosting, lightweight gradient boosting machine, K-nearest neighbors, Naive Bayes and artificial neural network, and uses SMOTE augmented training queue for training. S5. The performance of each model is evaluated in an independent validation queue. Evaluation metrics include area under the receiver operating characteristic curve, accuracy, sensitivity, specificity, positive predictive value, negative predictive value, calibration curve and decision curve analysis, and the extreme gradient boosting model is selected as the optimal prediction model. S6 uses the SHapley Additive exPlanations algorithm to interpret the optimal extreme gradient boosting model, and outputs the ranking and visualization analysis results of the contribution of each feature to the prediction results.

[0008] Preferably, in step S3, the optimal regularization parameter λ for LASSO regression is 0.014, and the corresponding log(λ) value is -4.243; the 12 key clinical features selected include anticholinergic drug use, pyloric obstruction, analgesic use, systemic disease, history of gastrointestinal surgery, indigestion, intestinal obstruction, hypoproteinemia, BMI, antihistamine use, diabetes, and hypokalemia.

[0009] Preferably, in step S5, the area under the receiver operating characteristic (AUC) of the extreme gradient boosting model in the SMOTE boosting training cohort is 0.806, and the accuracy is 0.691; the AUC in the independent validation cohort is 0.710; and after 10-fold cross-validation, the average AUC of the extreme gradient boosting model is 0.766±0.019, and the average accuracy is 0.691±0.019.

[0010] Preferably, in step S6, the output of the SHapley Additive exPlanations algorithm shows that the use of anticholinergic drugs has the greatest impact on the model prediction results, followed by pyloric obstruction, analgesic use, systemic diseases, and a history of gastrointestinal surgery. The use or presence of the above features is associated with a higher risk of gastric retention.

[0011] The beneficial effects of this invention are: 1. This invention enables individualized quantitative prediction of the risk of gastric retention before gastroscopy. By integrating 12 clinically routinely collected features and constructing an extreme gradient enhancement model, it upgrades the traditional qualitative assessment that relies on fasting time and diabetes history to a precise prediction of continuous risk probability values, filling the technical gap in the field of quantitative prediction tools.

[0012] 2. The extreme gradient boosting model constructed in this invention achieved an area under the receiver operating characteristic (ROC) curve of 0.710 and a sensitivity of 0.708 in an independent validation cohort. After 10-fold cross-validation, the average ROC curve area was 0.766 ± 0.019. Simultaneously, calibration curve and decision curve analysis confirmed that it has good calibration and clinical net benefit, significantly outperforming eight other machine learning models such as logistic regression and decision trees, demonstrating good predictive stability and clinical applicability.

[0013] 3. This invention innovatively introduces the SHapley Additive exPlanations interpretability algorithm into the field of gastric retention risk prediction. It visually reveals the contribution of each feature to the prediction results through bar charts, bee colony diagrams, force-directed diagrams, and waterfall diagrams, and clarifies key risk factors such as anticholinergic drug use, pyloric obstruction, and analgesic use, providing clinicians with a reliable basis for decision-making.

[0014] 4. This invention uses LASSO regression to scientifically screen 12 key predictive factors from 45 initial clinical features. These features are all routinely collected clinical data that do not require additional testing. While ensuring predictive performance, it significantly reduces data collection costs and clinical implementation thresholds, making the system clinically feasible and valuable for promotion. Attached Figure Description

[0015] Figure 1 The diagram shown is a schematic representation of the system framework of the present invention. Figure 2 The diagram shown illustrates the data acquisition and preprocessing process of this invention. Figure 3 The diagram shown illustrates the feature screening and category balancing process of this invention. Figure 4 The diagram shown is a schematic representation of the feature selection process of this invention. Figure 5 The diagram shown illustrates the feature selection results using lasso regression according to the present invention. Figure 6 The diagram shown illustrates the model evaluation and selection process of this invention. Figure 7 The diagram shown is a schematic representation of the subject operating characteristic curve of the present invention. Figure 8The diagram illustrates the performance of different machine learning models of this invention. Figure 9 The diagram shown is a schematic representation of the decision curve of this invention; Figure 10 The diagram shown is a schematic representation of the model explanation process of this invention; Figure 11 The image shown is a bee colony diagram of the present invention; Figure 12 The bar chart shown presents the feature importance of the present invention; Figure 13 The diagram shown is a force-directed diagram and a waterfall diagram of the present invention. Detailed Implementation

[0016] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are some embodiments of the present invention, but not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0017] Please see Figure 1 This invention provides an embodiment of a gastric retention risk prediction system based on a machine learning model, comprising: The data acquisition module, serving as the system's input, is used to acquire clinical data from the target object. This module supports multiple data access methods, including interface calls with the hospital information system, manual data entry, and batch data import functionality. In implementation, the data acquisition module first performs integrity verification on the input data to ensure that the acquired clinical data contains the 12 key feature fields necessary for this invention. For missing values, the module employs multiple imputation methods to fill in the gaps, ensuring that the data quality meets the requirements for subsequent analysis.

[0018] The feature processing module, connected to the data acquisition module, receives and standardizes raw clinical data. This module integrates feature engineering components, enabling automatic identification and extraction of 12 key features, including anticholinergic drug use, pyloric obstruction status, analgesic use, systemic disease prevalence, gastrointestinal surgery history, dyspepsia symptoms, intestinal obstruction status, hypoalbuminemia indicators, body mass index (BMI), antihistamine use, diabetes prevalence, and hypokalemia indicators. The feature processing module converts these features into numerical values ​​according to predefined encoding rules. For example, binary variables (such as anticholinergic drug use) are encoded as 0 or 1, while continuous variables (such as BMI) retain their original values ​​and undergo standardization. After feature extraction and encoding, the feature processing module inputs the processed feature vectors into a pre-trained extreme gradient boosting model.

[0019] The risk prediction module runs the Extreme Gradient Boosting (XGBoost) model. This module loads a pre-trained and saved model file, receives the feature vector output from the feature processing module as input, and calculates the gastric retention risk probability value through forward propagation of the model. The risk probability value ranges from 0 to 1, representing the likelihood of gastric retention in the target individual. The risk prediction module also includes a risk stratification function, classifying the prediction results into low-risk, medium-risk, and high-risk levels based on preset thresholds, and presenting them to clinicians in a visual manner. In this embodiment, the output interface of the risk prediction module includes the risk probability value, risk level label, and a ranking of the main risk factors affecting the prediction result, facilitating clinicians' quick understanding of the prediction basis and the development of personalized intervention strategies. It also includes a model interpretation unit, which uses the Shapley additive interpretation algorithm. Based on the trained Extreme Gradient Boosting model, it calculates and visualizes the contribution of each input feature to the risk probability value, thereby generating an individualized risk interpretation report. This individualized risk interpretation report includes feature importance bar charts, beehive plots, and force-directed plots and waterfall plots for individual patients.

[0020] The risk stratification and intervention recommendation module is used to compare the risk probability value output by the risk prediction module with the preset threshold, divide the target object into a high-risk group, a medium-risk group, or a low-risk group, and output corresponding preoperative management recommendations based on the grouping results. The preoperative management recommendations include extending the fasting program, using prokinetic drugs, adjusting the strategy of using anticholinergic or analgesic drugs, or arranging the gastroscopy examination as the first procedure of the day.

[0021] The model update module is used to periodically collect data on newly diagnosed patients with gastric retention and their corresponding clinical outcomes, and to perform incremental learning or periodic retraining on the currently deployed extreme gradient boosting model in order to optimize the model's predictive performance.

[0022] Furthermore, the present invention provides an embodiment to illustrate the construction method of the present invention, specifically: Please see Figure 2 S1, This invention employs a retrospective cohort study design, with data sourced from a hospital endoscopy center database. In the implementation, a database of a university-affiliated First Hospital was searched, including patients diagnosed with gastric retention by gastroscopy between January 2022 and December 2024, and non-gastric retention patients who underwent gastroscopy between June 2024 and December 2024. All patients undergoing gastroscopy were prepared according to a standard fasting protocol, i.e., fasting for 6 to 8 hours before the examination.

[0023] The diagnostic criteria for gastric retention are as follows: a gastric residual volume of at least 6.3% after a 4-hour fast, or unexpected food residue observed during gastroscopy after an 8-hour fast. These diagnostic criteria ensure the homogeneity of the study samples and the reliability of the diagnosis.

[0024] The exclusion criteria were set for the following four situations: First, no gastroscopy images were available, making it impossible to confirm the diagnosis; second, laboratory data was incomplete, missing key test indicators; third, the medication history was unclear, making it impossible to accurately obtain drug exposure information; and fourth, emergency gastroscopy was performed, which is a special clinical situation. After rigorous screening, a total of 3233 patients were finally included, including 729 patients with gastric retention and 2504 patients without gastric retention.

[0025] The data collection covered the patient's initial clinical information, specifically including basic demographic data (age, sex, education level), surgical history (gastrointestinal surgery, pyloric obstruction, intestinal obstruction, etc.), laboratory data (indicators of hypoalbuminemia, hypokalemia, hyponatremia, etc.), and medication history (use of anticholinergic drugs, analgesics, antihistamines, hypoglycemic agents, etc.). All data were extracted from the electronic medical record system and double-checked to ensure accuracy.

[0026] After data collection, the study population was randomly divided into a training cohort and a validation cohort at a ratio of 7:3. The training cohort included 2263 patients, of whom 1753 had no gastric retention and 540 had gastric retention. The validation cohort included 970 patients, of whom 751 had no gastric retention and 219 had gastric retention. To validate the stratification, chi-square tests or t-tests were performed on all characteristics between the training and validation cohorts. The results showed no statistically significant differences between the two groups on any characteristic (P>0.05), indicating that the randomization stratification was effective and that the validation cohort could represent the data distribution characteristics of the training cohort.

[0027] Please see Figure 3In step S2, in the training queue constructed in step S1, the ratio of patients with gastric retention to those without gastric retention is 540:1753, approximately 1:3.25, indicating a significant class imbalance. Without intervention, the machine learning model may favor the majority class (non-gastric retention) during training, leading to a decreased ability to identify the minority class (gastric retention). Therefore, this invention employs a synthetic minority oversampling technique to balance the training queue.

[0028] Specifically, the core principle of synthetic minority class oversampling technology involves randomly selecting two or more neighboring samples in the feature space of the minority class samples and generating new synthetic samples through linear interpolation, rather than simply copying the original minority class samples. The specific algorithm flow is as follows: First, for each minority class sample, calculate its Euclidean distance with all other minority class samples to determine its k nearest neighbors (k is set to 5 in this embodiment). Then, randomly select a sample from the k nearest neighbors. Finally, perform random linear interpolation between the feature vectors of the two samples to generate a new synthetic sample.

[0029] By employing synthetic minority class oversampling, the number of samples in the gastric retention category was increased from 540 to a level balanced with the majority class. The final SMOTE-enhanced training cohort included both real and algorithm-generated samples, totaling 3506 samples. Statistical analysis of the clinical characteristics of the SMOTE-enhanced training cohort revealed significant differences between the two groups in BMI, pyloric obstruction, intestinal obstruction, dyspepsia, history of gastrointestinal surgery, systemic diseases, diabetes, hypoalbuminemia, hypokalemia, use of anticholinergic drugs, use of hypoglycemic drugs, and use of antihistamines (P<0.05). No other statistically significant differences were observed (P>0.05). These results demonstrate that synthetic minority class oversampling effectively preserves the statistical characteristics of the original data while balancing the class distribution.

[0030] Please see Figure 4 S3. Based on the SMOTE enhanced training cohort, this invention employs LASSO regression for feature selection to identify the clinical predictors most relevant to gastric retention. LASSO regression, by adding an L1 regularization term to the loss function, can compress the coefficients of irrelevant or redundant features to zero, thereby achieving the purpose of feature selection.

[0031] In implementation, all clinical features in the SMOTE enhanced training cohort are used as candidate predictors, with gastric retention status as the dependent variable, to construct a LASSO regression model. The regularization parameter λ controls the strength of the penalty; specifically, the larger the λ value, the stronger the penalty, the more coefficients are compressed to zero, and the fewer features are ultimately retained. This invention uses a 10-fold cross-validation method to determine the optimal λ value. The specific operation process is as follows: the SMOTE enhanced training cohort is randomly divided into 10 subsets of similar size, each subset is used as the validation set, and the remaining 9 subsets are used as the training set. The cross-validation error under each λ value is calculated, and the λ value with the smallest cross-validation error is selected as the optimal parameter.

[0032] Please see Figure 5 In the figure, LASSO regression was used for feature selection. The lasso parameter (λ) was optimized using 10-fold cross-validation combined with a single standard error rule. The dashed vertical line indicates the optimal λ value; this invention selected λ = 0.014log(λ) = -4.243 as the best fit value. This invention compared the lasso coefficient distribution plots of 16 clinical features with the log(λ) value selected by 10-fold cross-validation. This analysis identified 12 features with significantly non-zero coefficients, which were ultimately included in the model. Note: LASSO is the minimum absolute contraction and selection operator.

[0033] After 10-fold cross-validation, the optimal regularization parameter λ was determined to be 0.014, corresponding to a log(λ) value of -4.243. At this λ value, LASSO regression selected 12 features with non-zero coefficients from the original features, in the following order: anticholinergic drug use, pyloric obstruction, analgesic use, systemic disease, history of gastrointestinal surgery, indigestion, intestinal obstruction, hypoproteinemia, BMI, antihistamine use, diabetes, and hypokalemia.

[0034] These 12 characteristics are well-interpreted at the clinical level. Anticholinergic drugs can inhibit gastric smooth muscle contraction, directly delaying gastric emptying; pyloric obstruction physically hinders the emptying of gastric contents; analgesics affect gastrointestinal motility; systemic diseases reflect overall health status; a history of gastrointestinal surgery may damage the vagus nerve or alter anatomical structures; dyspepsia symptoms are a clinical manifestation of delayed gastric emptying; intestinal obstruction can lead to upper gastrointestinal content retention; hypoproteinemia may reflect malnutrition or systemic inflammation; BMI reflects nutritional metabolic status; antihistamines have anticholinergic effects; diabetes is a known risk factor for gastroparesis; hypokalemia can directly impair smooth muscle contraction function. These 12 characteristics cover multiple dimensions, including demographic characteristics, medical history, medication use, and laboratory tests, forming a multi-faceted assessment of the risk of gastric retention.

[0035] S4. Based on the 12 key clinical features selected in step S3, this invention constructs 9 machine learning prediction models and conducts a comprehensive comparison of their performance. The selected models include: logistic regression, decision tree, random forest, support vector machine, extreme gradient boosting, lightweight gradient boosting machine, K-nearest neighbors, Naive Bayes, and artificial neural network.

[0036] Logistic regression, as a generalized linear model, assumes that the dependent variable follows a Bernoulli distribution and solves for the model parameters through maximum likelihood estimation. The advantages of logistic regression are its simple model structure, high computational efficiency, and easily interpretable results; however, it struggles to capture nonlinear interactions between features. In this embodiment, L2 regularization is used to prevent overfitting in logistic regression, and the regularization coefficients are determined through grid search.

[0037] Decision trees construct a tree structure by recursively partitioning the feature space. Each internal node corresponds to a decision condition for a feature, and each leaf node corresponds to a predicted category. The advantages of decision trees are that they do not require feature preprocessing, can handle non-linear relationships, and offer intuitive interpretability. In this embodiment, the maximum depth of the decision tree is set to 5, and the minimum number of leaf node samples is set to 10 to prevent overfitting.

[0038] Random forest is an ensemble learning method that constructs multiple decision trees through bootstrapping and outputs the final prediction result using a majority voting mechanism. By integrating multiple weak learners, random forest achieves more stable and accurate prediction performance, effectively reducing the risk of overfitting. In this embodiment, the number of trees in the random forest is set to 100, and the maximum number of features per tree is set to the square root of the total number of features.

[0039] Support Vector Machines (SVMs) perform classification by finding the optimal hyperplane that maximizes the class margin. For non-linearly separable problems, SVMs map the original feature space to a higher-dimensional feature space using a kernel function, and then search for the optimal hyperplane in the higher-dimensional space. In this embodiment, the SVM uses a radial basis function kernel, and the kernel coefficients and regularization parameters are optimized through a grid search.

[0040] Extreme gradient boosting is an ensemble learning algorithm based on the gradient boosting framework. It iteratively adds decision trees, with each new tree fitting the residual of the previous tree, thereby progressively optimizing prediction performance. Extreme gradient boosting introduces a regularization term at the algorithmic level to control model complexity, supports parallel computation to improve training efficiency, and has a built-in mechanism for handling missing values, exhibiting strong robustness and generalization ability. In this embodiment, the learning rate of extreme gradient boosting is set to 0.1, the maximum tree depth is set to 6, and the number of trees is determined to be 150 using early stopping.

[0041] The Lightweight Gradient Boosting Machine (LTHM) is an improved algorithm for extreme gradient boosting. It uses one-sided gradient sampling to reduce the amount of data and mutual exclusion feature binding to reduce feature dimensionality, significantly improving training speed while maintaining prediction accuracy. In this embodiment, the learning rate of the Lightweight Gradient Boosting Machine is set to 0.1, the maximum tree depth is set to 5, and the number of leaf nodes is set to 31.

[0042] K-Nearest Neighbors (KNN) is an instance-based learning algorithm. For a sample to be predicted, it finds the k nearest neighbors in the training set, and the prediction result is determined by voting among these k neighbors based on their class. KNN's advantages include not requiring explicit training and being able to handle multi-class classification problems, but it is sensitive to feature scaling and has high computational complexity. In this embodiment, the value of k is determined to be 7 through cross-validation, and Euclidean distance is used as the distance metric.

[0043] Naive Bayes is based on Bayes' theorem, which assumes that features are conditionally independent under a given category. Although this assumption often does not hold true in practical applications, Naive Bayes still exhibits good performance on many problems, especially in high-dimensional feature spaces. In this embodiment, Gaussian Naive Bayes is used, assuming that continuous features follow a Gaussian distribution.

[0044] Artificial neural networks (ANNs) simulate the connection structure of biological neurons, constructing a multi-layered network structure comprising an input layer, hidden layers, and an output layer. Each neuron receives an input signal, processes it through an activation function, and outputs it to the next layer. ANNs can approximate arbitrarily complex nonlinear functions, but require a large amount of training data, and the training process is time-consuming. In this embodiment, the ANN contains two hidden layers, each containing 64 neurons, with ReLU as the activation function, a sigmoid activation function for the output layer, Adam as the optimizer, and a learning rate of 0.001.

[0045] All nine models were trained on the SMOTE augmented training queue, using the same 12 features as input. During model training, 5-fold cross-validation was used for hyperparameter tuning to ensure each model reached its optimal configuration. Detailed hyperparameter settings are shown in Supplementary Table 1.

[0046] Please see Figure 6 S5. In this invention, an independent validation queue is used to comprehensively evaluate the nine models constructed in step S4, thereby selecting the optimal prediction model. The evaluation indicators cover three dimensions: model discrimination, calibration and clinical utility.

[0047] Please see Figure 7 The figure shows the calibration curves for different machine learning models. Figure 7In the diagram, (A) represents the Smote boosting training queue, and (B) represents the validation queue. Note: AUC (Area Under the Curve); LR (Logistic Regression); DT (Decision Tree); RF (Random Forest); SVM (Support Vector Machine); XGBoost (Extreme Gradient Boosting); LightGBM (Light Gradient Boosting Machine); KNN (K-Nearest Neighbors); NB (Naive Bayes); ANN (Artificial Neural Network). The calibration curve divides the predicted probability into several intervals, calculates the actual positive rate within each interval, and plots a scatter plot with the predicted probability on the x-axis and the actual positive rate on the y-axis. If the predicted probability and the actual positive rate are close, the scatter points will be distributed around the 45-degree diagonal, indicating that the model has good calibration.

[0048] Please see Figure 8 The figure illustrates the performance of different machine learning models. Figure 8 In the diagram, (A) is the SMOTE-enhanced training set, and (B) is the validation set. Note: AUC: Area Under the Receiver Operating Characteristic (ROC); PPV: Positive Predictive Value; NPV: Negative Predictive Value; LR: Logistic Regression; DT: Decision Tree; RF: Random Forest; SVM: Support Vector Machine; XGBoost: Extreme Gradient Boosting; LightGBM: Lightweight Gradient Boosting Machine; KNN: K-Nearest Neighbors; NB: Naive Bayes; ANN: Artificial Neural Network.

[0049] The ability of a discriminative model to differentiate between patients with and without gastric retention is assessed primarily by the area under the receiver operating characteristic (ROC) curve. The ROC curve is plotted with the false positive rate on the x-axis and the true positive rate on the y-axis. A ROC curve closer to 1 indicates a stronger discriminative ability. Accuracy, sensitivity, specificity, positive predictive value, and negative predictive value are also calculated. Sensitivity reflects the model's ability to identify patients with gastric retention, while specificity reflects its ability to identify patients without gastric retention. In clinical scenarios involving gastric retention risk prediction, missing high-risk patients can have serious adverse consequences; therefore, sensitivity has a high clinical weight.

[0050] Please see Figure 9 The figure shows the decision curve analysis (DCA) of different machine learning models. Figure 9In the image, (A) is the SMOTE-enhanced training set, and (B) is the validation set. Note: LR: Logistic Regression; DT: Decision Tree; RF: Random Forest; SVM: Support Vector Machine; XGBoost: Extreme Gradient Boosting; LightGBM: Lightweight Gradient Boosting Machine; KNN: K-Nearest Neighbors; NB: Naive Bayes; ANN: Artificial Neural Network; All: Full Intervention Baseline; None: No Intervention Baseline. Decision curve analysis uses the model's predicted probabilities as the basis for decision-making, calculating the net benefit of using the model to guide decisions at different threshold probabilities. The net benefit comprehensively considers the benefit from true positive decisions and the loss from false positive decisions, reflecting whether the model truly outperforms the extreme strategies of "full intervention" or "no intervention." The results of the decision curve analysis are plotted with net benefit on the ordinate and threshold probability on the abscissa; a higher curve position indicates better clinical utility.

[0051] The evaluation results are as follows: In the SMOTE augmented training cohort, the area under the receiver operating characteristic (AUC) of the nine models ranged from 0.687 to 0.806. The extreme gradient boosting model performed best, with an AUC of 0.806, accuracy of 0.691, sensitivity of 0.715, specificity of 0.667, positive predictive value of 0.683, and negative predictive value of 0.699. The random forest model performed slightly worse than the extreme gradient boosting model, with an AUC of 0.792; the lightweight gradient boosting model had an AUC of 0.788; the artificial neural network model had an AUC of 0.775; the support vector machine model had an AUC of 0.756; the logistic regression model had an AUC of 0.741; the K-nearest neighbor model had an AUC of 0.718; the Naive Bayes model had an AUC of 0.702; and the decision tree model had an AUC of 0.687.

[0052] In the independent validation cohort, the area under the receiver operating characteristic (AUC) for the nine models ranged from 0.563 to 0.710. The extreme gradient boosting model maintained the best performance, with an AUC of 0.710, accuracy of 0.685, sensitivity of 0.708, specificity of 0.662, positive predictive value of 0.679, and negative predictive value of 0.692. The AUCs for the random forest model, lightweight gradient boosting model, artificial neural network model, support vector machine model, logistic regression model, k-nearest neighbor model, and decision tree model were all 0.563.

[0053] The DeLong test was used to statistically compare the area under the receiver operating characteristic (AUC) curves of each model. The results showed that the extreme gradient boosting model had a significantly higher AUC in the training cohort than the decision tree, K-nearest neighbors, Naive Bayes, and logistic regression models (P<0.01), while the difference between it and the random forest and lightweight gradient boosting models was not statistically significant (P>0.05). In the validation cohort, the extreme gradient boosting model had a significantly higher AUC than all other models (P<0.05).

[0054] To verify the stability and generalization ability of the extreme gradient boosting model, this example uses 10-fold cross-validation for internal validation on the SMOTE boosting training cohort. The SMOTE boosting training cohort is randomly divided into 10 subsets of similar size, with each subset serving as the validation set and the remaining 9 subsets as the training set, repeated 10 times. The results show that the mean area under the receiver operating characteristic (AUD) of the extreme gradient boosting model is 0.766±0.019, and the mean accuracy is 0.691±0.019, indicating that the model has good stability.

[0055] Calibration curve analysis showed that the extreme gradient boosting model exhibited good consistency in both the SMOTE boosting training cohort and the independent validation cohort. The scatter plots of predicted probabilities and actual positive rates were located near the 45-degree diagonal. The p-values ​​for the Hosmer-Lemeshow goodness-of-fit test were 0.324 and 0.287, respectively, both greater than 0.05, indicating that there was no significant difference between the model's predicted probabilities and the actual observations.

[0056] Decision curve analysis results show that within the clinical decision-making interval of a threshold probability range of 0.2 to 0.8, the net benefit of the extreme gradient boosting model is higher than that of the other eight models, and also higher than the two extreme strategies of "full intervention" and "no intervention". Specifically, when the threshold probability is set at 0.3, the net benefit of the extreme gradient boosting model is 0.082, while that of the random forest model is 0.071, the lightweight gradient boosting machine model is 0.069, the artificial neural network model is 0.062, and the logistic regression model is 0.055. This result indicates that using the extreme gradient boosting model to guide clinical decision-making can achieve higher clinical benefits within a reasonable threshold range.

[0057] Based on the above evaluation results, this invention selects the extreme gradient boosting model as the optimal prediction model. This model performs best in all three dimensions: discrimination, calibration, and clinical utility, and also exhibits good stability and generalization ability.

[0058] Please see Figure 10 In step S6, this invention employs the Shapley Additive exPlanations (SHAP) algorithm to interpret the optimal extreme gradient boosting model selected in step S5. The SHAP algorithm, based on the concept of Shapley value in game theory, quantifies the contribution of each feature as its marginal contribution to the prediction result. Specifically, for the sample to be interpreted, the SHAP algorithm calculates the model prediction values ​​for all possible feature subsets and determines the Shapley value for each feature. The Shapley value satisfies the additivity property, meaning the sum of the Shapley values ​​for all features equals the difference between the model prediction value and the baseline prediction value.

[0059] The results of SHAP interpretation are presented through various visualization methods, specifically: Please see Figure 11 This chart showcases a bee colony graph generated based on the Shaple analysis using the XGBoost model. The graph clearly visualizes the specific impact mechanism of each data point's feature value on the prediction results. Each data point (corresponding to an individual bee) is color-coded according to its feature value, intuitively demonstrating the correlation between feature strength and its impact on the model's prediction results. Note: Shaple represents the Shaple additive interpretation method; XGBoost is the extreme gradient boosting algorithm.

[0060] Bee swarm plots combine information from scatter plots and density plots to display the Shapley value distribution for each feature. Each point in the plot represents a sample, and the color of the point indicates the value of that feature in the sample (red represents a high value, blue represents a low value). The horizontal axis represents the Shapley value (positive values ​​indicate an increased risk of gastric retention, negative values ​​indicate a decreased risk). Bee swarm plot results show that Shapley values ​​for anticholinergic drug use, pyloric obstruction, analgesic use, systemic diseases, and a history of gastrointestinal surgery are mainly distributed on the positive half-axis, and high values ​​for these features (such as anticholinergic drug use and pyloric obstruction) correspond to larger positive Shapley values, indicating that these features are associated with a higher risk of gastric retention. Conversely, the Shapley value distribution for BMI is more symmetrical; both low and high BMI may have different effects on risk.

[0061] Please see Figure 12 This figure shows the Shaple analysis bar chart for the XGBoost model. The length of each bar represents the overall contribution of a specific feature to the model's prediction results across the entire dataset. Note: Shaple refers to the SHapley additive interpretation; XGBoost refers to the extreme gradient boosting method.

[0062] The bar chart illustrates the average absolute impact of each feature on the model's predictions. The height of each bar represents the average absolute Shapley value of that feature across all samples, reflecting the overall contribution of that feature to the model's output. The bar chart results show that anticholinergic drug use has the greatest impact on the model, with an average absolute Shapley value of 0.142; followed by pyloric obstruction, with an average absolute Shapley value of 0.113; third is analgesic use, with an average absolute Shapley value of 0.098; fourth is systemic disease, with an average absolute Shapley value of 0.085; and fifth is a history of gastrointestinal surgery, with an average absolute Shapley value of 0.076. Other features, in descending order of contribution, include indigestion, intestinal obstruction, hypoproteinemia, BMI, antihistamine use, diabetes, and hypokalemia.

[0063] Please see Figure 13 The figure shows the mean probability distribution of two patients (one without gastric retention and one with gastric retention) in the validation cohort, as illustrated by the force diagram and waterfall plot. Figure 13 Figures (A) and (B) attempt to provide a decomposition plot of the contribution of patient-specific features to the predictive probability of the outcome. (A) represents patients without gastric retention, and (B) represents patients with gastric retention. Each feature is represented by an arrow, with the direction and length of the arrow indicating the increase or decrease in the outcome probability of the feature and the specific magnitude of the increase or decrease, respectively. Figure 13The waterfall plots (C) and (D) further extend the feature impact analysis, demonstrating the sequential contribution of each feature to the probability score. Starting from the baseline probability, the influence of each feature is progressively added or subtracted, and the final probability change is presented in a waterfall-like staircase format. Both types of charts use color coding to distinguish between positive (red) and negative (blue) contributions of features, thereby improving the interpretability of the model's prediction results at the individual patient level.

[0064] Force-directed plots demonstrate the breakdown of prediction results for a single sample, visually presenting the positive or negative contribution of each feature to the predicted value. For a typical sample of patients with gastric retention, the force-directed plot shows that anticholinergic drug use, pyloric obstruction, analgesic use, systemic diseases, and a history of gastrointestinal surgery are the main positive contributing features, collectively boosting the predicted value; while normal BMI and no use of antihistamines are negative contributing features, partially offsetting the influence of positive factors.

[0065] Waterfall plots cumulatively display the contribution of each feature, starting from the baseline predicted value and progressively accumulating the Shapley values ​​of each feature until the model's predicted probability is reached. Waterfall plots clearly show the specific magnitude of each feature's impact on the final prediction result, making it easier for clinicians to understand the model's decision-making process.

[0066] The results interpreted by SHAP have significant value in clinical practice. First, the use of anticholinergic drugs was identified as the strongest predictor, suggesting that clinicians should pay close attention to patients' medication history before gastroscopy, especially for those currently using anticholinergic drugs, and should consider adjusting the medication regimen or extending the fasting period. Second, the identification of pyloric obstruction and a history of gastrointestinal surgery suggests that patients with these conditions should be considered high-risk groups and interventions should be implemented in advance. Third, the discovery of analgesic use and systemic diseases broadens the perspective of gastric retention risk assessment, reminding physicians to pay attention to non-traditional risk factors.

[0067] This invention provides Embodiment 1 This embodiment constructs the present invention according to the above steps. During the data collection phase, a total of 3233 patients were included, of whom 729 had gastric retention (22.5%) and 2504 had no gastric retention (77.5%). Among the patients with gastric retention, there were 401 males and 328 females, with a mean age of 62.4 ± 12.3 years; among the patients without gastric retention, there were 1487 males and 1017 females, with a mean age of 58.7 ± 13.1 years. There was a significant difference in age distribution between the two groups (P < 0.01), but no significant difference in gender distribution (P = 0.084).

[0068] In the feature selection phase, 12 key features were selected from the initial 45 clinical features using LASSO regression. Compared with the original feature set, the feature dimension was reduced by 73.3%, effectively reducing model complexity. The 10-fold cross-validation results of LASSO regression showed that the cross-validation error was minimized when λ=0.014, at which point the 12 retained features had non-zero coefficients.

[0069] During the model comparison phase, the performance metrics of the nine models in the validation queue are shown in Table 1.

[0070] Table 1. Performance comparison of each model in the independent validation queue.

[0071] In the table, AUC is the area under the receiver operating characteristic curve, PPV is the positive predictive value, and NPV is the negative predictive value.

[0072] As shown in Table 1, the extreme gradient boosting model outperformed other models in all evaluation metrics. In terms of sensitivity, a clinically crucial metric, the extreme gradient boosting model achieved a score of 0.708, indicating that it could correctly identify 70.8% of patients with gastric retention. In terms of specificity, it reached 0.662, indicating that it could correctly identify 66.2% of patients without gastric retention. Therefore, this performance level meets the basic requirements for clinical decision support.

[0073] This invention provides Embodiment 2 This embodiment uses the SHAP algorithm to analyze the feature importance of the extreme gradient boosting model and verify the stability of the feature ranking. The mean absolute Shapley value of each feature is calculated to obtain the feature importance ranking, as shown in Table 2.

[0074] Table 2. Ranking of Feature Importance

[0075] This example uses a bootstrap method for sensitivity analysis to verify the stability of feature importance ranking. One hundred bootstrap samples were drawn with replacement from the original data, and the mean absolute Shapley value of the features was recalculated for each bootstrap sample. The results show that the top five features (anticholinergic drug use, pyloric obstruction, analgesic use, systemic disease, and history of gastrointestinal surgery) remained in the top five positions in over 95% of the bootstrap samples, indicating that the feature importance ranking has good stability.

[0076] This example further analyzes the relationship between characteristics and the risk of gastric retention. For binary characteristics (such as anticholinergic drug use), the mean Shapley value difference between the two groups was calculated. The results showed that the mean Shapley value of the sample using anticholinergic drugs was 0.163±0.042, while the mean Shapley value of the sample not using anticholinergic drugs was -0.021±0.015, and the difference was statistically significant (P<0.001), indicating that anticholinergic drug use increases the risk of gastric retention. The mean Shapley value for samples with pyloric obstruction was 0.131±0.038, while the mean Shapley value for samples without pyloric obstruction was -0.016±0.012; the mean Shapley value for samples using analgesics was 0.114±0.035, while the mean Shapley value for samples not using analgesics was -0.011±0.010; the mean Shapley value for samples with systemic diseases was 0.098±0.031, while the mean Shapley value for samples without systemic diseases was -0.009±0.008; the mean Shapley value for samples with a history of gastrointestinal surgery was 0.087±0.029, while the mean Shapley value for samples without a history of surgery was -0.008±0.007.

[0077] For the continuous characteristic BMI, this experiment analyzed the relationship between its Shapley value and the characteristic value. The Shapley value for the low BMI (<18.5) sample was 0.012±0.018, the Shapley value for the normal BMI (18.5-24) sample was -0.008±0.012, the Shapley value for the overweight (24-28) sample was -0.006±0.011, and the Shapley value for the obese (>28) sample was 0.009±0.015. Both low BMI and obesity showed a slightly positive Shapley value, but the variability was large, suggesting that the relationship between BMI and gastric retention may have a U-shaped distribution.

[0078] This invention provides embodiment 3 This embodiment evaluates the application effect of the system of the present invention in clinical decision support. Decision curve analysis is used to quantify clinical benefits. The decision curve analysis is performed in the validation cohort, calculating the net benefit under different threshold probabilities. The formula for calculating net benefit is: Net benefit = (Number of true positives / Total number of samples) - (Number of false positives / Total number of samples) × (Threshold probability / (1 - Threshold probability)). The larger the net benefit value, the higher the benefit brought by using the model decision at the corresponding threshold probability.

[0079] Using the predicted probability of the extreme gradient boosting model as the decision-making basis, threshold probabilities were set from 0.1 to 0.9, and the net benefit at each threshold was calculated. Simultaneously, the net benefits of two extreme strategies were calculated: the "all-intervention" strategy (intervening in all patients, net benefit = prevalence - (1 - prevalence) × (threshold probability / (1 - threshold probability))) and the "no-intervention" strategy (no intervention for all patients, net benefit = 0).

[0080] The results show that, within the clinically common decision-making range of threshold probabilities of 0.2 to 0.5, the net benefit of the extreme gradient boosting model is significantly higher than that of the two extreme strategies, as shown in Table 3.

[0081] Table 3 Comparison of net benefits under different threshold probabilities.

[0082] As shown in Table 3, when the threshold probability is set to 0.30, the net benefit of using the extreme gradient boosting model to guide decision-making is 0.082, while the net benefit of the "full intervention" strategy is only 0.005. This indicates that the model can bring better clinical decision-making results compared to blind intervention.

[0083] In this example, using a threshold probability of 0.30, an extreme gradient boosting model was used to predict the risk of 970 patients in the validation cohort. Of these, 328 patients (33.8%) had a predicted risk ≥0.30, and 642 patients (66.2%) had a predicted risk <0.30. In the high-risk group, 155 patients actually had gastric retention, and 173 patients did not. In the low-risk group, 64 patients actually had gastric retention, and 578 patients did not. This indicates that if clinical intervention is based on the model's predictions, intervening in 328 patients would identify 155 patients with gastric retention, while 173 non-gastric retention patients would receive unnecessary intervention. In contrast, if a "full intervention" strategy is adopted, 970 patients need to be intervened to identify 219 patients with gastric retention, and an additional 751 non-gastric retention patients need to be intervened. The application of the model reduces unnecessary interventions by 77.0%, significantly reducing the waste of medical resources and the intervention burden on patients.

[0084] This invention provides Example 4 This embodiment evaluates the predictive performance of the extreme gradient boosting model in different patient subgroups to verify the model's generalizability. The validation cohort was stratified by age, sex, diabetes status, and history of gastrointestinal surgery. The area under the receiver operating characteristic (AUC), sensitivity, and specificity were calculated for each subgroup, and the results are shown in Table 4.

[0085] Table 4 Model performance in different subgroups

[0086] Table 4 shows that the area under the receiver operating characteristic (AUC) of the extreme gradient boosting model remained between 0.68 and 0.72 across different subgroups, indicating good subgroup stability. In the high-risk subgroup with a history of gastrointestinal surgery, the AUC was relatively low (0.682), but still has clinical application value; in the low-risk subgroup without a history of gastrointestinal surgery, the AUC was higher (0.718). The sensitivity index was relatively low in the diabetes and gastrointestinal surgery subgroups, possibly due to the greater number of confounding factors in these subgroups.

[0087] This invention provides Example 5 This embodiment compares the prediction results of the system of the present invention with the accuracy of clinical physicians' experience-based judgment. Five attending physicians with more than five years of endoscopic experience participated in the comparative test. 200 patients were randomly selected from the validation cohort, including 60 patients with gastric retention and 140 patients without gastric retention, forming the test set. Each physician independently judged whether a patient was at high risk of gastric retention based on their clinical data (12 features identical to the model input). The physicians' judgments were compared with the model's predictions, using actual gastroscopy results as the gold standard. Accuracy, sensitivity, and specificity were calculated, and the results are shown in Table 5.

[0088] Table 5. Performance comparison between the model and physician judgment.

[0089] As shown in Table 5, the accuracy of the extreme gradient boosting model was 0.685, significantly higher than the average accuracy of 0.626 among the five physicians (P=0.012); the sensitivity was 0.708, significantly higher than the average sensitivity of 0.590 among physicians (P=0.003); and the specificity was 0.662, which was not significantly different from the average specificity of 0.642 among physicians (P=0.187). These results demonstrate that the system of this invention is superior to the experience-based judgment of clinicians in identifying the risk of gastric retention, especially in identifying high-risk patients, and can serve as an effective auxiliary decision-making tool.

[0090] The above are merely preferred embodiments of the present invention and are not intended to limit the present invention in any other way. Any person skilled in the art may make changes or modifications to the above-disclosed technical content to create equivalent embodiments that can be applied to other fields. However, any simple modifications, equivalent changes, and modifications made to the above embodiments based on the technical essence of the present invention without departing from the scope of the present invention shall still fall within the protection scope of the present invention.

Claims

1. A gastric retention risk prediction system based on a machine learning model, characterized in that, include: The data acquisition module is used to acquire clinical data of the target subject. The clinical data includes at least the use of anticholinergic drugs, pyloric obstruction, analgesic use, systemic disease status, history of gastrointestinal surgery, indigestion, intestinal obstruction, hypoproteinemia indicators, body mass index, antihistamine use, diabetes status, and hypokalemia indicators. The feature processing module is used to transform the acquired clinical data into feature vectors that match the input layer of a pre-trained machine learning model. The risk prediction module is used to load and run a pre-trained machine learning model, input feature vectors into the machine learning model, and output the risk probability value of the target object developing gastric retention. The pre-trained machine learning model is an extreme gradient boosting model, which is constructed and trained through the following steps: A1. Obtain historical clinical dataset, which includes multiple samples, each corresponding to a patient who underwent gastroscopy, and labeled with a classification tag indicating whether the patient has gastric retention. A2, preprocess the historical clinical dataset to form the initial training set; A3 uses synthetic minority class oversampling technology to oversample the positive samples of gastric retention in the initial training set to generate a balanced enhanced training set; A4. The enhanced training set is subjected to feature selection using a minimum absolute contraction and selection operator regression algorithm combined with 10-fold cross-validation to screen out 12 key clinical features related to gastric retention. The 12 key clinical features are the types of clinical data acquired by the data acquisition module. A5, based on 12 selected key clinical features, constructs and trains an extreme gradient boosting model; A6 uses an independent clinical validation cohort to validate the trained extreme gradient boosting model, and determines the final model parameters based on the validation results.

2. The gastric retention risk prediction system based on a machine learning model according to claim 1, characterized in that, The inclusion criteria for the historical clinical dataset or clinical data are: age, sex, education level, surgical history, complete laboratory data and medication history, and exclusion of patients without gastroscopy images, with incomplete laboratory data, unclear medication history or who underwent emergency gastroscopy.

3. The gastric retention risk prediction system based on a machine learning model according to claim 1, characterized in that: The 12 key clinical features include anticholinergic drug use, pyloric obstruction, analgesic use, systemic disease, history of gastrointestinal surgery, dyspepsia, intestinal obstruction, hypoproteinemia, body mass index, antihistamine use, diabetes, and hypokalemia.

4. The gastric retention risk prediction system based on a machine learning model according to claim 1, characterized in that: The risk prediction module also includes a model interpretation unit, which uses the Shapley additive interpretation algorithm to calculate and visualize the contribution of each input feature to the risk probability value based on a trained extreme gradient boosting model, thereby generating an individualized risk interpretation report. The individualized risk interpretation report includes a feature importance bar chart, a beehive diagram, and a force-directed diagram and waterfall diagram for a single patient.

5. The gastric retention risk prediction system based on a machine learning model according to claim 1, characterized in that: The system also includes a risk stratification and intervention suggestion module. This module compares the risk probability value output by the risk prediction module with a preset threshold to classify the target group into high-risk, medium-risk, or low-risk groups, and outputs corresponding preoperative management suggestions based on the grouping results. These suggestions include extending the fasting regimen, using prokinetic drugs, adjusting the use strategy of anticholinergic or analgesic drugs, or scheduling the gastroscopy examination as the first procedure of the day.

6. The gastric retention risk prediction system based on a machine learning model according to claim 1, characterized in that: The data acquisition module is used to connect to the hospital's electronic medical record system data interface to acquire the clinical data of the target object. The clinical data includes structured data and unstructured text data. For unstructured text data, information extraction and structuring are performed using natural language processing technology.

7. The gastric retention risk prediction system based on a machine learning model according to claim 1, characterized in that: The system also includes a model update module, which is used to periodically collect data on newly diagnosed patients with gastric retention and corresponding clinical outcome data, and to perform incremental learning or periodic retraining on the currently deployed extreme gradient boosting model, thereby optimizing the model's predictive performance.

8. A method for constructing a gastric retention risk prediction system based on a machine learning model, used to construct the gastric retention risk prediction system based on a machine learning model as described in any one of claims 1-7, characterized in that, Includes the following steps: S1. Collect historical clinical datasets, which contain clinical information of multiple patients and corresponding gastroscopy results. The diagnostic criteria for gastric retention are that the gastric residual volume is at least 6.3% after fasting for 4 hours, or unexpected food residue is observed during gastroscopy after fasting for 8 hours. S2, randomly divide the historical clinical dataset into training queues and validation queues according to a preset ratio; S3, For the training queue, a synthetic minority oversampling technique is used to generate new samples with a distribution similar to that of minority gastric retention samples, thereby balancing the class distribution and obtaining an enhanced training set; S4 uses gastric retention as the prediction target. It applies the minimum absolute contraction and selection operator regression algorithm to the enhanced training set for feature selection and optimizes the penalty parameter through 10-fold cross-validation to select a set of clinical features with non-zero coefficients as key prediction features. S5. Based on key prediction features, an extreme gradient boosting model is constructed as the initial model. The initial model is then trained using an enhanced training set to optimize the model parameters. S6. The extreme gradient boosting model after training is independently validated using a validation queue. The discrimination, calibration and clinical net benefit of the model are evaluated by analyzing the area under the receiver operating characteristic curve, calibration curve and decision curve. The final model is determined based on the evaluation results. S7 deploys the final model in the risk prediction system to receive the corresponding clinical data of the patients to be tested and output the probability of gastric retention risk.

9. The method for constructing a gastric retention risk prediction system based on a machine learning model according to claim 8, characterized in that, Step S6 includes: using the DeLong test to statistically compare the area under the receiver operating characteristic curve of the extreme gradient boosting model with that of other machine learning models to verify the superiority of the extreme gradient boosting model, and using 10-fold cross-validation to internally validate the extreme gradient boosting model to evaluate its stability.

10. The method for constructing a gastric retention risk prediction system based on a machine learning model according to claim 8, characterized in that: The hyperparameters of the extreme gradient boosting model are tuned in step S5 through grid search or Bayesian optimization. The hyperparameters include the learning rate, the maximum depth of the tree, the minimum weight of the leaf nodes, the subsampling ratio, and the column sampling ratio.