Clinical prediction model and visual platform for chronic atrophic gastritis based on random forest algorithm
The chronic atrophic gastritis (CAG) prediction model constructed using the RandomForest algorithm solves the problems of high cost of endoscopy and reliance on professional knowledge for accuracy. It achieves non-invasive and accurate CAG risk prediction and high-risk population screening, and provides a visualization platform to support clinical applications.
Patent Information
- Application Number
- CN202511504982.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-21
- Publication Date
- 2026-02-13
AI Technical Summary
In the current technology, the diagnosis of chronic atrophic gastritis relies on endoscopy, which has problems such as high labor costs, invasive examination process, and diagnostic accuracy depending on professional knowledge. In addition, there is a lack of non-invasive and accurate predictive models before endoscopy.
A predictive model for chronic atrophic gastritis (CAG) was constructed using the RandomForest algorithm. Through feature selection, model tuning, and interpretability analysis, a prediction model based on the RandomForest algorithm was developed, and a visualization platform was provided for early and accurate prediction of CAG risk.
It provides a non-invasive and interpretable method for predicting CAG risk, improving the accuracy and efficiency of diagnosis, providing reliable clinical evidence for screening high-risk groups before endoscopy, and facilitating clinical application through a visualization platform.
Smart Images

Figure CN121528516A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application belongs to the technical field of CAG risk prediction model and prediction platform, and particularly relates to a chronic atrophic gastritis clinical prediction model and visualization platform based on a random forest algorithm. BACKGROUND
[0002] Gastric cancer (GC) is one of the most common malignant tumors worldwide, and its disease burden shows significant regional differences. According to global cancer statistics, East Asia accounts for about 60% of global GC cases, and China accounts for about half of the global total of new cases and deaths each year, which has become a serious public health problem and challenge. The Correa cascade is widely recognized as one of the main pathways of the development of intestinal-type gastric cancer. This theory proposes that the occurrence of gastric cancer usually goes through a multi-stage progressive process, including chronic atrophic gastritis (CAG), intestinal metaplasia, dysplasia, and eventually adenocarcinoma. CAG is a common gastric disease and an important precancerous disease of GC. Its characteristics are a decrease in the number of gastric mucosal glands and mucosal atrophy, often accompanied by or without intestinal metaplasia and dysplasia. Most patients have no obvious symptoms or only show some non-specific gastric discomfort. Studies have shown that the risk of GC in CAG patients is 4-6 times that of the general population.
[0003] A meta-analysis based on 107 studies showed that the global prevalence of CAG was 33%, and the prevalence in GC high-incidence countries was significantly higher than that in low-incidence countries (42% vs. 23%). A large-scale survey in China covering 8892 patients with chronic gastritis showed that CAG accounted for 17.7%. It is worth noting that the accuracy of endoscopy in diagnosing CAG is low, only 50.3%, which is significantly lower than that of histological diagnosis. Since most CAG patients have no obvious symptoms, they do not receive timely endoscopic examination, or they do not seek medical treatment due to fear of endoscopy, so the actual prevalence of CAG may be underestimated, and it is estimated that its true prevalence has exceeded 20%. Traditional methods for diagnosing CAG rely on endoscopy combined with biopsy pathology, but as a screening method, it has high labor costs, the examination process is invasive, patient dependence is poor, and the diagnostic accuracy depends on the clinical professional knowledge and subjective judgment of professionals. In view of the above situation, there is an urgent need for a non-invasive method to objectively predict CAG for use in clinical practice.
[0004] Machine learning is a technology that uses algorithms to automatically learn rules from large amounts of data and make predictions or classifications. In recent years, it has been widely used in the medical field. Compared with traditional statistical models, machine learning models have many significant advantages. First, machine learning can handle high-dimensional and complex-structured data, which is suitable for clinical scenarios with significant multivariate interaction. Second, machine learning models have stronger modeling ability for non-linear relationships and can more accurately reflect the complex mechanisms of disease development. In addition, machine learning models have strong self-optimization and generalization capabilities, and can accurately predict new data after training. Currently, machine learning has been used in the fields of endoscopy-assisted diagnosis, risk prediction and prognosis estimation of gastrointestinal tumors, but there is still a lack of prediction models that can accurately predict the risk of CAG before gastroscopy. SUMMARY
[0005] Technical solution: In order to solve the above technical problems, the present application uses the RandomForest algorithm to develop and verify an interpretable machine learning model for early and accurate prediction of the risk of CAG in the population. Specifically, a chronic atrophic gastritis clinical prediction model based on the random forest algorithm is provided, and the prediction model construction process includes: Acquiring clinical information for preprocessing to constitute a data set, defining a training set and a test set, and performing stratified sampling division; Using the least absolute shrinkage and selection operator regression method for feature selection to determine the input variables and core variables, and constructing a random forest prediction model; Defining the basic framework of the model under the rand_forest() function, marking the items to be optimized, constructing the workflow, setting the cross-validation strategy, performing grid search optimization, completing the optimization of the model, and selecting the optimal combination of hyperparameters; Solidifying the optimal workflow to generate the final trained prediction model.
[0006] As an improvement, it also includes verifying the final prediction model using the test set, including discrimination and classification performance evaluation, calibration evaluation, and clinical application value evaluation; The discrimination and classification performance evaluation is to first calculate the AUC value and 95% confidence interval of the model on the test set, then determine the optimal classification threshold based on the ROC curve of the training set using the Youden method, and finally apply the threshold to the test set to generate a confusion matrix and calculate the accuracy, sensitivity, specificity, positive predictive value PPV and negative predictive value NPV; The calibration evaluation is to draw a calibration curve to compare the fit degree of the average prediction probability and the actual prevalence rate, and evaluate the reliability of the model prediction probability; The clinical application value assessment is conducted by plotting decision curves and comparing the net benefits of the model strategy with the "full treatment" / "no treatment" baseline strategy to quantify the clinical applicability of the model at different risk thresholds.
[0007] As an improvement, it also includes using the test set to perform global interpretability analysis and local interpretability analysis on the final prediction model; the global interpretability analysis is to generate feature importance bar charts and bee colony diagrams by summarizing the SHAP values of all samples to show the overall impact of each feature on the model prediction. The local interpretability analysis needle is used to visualize individual cases through force diagrams or waterfall plots, clearly showing the attribution of individual predictions.
[0008] As an improvement, the SHAP value is a method provided by the kernelshap package in R, which calculates the contribution of each feature to the prediction result of each sample for the generated final model. The formula is:
[0009] in Φᵢ :feature i The SHAP value is the objective to be solved; F: the set of all features; S: a subset of the feature set F, not a feature set. i (i.e., S ⊆ F \ {i}); |S|: the number of features contained in subset S; |F|: the total number of features; f(S): the model's prediction when using features from subset S as input; for features not in S, the marginal distribution of the feature in the entire dataset is used to estimate the value. f(S ∪ {i}): Using a subset S plus features i When used as input, the model's predicted value; [f(S ∪ {i}) - f(S)]: This is the feature. i The marginal benefit contributed within the context of an existing feature subset S; it measures how much the prediction changes when feature i is added to the consortium S; ∑: for all features not included i The possible subsets S are summed, taking into account the features. i All possible ways of cooperating with all other features.
[0010] As an improvement, the numerical type of clinical information is preprocessed, including being converted into a factor type, where the dependent variable is the patient's final diagnosis and the potential independent variables are the original feature indicators collected from multiple dimensions. Clinical information includes data collected from all study subjects through standardized questionnaires and clinical tests. The data includes one dependent variable and several potential independent variables. The dependent variable is whether the patient has chronic atrophic gastritis. Potential independent variables include serological indicators, demographic characteristics, lifestyle factors, clinical symptoms, and personal and family medical history.
[0011] Preferably, the serological indicators in this invention include Helicobacter pylori (HP) antibody test results and pepsinogen I / II ratio (PGR); demographic characteristics include sex, age, body mass index, and education level; lifestyle factors include a long history of smoking (smoking duration greater than 6 months), a long history of alcohol consumption (drinking more than 3 times / week), a long history of tea consumption (drinking more than 1 time / week), dietary temperature preferences, frequency of fresh fruit intake, salt intake, sleep duration and quality: whether one frequently cannot fall asleep within 30 minutes, or wakes up easily or early at night; clinical symptoms include recurrent abdominal discomfort symptoms such as abdominal pain, poor appetite, bloating, and heartburn; personal and family medical history includes a history of hypertension, diabetes, a first-degree relative's cancer history, and a family history of gastric cancer.
[0012] As an improvement, the stratified sampling partitioning uses the initial_split function under the tidymodels framework to divide the original dataset into two parts: 75% as the training set and 25% as the test set. The stratified sampling method ensures that the ratio of positive to negative samples of chronic atrophic gastritis in the partitioned training and test sets remains consistent with that in the original dataset.
[0013] As an improvement, during feature selection, operator regression is applied to the training set partitioned by stratified sampling, and a parameter is appended to the loss function. L1 The regularization term compresses the coefficients of some unimportant variables to zero. The variables whose coefficients are compressed to zero are the variables included in the model, including HP, age, PGR, smoking history, drinking history, and family history of gastric cancer.
[0014] As an improvement, the factors to be optimized include the number of decision trees and the minimum sample size of each node; the workflow is to combine the model specification with the prediction formula using the workflow() function, where the dependent variable of the prediction formula is diagnosis and the independent variable is the core variable; the grid search optimization is a process of generating a certain threshold number of hyperparameter combinations through random search, training and evaluating them under a 5-fold cross-validation framework, and then using the area under the ROC curve (roc_auc) as the core criterion for selecting the best model. The hyperparameter combination that maximizes the area under the ROC curve (roc_auc) is the one with the best performance.
[0015] Simultaneously, a clinical prediction visualization platform for chronic atrophic gastritis based on the random forest algorithm is also provided. The prediction platform is a tool for end users to calculate the clinical prediction risk of chronic atrophic gastritis based on any of the above-mentioned clinical prediction models for chronic atrophic gastritis based on the random forest algorithm. The conversion includes using the shiny package of R language as a development framework to build a dynamic web application; building the user interface and server logic; and completing the process of deploying the model as an interactive web calculator.
[0016] As an improvement, the steps for calculating the clinical predictive risk of chronic atrophic gastritis using a prediction platform are as follows: (1) Receive and integrate all input data; (2) Load the final model trained and saved from any of the above-mentioned clinical prediction models for chronic atrophic gastritis based on the random forest algorithm. (3) Call the model to make real-time predictions on the newly input data and calculate the probability of disease risk; (4) Output the calculated probability values as percentages and risk levels, including low risk, medium risk and high risk, on the “Prediction Results” page, and display them visually with a dynamic risk dashboard. (5) Extract variable importance information from the loaded model, including Mean Decrease Gini, and plot a bar chart on the "Variable Importance" page.
[0017] Beneficial Effects: The predictive model of this invention uses the SHAP method to interpret and clarify the importance of features and explain the model's prediction results, thereby identifying relevant risk factors for CAG and providing reliable clinical evidence for screening high-risk individuals for CAG before endoscopic examination. To facilitate clinical application and promotion, this invention further develops a visual web platform based on the Shiny framework, namely a clinical prediction platform for chronic atrophic gastritis based on the random forest algorithm. Doctors can intuitively obtain individual CAG risk prediction values; the platform is easy to operate and highly practical. Attached Figure Description
[0018] Figure 1 This is a flowchart illustrating the research process of the prediction model of this invention.
[0019] Figure 2 This is a mind map of the prediction model of this invention.
[0020] Figure 3 This is a mind map of the prediction platform of this invention.
[0021] Figure 4This is a schematic diagram illustrating the predictor selection and model performance verification in Embodiment 1 of the present invention. (A) LASSO regression for predictor selection; (B) ROC curves of training set and test set; (C) Confusion matrix of training set; (D) Confusion matrix of test set; (E) Calibration curves of training set and test set; (F) Decision curves of training set and test set; (G) ROC curves of external validation set; (H) Confusion matrix of external validation set.
[0022] Figure 5 This is a schematic diagram of the SHAP model interpretation analysis in Embodiment 1 of the present invention. (A) In the figure, each point represents a feature, the horizontal axis represents the SHAP value, and the feature importance is sorted from top to bottom. Yellow dots represent higher feature values, i.e., the color at the top, and blue dots represent lower feature values, i.e., the color at the bottom; (B & C) are interpretability analyses of two independent samples: yellow represents a positive contribution to the model, and red represents a negative contribution to the model, where the right side is red and the left side is yellow. Detailed Implementation
[0023] The technical solutions in the embodiments of the present invention will be clearly and completely described below, so that those skilled in the art can better understand the advantages and features of the present invention, thereby making a clearer definition of the scope of protection of the present invention. The embodiments described in this invention are only some embodiments of the present invention, not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative effort are within the scope of protection of the present invention.
[0024] See Figures 1-2 The diagram shown is a flowchart and mind map of the research process for the clinical prediction model of chronic atrophic gastritis based on the random forest algorithm of this invention. The specific technical content includes the following steps: Step 1: Data collection and preprocessing. Clinical information of the research subjects is comprehensively collected through standardized questionnaires and clinical tests. The collected dataset contains one dependent variable and multiple potential independent variables. Preprocessing mainly includes data formatting, which converts the diagnosis column (which serves as the dependent variable) from a numerical type to a factor type to meet the requirements of the subsequent classification model.
[0025] In a specific embodiment of the present invention, the dependent variable is the patient's final diagnosis result, i.e. whether or not the patient has chronic atrophic gastritis (diagnosis), for example, "1" represents positive (having the disease) and "0" represents negative (not having the disease).
[0026] Furthermore, the potential independent variables of this invention, the collected original feature indicators, cover multiple dimensions, specifically including: 1) Serological markers: Helicobacter pylori (HP) antibody test results, pepsinogen I / II ratio (PGR).
[0027] 2) Demographic characteristics: gender, age, body mass index (BMI), and education level (Edu).
[0028] 3) Lifestyle factors: long-term smoking history (Smoke: smoking time greater than 6 months), long-term drinking history (Drink: drinking alcohol more than 3 times / week), long-term tea drinking history (Tea: drinking tea more than 1 time / week), food temperature preference (Temp: moderate temperature or too cold or too hot), frequency of fresh fruit intake (Fruit: at least 5 times per week), salt intake (Salt: whether it is excessive), sleep time (Sleep: actual sleep time per day) and sleep quality (Asleep: whether you often cannot fall asleep within 30 minutes, wake up easily at night or wake up early).
[0029] 4) Clinical symptoms: recurrent abdominal discomfort symptoms (such as abdominal pain, loss of appetite, bloating, heartburn, etc.).
[0030] 5) Personal and family medical history: history of hypertension, diabetes, cancer in first-degree relatives, and family history of gastric cancer.
[0031] The second step is dataset partitioning. To ensure the objectivity and reliability of model evaluation, the original dataset needs to be divided into independent training and test sets.
[0032] When partitioning the dataset, a random seed is set: a fixed random number seed (e.g., 6666) is set to ensure that the partitioning process is repeatable and facilitates the verification and reproduction of the results.
[0033] And stratified sampling partitioning: The `initial_split` function under the `tidymodels` framework is used to split the original dataset into two parts: 75% for training and 25% for testing. This partitioning process employs a stratified sampling strategy (strata = diagnosis) to ensure that the ratio of positive to negative samples of chronic atrophic gastritis in the split training and testing sets remains consistent with that in the original dataset.
[0034] The third step is feature selection. In order to select the most valuable features for predicting chronic atrophic gastritis from a large number of potential independent variables, reduce model redundancy, and improve the stability and interpretability of the model, this step uses Least Absolute Contraction and Selection Operator (LASSO) regression for feature selection.
[0035] First, LASSO regression is performed on the training set data partitioned in the second step. LASSO, by appending an L1 regularization term to the loss function, can compress the coefficients of some unimportant variables to zero, thus achieving automatic variable selection. Then, based on the results of the LASSO regression, feature variables with non-zero regression coefficients are selected. These variables are considered the core variables most closely related to the occurrence of chronic atrophic gastritis and have the strongest predictive power. Finally, the final input variables are determined.
[0036] In this invention, the variables ultimately selected for subsequent model construction include: HP, age, PGR, smoking history, drinking history, and family history of gastric cancer.
[0037] The fourth step is model framework definition and hyperparameter tuning, which is the process of building and optimizing the random forest prediction model based on the core variables selected in the third step.
[0038] 4.1 Define the model specification: Use the rand_forest() function to define the basic framework of a random forest model, and mark the number of decision trees (trees) and the minimum number of samples per node (min_n) as the terms to be tuned.
[0039] 4.2 Constructing the Workflow: The workflow() function is used to combine the model specification with the prediction formula. The dependent variable of this prediction formula is diagnosis, and the independent variables are all the core variables selected in step three.
[0040] 4.3 Setting the cross-validation strategy: The training set is divided using 5-fold cross-validation to robustly evaluate the performance of different hyperparameter combinations.
[0041] 4.4 Perform grid search optimization: Generate 100 sets of hyperparameter combinations through random search, train and evaluate them under the framework of 5-fold cross-validation, and use the area under the ROC curve (roc_auc) as the core criterion for selecting the best model.
[0042] 4.5 Selecting the optimal hyperparameters: After the tuning process is completed, the optimal combination of hyperparameters is selected based on the principle of maximizing roc_auc.
[0043] Step 5: Final Model Training and Generation 5.1 Solidify the optimal workflow: Apply the optimal hyperparameter combination selected in step 4 to the workflow.
[0044] 5.2 Training the final model: Apply this optimal workflow to the entire training dataset containing all core variables to obtain a final prediction model (final_rf) with optimal performance and the strongest generalization ability.
[0045] In this invention, to verify and comprehensively and objectively evaluate the performance and application value of the constructed model, a comprehensive performance verification of the model was conducted. One specific implementation method includes discrimination and classification performance evaluation, calibration evaluation, and clinical and application value evaluation. The discrimination and classification performance evaluation first involves ROC analysis, calculating the model's AUC value and its 95% confidence interval on the test set. Then, based on the ROC curve of the training set, the optimal classification threshold is determined using Youden's rule. This threshold is applied to the test set to generate a confusion matrix, and accuracy, sensitivity, specificity, positive predictive value (PPV), and negative predictive value (NPV) are calculated, thus completing the determination of the optimal threshold and classification evaluation.
[0046] The specific method for calibration assessment is to first plot a calibration curve, and then evaluate the reliability of the model's predicted probability by comparing the fit between the "average predicted probability" and the "actual disease rate".
[0047] The clinical application value assessment (decision curve analysis - DCA) method first plots a decision curve, and then quantifies the clinical applicability of the model at different risk thresholds by comparing the net benefits of the model strategy with the "full treatment" / "no treatment" baseline strategy.
[0048] As another specific embodiment of the present invention, it also includes model interpretability analysis. In order to open the "black box" of the random forest model and understand the internal logic of the model in making specific predictions, the present invention uses the SHAP method to provide an in-depth interpretation of the final model, the specific content of which is as follows: (1) Calculate the SHAP value: Using the kernelshap method, calculate the contribution of each feature to the prediction result of each sample for the final model final_rf generated in step 5, i.e., the SHAP value.
[0049] (2) Global interpretability analysis: By summarizing the SHAP values of all samples, feature importance bar charts and beeswarm plots are generated to show the overall impact of each feature on the model prediction.
[0050] (3) Local interpretability analysis: For a single case, the attribution of individual predictions can be clearly shown through force plot or waterfall plot.
[0051] (4) Feature interaction analysis: By drawing a SHAP dependency graph, the interaction effect between two features is analyzed.
[0052] See Figure 3 As shown, the clinical prediction visualization platform for chronic atrophic gastritis based on the random forest algorithm provided by this invention is a practical tool that can be directly used by clinicians and other end users based on the prediction model obtained by the above training. The conversion process includes the step of deploying the model as an interactive web calculator.
[0053] The specific steps include: (1) Technical framework: using the shiny package of R language as the development framework to build a dynamic web application.
[0054] (2) Build the application and server logic, where server logic refers to writing the backend server logic.
[0055] One specific embodiment of the application of the visualization platform of the present invention includes a user interface (UI): An intuitive user interface is designed. The left side of the interface is a sidebar input area, providing numerical input boxes (for age, PGR) and radio buttons (for HP, smoking history, drinking history, and family history of gastric cancer) for users to input various patient indicators. The right side of the interface is the main panel output area, designed with tabs to display "Prediction Results," "Variable Importance," and "Help Documentation," respectively.
[0056] When the user clicks the "Calculate Risk" button, the specific steps for prediction in this invention are as follows: a. Receive and integrate all input data.
[0057] b. Load the final model final_rf trained and saved in step 5.
[0058] c. Call the model to make real-time predictions on the newly input data and calculate the probability of disease risk.
[0059] d. Output the calculated probability values as percentages and risk levels (e.g., low, medium, high risk) on the "Prediction Results" page, and display them visually with a dynamic risk dashboard.
[0060] e. Extract variable importance information (such as Mean Decrease Gini) from the loaded model and plot a bar chart on the "Variable Importance" page.
[0061] The following specific embodiments further introduce and explain the clinical prediction model and prediction platform for chronic atrophic gastritis based on the random forest algorithm of the present invention. Example 1
[0062] Prior to implementation, the study was approved by the Ethics Committee of Wuxi People's Hospital affiliated with Nanjing Medical University and complied with all applicable laws, regulations, and ethical standards. The research protocol was submitted and approved for filing by the Research Ethics Committee of Wuxi People's Hospital (KY23001), and registered with the Chinese Clinical Trial Registry (ChiCTR2400085856). All participants signed informed consent forms before participating in the study and fully understood the research content, purpose, potential risks, and their personal rights.
[0063] This invention utilizes a machine learning prediction model built on the RandomForest algorithm to assess the risk of developing CAG in subjects. The study employed a retrospective cohort design, incorporating complete clinical data from 1268 subjects in the region who underwent gastric cancer screening.
[0064] The data collection included: 1) Serological indicators: HP antibody test results and PGR; 2) Demographic characteristics: gender, age, BMI and education level; 3) Lifestyle factors: long-term smoking history (whether smoking time is greater than 6 months), long-term alcohol consumption history (whether alcohol consumption frequency is greater than 3 times / week), long-term tea consumption history (whether tea consumption frequency is greater than 1 time / week), preferred food temperature, frequency of fresh fruit intake and salt intake, sleep time and sleep quality (whether it is often difficult to fall asleep within 30 minutes, easy to wake up at night or early to wake up); 4) Clinical symptoms including recurrent abdominal discomfort symptoms (such as abdominal pain, loss of appetite, bloating, heartburn, etc.); 5) Medical history: including history of hypertension and diabetes, family history of tumors and gastric cancer in first-degree relatives. See Table 1 for explanation of the included characteristic variables.
[0065] Table 1. Description of included feature variables Furthermore, 75% of the dataset was divided into training and 25% into a test set. Least Absolute Shrinkage and Selection Operator (LASSO) regression was used for feature selection to identify the features most relevant to CAG risk. Subsequently, based on the R language's tidymodels package, the RandomForest machine learning model was developed, validated, and optimized using a 5-fold cross-validation method. After constructing the optimal model, its performance was evaluated using various metrics including AUC, calibration curve, decision curve, specificity, and sensitivity. To improve the model's transparency and interpretability, the SHAP method was employed to interpret the prediction results and clarify the impact of each feature on the prediction.
[0066] 1. Data Acquisition and Preprocessing Of the 1375 participants in this study, 1268 were included after excluding those with missing clinical data and those pathologically diagnosed with gastric cancer. These included 619 participants with chronic gastric cancer (CAG) and 649 participants without CAG. Regarding continuous variables, the median progression-free survival (PGR) in the CAG group was 9.81 (interquartile range: 7.33–12.35), significantly lower than the 12.10 (10.10–14.20) in the non-CAG group, a statistically significant difference. P <0.001). In the history of H. pylori infection: the positive rate in the CAG group was 76.90%, which was much higher than the 27.12% in the non-CAG group ( P <0.001. Regarding age, the median age in the CAG group was 59 years (53.50–64.00), significantly higher than the 56 years (50.00–61.00) in the non-CAG group. P <0.001). BMI did not differ significantly between the two groups; the median BMI in the CAG group was 23.51 (21.63–25.44), and in the non-CAG group it was 23.38 (21.36–25.39). P = 0.762). Daily sleep duration was 7 hours (6–8 hours) in both groups, with no significant difference (P = 0.394). 28.27% of those with poor sleep quality were in the CAG group, compared to 30.82% in the non-CAG group; the difference was not statistically significant. P = 0.321). In terms of gender distribution, males accounted for 46.85% in the CAG group, higher than the 37.29% in the non-CAG group; while females accounted for 53.15%, lower than the 62.71% in the non-CAG group. P <0.001). Furthermore, in the male population, the proportion of non-atrophic gastritis was 45.49% and the proportion of atrophic gastritis was 54.51%, while in the female population, the proportion of non-atrophic gastritis was 55.30% and the proportion of atrophic gastritis was 44.70%. The difference in the distribution of gastritis diagnoses between the two groups was statistically significant (χ²=11.89, P<.001). Regarding education level, those with low education levels accounted for 75.12% in the CAG group and 71.65% in the non-CAG group; those with high education levels accounted for 24.88% and 28.35%, respectively. P = 0.162). P = 0.162). In the low-education group, the proportion of non-atrophic gastritis was 50.00%, and the proportion of atrophic gastritis was 50.00%. In the high-education group, the proportion of non-atrophic gastritis was 54.44%, and the proportion of atrophic gastritis was 45.56%. There was no statistically significant difference in the distribution of gastritis diagnoses between the two groups (χ²=1.95, P=0.162). The proportion of subjects with abdominal discomfort symptoms was 17.77% in the CAG group and 22.03% in the non-CAG group, with no statistically significant difference. P=0.058). Regarding lifestyle habits, the percentage of long-term smokers in the CAG group was 34.25%, higher than the 22.65% in the non-CAG group ( P <0.001); Long-term drinkers accounted for 19.71% in the CAG group and 16.33% in the non-CAG group, which was not statistically significant. P = 0.118); Long-term tea drinkers accounted for 32.63% in the CAG group, higher than the 26.81% in the non-CAG group ( P = 0.023). Regarding dietary preferences, 14.54% of those in the CAG group preferred excessively cold or hot foods, which was basically consistent with the 14.48% in the non-CAG group. P = 0.978); those with excessive salt intake accounted for 5.65% in the CAG group and 4.01% in the non-CAG group ( P = 0.170). Hypertensive patients accounted for 35.06% in the CAG group and 32.51% in the non-CAG group ( P = 0.338); the CAG rate in diabetic patients was 10.34% in the CAG group and 9.86% in the non-CAG group ( P = 0.778). The percentage of individuals with a family history of cancer was 31.02% in the CAG group and 30.35% in the non-CAG group. P = 0.798); the percentage of individuals with a family history of gastric cancer was 12.44% in the CAG group, higher than the 9.09% in the non-CAG group ( P = 0.054).
[0067] In summary, compared with the non-CAG group, the CAG group had significantly lower PGR levels (median 9.81 vs 12.10), significantly higher H. pylori infection positivity rates (76.90% vs 27.12%), and was older (median 59 vs 56). Significant gender differences were observed, with a higher proportion of men in the CAG group than in the non-CAG group (46.85% vs 37.29%), and significant differences in the distribution of gastritis types between men and women. Regarding lifestyle, the proportion of long-term smokers (34.25% vs 22.65%) and long-term tea drinkers (32.63% vs 26.81%) was significantly higher in the CAG group than in the non-CAG group.
[0068] 2. Predictor selection The 1268 enrolled patients were divided into a training set (n=950) and a test set (n=318). LASSO regression, as a compressed estimation method, achieved variable selection and model complexity adjustment by constructing an optimization objective function that includes a penalty term. See [link to relevant documentation] Figure 4As shown, the LASSO regression (λ.1se=0.031458) identified six key features of CAG: HP, PGR, smoking history, drinking history, age, and family history of gastric cancer. These six key variables were then incorporated into the model.
[0069] 3. Model Performance Testing The model was built using five repeated training iterations, and its performance was evaluated on both the training and test sets using the area under the ROC curve (AUC), specificity, and sensitivity. See [link to relevant documentation]. Figure 4 As shown in Figure A, the model's AUC on the training set is 0.8542, with a 95% CI of 0.8307–0.8777. (See Figure A for details.) Figure 4 As shown in B, the confusion matrix indicates that the model identified 341 true positive samples, 395 true negative samples, 91 false positive samples, and 123 false negative samples in the training set, with a specificity of 81.27% and a sensitivity of 73.49%. Figure 4 The AUC of A on the test set was 0.8073, with a 95% CI of 0.759–0.8557. Figure 4 The C confusion matrix showed that the model identified 112 true positive samples, 128 true negative samples, 35 false positive samples, and 43 false negative samples in the test set, with a specificity of 78.53% and a sensitivity of 72.26%. Figure 4 As shown in D,4E, the clinical utility of the model was evaluated through calibration curve and decision (DCA) curve analysis, and it was found that the model maintained stable performance between the training and test sets. Figure 4 As shown in F, the stability verification results based on 5-fold cross-validation show that the model's average AUC is 0.818, which also reflects that the model has stable performance.
[0070] 4. Interpretability Analysis This invention analyzes the decision-making mechanism of the RandomForest model in predicting CAG risk based on the SHAP interpretability framework. Features, ranked from highest to lowest importance, are: *Helicobacter pylori* infection status, age, pepsin ratio (PGR), smoking history, alcohol consumption history, and family history of gastric cancer. *Helicobacter pylori* positivity, decreased PGR, advanced age, long-term alcohol consumption, long-term smoking, and a family history of gastric cancer all positively contribute to the prediction results and significantly increase the risk of CAG. Figure 5 A). To gain a deeper understanding of the model's decision-making mechanism at the individual level, we... Figure 5 A detailed interpretability analysis was conducted on the two representative samples shown in B and 5C. Figure 5 B presents a subject who is 43 years old, has no history of smoking or drinking, or a family history of gastric cancer, is positive for serum HP antibody, has a PGR of 17.8, and has a low Shap value, which the model predicts is likely to be non-atrophic gastritis. Figure 5B presents a subject, aged 58, with no history of smoking or drinking, a family history of gastric cancer, positive serum Helicobacter pylori antibody, a PGR of 2.93, and a high Shap value, which the model predicts is likely to be atrophic gastritis. By visualizing the Shap values of these samples, we can clearly identify the specific impact of each feature on the model's predictions for these particular instances.
[0071] 5. Prediction Results Using the prediction platform of this invention, 120 subjects recruited from an early cancer screening cohort in another city in the province were selected as external validation subjects. Figure 4 After the analysis, the model's AUC value in the external validation queue was 0.8505. The confusion matrix showed that the model identified 39 true positive samples, 58 true negative samples, 13 false positive samples, and 10 false negative samples, with a specificity of 81.69% and a sensitivity of 79.59%. It can be concluded that the model of this invention has high stability and versatility.
[0072] The embodiments described above are merely illustrative of several implementations of the present invention, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the invention patent. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of the present invention, and these all fall within the protection scope of the present invention. Therefore, the protection scope of this invention patent should be determined by the appended claims.
Claims
1. A clinical prediction model for chronic atrophic gastritis based on the random forest algorithm, characterized in that: The prediction model construction process includes: Acquire clinical information, preprocess it to form a dataset, define training and test sets, and perform stratified sampling. The minimum absolute shrinkage and selection operator regression method are used for feature selection to determine the input variables and core variables, and a random forest prediction model is constructed. definition rand_forest The basic framework of the model under the () function is defined, the items to be tuned are marked, the workflow is constructed, the cross-validation strategy is set, the grid search tuning is performed, the model tuning is completed, and the best-performing set of hyperparameter combinations is selected. Solidify the optimal workflow to generate the final prediction model after training.
2. The method for constructing a clinical prediction model for chronic atrophic gastritis based on the random forest algorithm according to claim 1, characterized in that: It also includes validation of the final prediction model using a test set, including discrimination and classification performance evaluation, calibration evaluation, and clinical application value evaluation; The discrimination and classification performance evaluation first calculates the model's performance on the test set. AUC Values, 95% confidence intervals, and then, based on the training set... ROC The curve was analyzed, and the Yoden method was used to determine the optimal classification threshold. Finally, this threshold was applied to the test set to generate a confusion matrix, and the accuracy, sensitivity, specificity, and positive predictive value were calculated. PPV and negative predictive value NPV ; The calibration assessment is conducted by plotting a calibration curve and comparing the fit between the average predicted probability and the actual disease proportion to evaluate the reliability of the model's predicted probability. The clinical application value assessment is conducted by plotting decision curves and comparing the net benefits of the model strategy with the "full treatment" / "no treatment" baseline strategy to quantify the clinical applicability of the model at different risk thresholds.
3. The method for constructing a clinical prediction model for chronic atrophic gastritis based on the random forest algorithm according to claim 1, characterized in that: It also includes performing global and local interpretability analysis on the final prediction model using the test set; the global interpretability analysis is conducted by analyzing all samples... SHAP The values are summarized to generate feature importance bar charts and bee colony plots to show the overall impact of each feature on the model's predictions; The local interpretability analysis needle is used to visualize individual cases through force diagrams or waterfall plots, clearly showing the attribution of individual predictions.
4. The clinical prediction model for chronic atrophic gastritis based on the random forest algorithm according to claim 1, characterized in that: SHAP The value is used R Language kernelshap The package provides a method to calculate the contribution of each feature to the prediction result of each sample for the generated final model. Its core formula is:
5. Among them Φᵢ :feature i The SHAP value is the objective to be solved; F: The set of all features; S: A subset of the feature set F, not a feature set. i (i.e., S ⊆ F \ { i }); |S|: The number of features contained in subset S; |F|: The total number of features; f(S): The model's prediction when using features from subset S as input; For features not in S, the marginal distribution of that feature in the entire dataset is used to estimate the value. f(S ∪ { i }): Using subset S plus features i When used as input, the model's predicted value; [f(S ∪ {i}) - f(S)]: This is the feature. i The marginal benefit contributed within the context of an existing feature subset S; it measures the marginal benefit when features are... i Join the alliance S How much did the prediction results change afterward? ∑: For all features not included i The possible subsets S are summed, taking into account all possible ways in which feature i can cooperate with all other features.
6. The clinical prediction model for chronic atrophic gastritis based on the random forest algorithm according to claim 1, characterized in that: The numerical data of clinical information is preprocessed, including being converted into factor types, where the dependent variable is the patient's final diagnosis and the potential independent variables are the original feature indicators collected from multiple dimensions. Clinical information includes data collected from all study subjects through standardized questionnaires and clinical tests. The data includes one dependent variable and several potential independent variables. The dependent variable is whether the patient has chronic atrophic gastritis. Potential independent variables include serological indicators, demographic characteristics, lifestyle factors, clinical symptoms, and personal and family medical history.
7. The clinical prediction model for chronic atrophic gastritis based on the random forest algorithm according to claim 1, characterized in that: When dividing into stratified sampling groups, the method used is... tidymodels Under the framework initial_split The function divides the original dataset into two parts: 75% as the training set and 25% as the test set. Stratified sampling is used, and the ratio of positive to negative samples of chronic atrophic gastritis in the divided training and test sets is kept consistent with that in the original dataset.
8. The clinical prediction model for chronic atrophic gastritis based on the random forest algorithm according to claim 1, characterized in that: During feature selection, the training set partitioned by stratified sampling is processed using operator regression, and an operator is appended to the loss function. L1 The regularization term compresses the coefficients of some unimportant variables to zero. The variables whose coefficients are compressed to zero are those included in the model. HP ,age, PGR Smoking history, drinking history, and family history of stomach cancer.
9. The clinical prediction model for chronic atrophic gastritis based on the random forest algorithm according to claim 1, characterized in that: The optimization parameters include the number of decision trees and the minimum sample size per node; the workflow uses... workflow The () function combines the model specification with the prediction formula, where the dependent variable of the prediction formula is diagnosis The independent variable is the core variable; the grid search optimization is achieved by generating a certain threshold number of hyperparameter combinations through random search, training and evaluation within a 5-fold cross-validation framework, and then using... ROC Area under the curve roc_auc As a core criterion for selecting the best model, the process of maximizing the lower area... roc_auc The corresponding combination of hyperparameters is the one that performs best.
10. A clinical prediction visualization platform for chronic atrophic gastritis based on the random forest algorithm, characterized in that: The prediction platform is a tool for end-users to calculate the clinical risk of chronic atrophic gastritis, based on the random forest algorithm described in any one of claims 1-7. The transformation includes using… R Language shiny Packages serve as development frameworks, building a dynamic... Web Applications; building user interfaces and server logic; Complete the process of deploying the model as an interactive web-based calculator.
11. A clinical prediction visualization platform for chronic atrophic gastritis based on random forest algorithm, characterized in that: The steps for calculating the clinical predictive risk of chronic atrophic gastritis using a predictive platform are as follows: (1) Receive and integrate all input data; (2) Load the final model trained and saved in the clinical prediction model of chronic atrophic gastritis based on random forest algorithm as described in any one of claims 1-8; (3) Call the model to make real-time predictions on the newly input data and calculate the probability of disease risk; (4) Output the calculated probability values as percentages and risk levels, including low risk, medium risk and high risk, on the "Prediction Results" page, and display them visually with a dynamic risk dashboard. (5) Extract variable importance information from the loaded model, including Mean Decrease Gini And draw a bar chart on the "Variable Importance" page.