BackgroundGastric cancer is one of the most common malignant tumors worldwide, with high incidence and mortality rates, and it has a complex etiology and complex pathological features. Depending on the tumor type, gastric cancer can be classified as intestinal-type and diffuse-type gastric cancer, each with distinct pathogenic mechanisms and clinical presentations. In recent years, machine learning techniques have been widely applied in the medical field, offering new perspectives for the diagnosis, treatment, and prognosis of gastric cancer patients.MethodsThis study recruited 2158 gastric cancer patients and constructed prognostic prediction models for both intestinal-type and diffuse-type gastric cancer. Clinical pathological data were collected from patients, and machine learning algorithms were used for feature selection and model construction. The performance of the models was validated with training and testing datasets. The Shapley additive explanations (SHAP) values were used to interpret the model predictions and identify the main factors that influence patient survival.ResultsIn the prognostic model for intestinal-type gastric cancer, the gradient boosting decision tree (GBDT) model demonstrated the best performance, with key features including pTNM, CA125, tumor size, CA199, and PALB. Similarly, in the prognostic model for diffuse-type gastric cancer, the GBDT model was utilized, with key features comprising pTNM, Borrmann type IV disease, lymphocyte (LYM), lactate dehydrogenase (LDH), potassium (K), perineural invasion (PNI), tumor size, and whole stomach location. Risk stratification analysis revealed that the prognosis of high-risk patients was significantly worse than that of low-risk patients.ConclusionMachine learning shows great potential in predicting survival outcomes of gastric cancer patients, providing strong support for the development of personalized treatment plans.