Search for a command to run...
Food safety is still a global public health issue. Every year, more than 600 million people get sick from foodborne illnesses because of unsafe handling, bad vendor practices, and not enough predictive surveillance. Current studies reveal substantial discrepancies between consumer and vendor knowledge, attitudes, and practices (KAP) and actual contamination outcomes, especially in low- and middle-income nations. To mitigate these constraints, this study introduces an innovative Machine Learning–Driven Framework for Safeguarding Consumer Food Safety, amalgamating behavioral, environmental, and microbiological data into a cohesive predictive model. The suggested system uses hybrid ensemble learning, which combines Random Forest, Gradient Boosting, and Support Vector Machines, to figure out the risk of contamination and sort hazards into different levels. A dataset comprising 10,000 consumer-vendor interactions and 1,200 microbiological samples was subjected to a 10-fold cross-validation protocol for analysis. The model had an accuracy of 94.6%, an F1-score of 0.93, and an AUC of 0.96 (p < 0.001), which was 8.4% better than baseline models. An analysis of feature importance showed that vendor hygiene compliance, food temperature, and consumer awareness were the most important factors. SHAP-based feature attribution made sure that the model was explainable, which made it easier to understand for policy and regulatory use. The proposed framework offers a scalable, privacy-preserving instrument for early contamination forecasting and evidence-based intervention formulation. Future extensions will investigate federated learning and IoT integration to facilitate real-time monitoring and adaptive risk management in various food systems.