Accurate identification and prediction of food safety risks are crucial for enhancing modern food safety assurance capacity. Given the complex nature of food safety risks and inefficiencies in regulatory processes, establishing a reliable early warning mechanism can help address the challenge of excessive regulatory resource investment and low efficiency in China. This study uses sampling data comprising over 180,000 agricultural products collected from Shanghai, Guangzhou, and Shenzhen between January 2023 and March 2025 to develop a machine learning-based risk prediction model for assessing agricultural product safety. Predictive features are ranked based on their contributions to risk, and the influence of key features on risk levels is examined using econometric analysis. An eXtreme Gradient Boosting (XGBoost) model is constructed, and model interpretability is assessed using SHAP values and probit regression. The model achieves a recall of 75.4% and a precision of 71.9%, indicating robust predictive performance. Food safety risks are closely found to be associated with five key dimensions: supply chain stages, regions, government supervision intensity, product categories, and weather conditions. By integrating machine learning with interpretable analysis, this study provides actionable insights for urban food safety management and supports targeted regulatory strategies for agricultural products in these megacities.
Wu et al. (Wed,) studied this question.