In recent years,food safety incidents have been frequent,and various types of food safety problems of substandard quality have been reported and exposed.Food safety is a matter of people’s health,therefore,there is an urgent need to develop safety risk prediction techniques for food that can accurately predict food safety risks in daily life and important activities.In this paper,we use the temporal knowledge graphs to predict food risks,make predictions about the food safety risks that may have to occur in the future moment,and build a question and answer system to process the predicted results.First,for the food safety risk to be predicted at the current moment,a food safety prediction model based on heterogeneous graph attention network is constructed applicable to on-site sampling.The food safety knowledge graph is built by selecting five major categories of food sampling data commonly found in daily life as the food safety dataset,and using the dataset to train the food safety risk research model built based on the heterogeneous graph attention network.The model prediction accuracy is90%,and the effective risk prediction is made for the food being tested,and the result can be used as the input of the food safety temporal knowledge graph prediction model for the next moment.Second,a temporal prediction model was constructed that could be used to predict food safety risks at future moments.A set of evaluation index system that can be used for food safety risk evaluation is designed.Based on the established index system,five major categories of food sampling data commonly used in daily life are selected as the research objects,and the data set is analyzed temporally by building a food safety temporal knowledge graph,and then the data is used to train a food safety temporal prediction model based on the temporal knowledge graph network,so as to determine the risk level of food.The accuracy of the model was obtained as The final accuracy of the model was 86.15%,and the Mean Reciprocal Rank(MRR)was 88.35%.The model was compared with other temporal networks to demonstrate its good performance and can be applied to predict the food safety risk in future moments.Finally,for the content of food safety risk prediction,a question and answer system was established to analyze the prediction results and provide auxiliary reference for experts’ decision making,such as statistical events and hazard treatment.Based on the Flask technology,external interfaces were provided for the food safety risk prediction model and the food safety risk temporal prediction model,and the interfaces were subsequently tested through the Postman platform,and the results showed that the interfaces operated stably and could accomplish the expected goals. |