CN113934863B - Food safety risk prediction method and device, electronic equipment and medium - Google Patents

Food safety risk prediction method and device, electronic equipment and medium Download PDF

Info

Publication number
CN113934863B
CN113934863B CN202111154651.2A CN202111154651A CN113934863B CN 113934863 B CN113934863 B CN 113934863B CN 202111154651 A CN202111154651 A CN 202111154651A CN 113934863 B CN113934863 B CN 113934863B
Authority
CN
China
Prior art keywords
data
moment
entity
food safety
entity data
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202111154651.2A
Other languages
Chinese (zh)
Other versions
CN113934863A (en
Inventor
史运涛
周锴
李书钦
张荫芬
王力
董哲
殷翔
周萌
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
North China University of Technology
China National Institute of Standardization
Original Assignee
North China University of Technology
China National Institute of Standardization
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by North China University of Technology, China National Institute of Standardization filed Critical North China University of Technology
Priority to CN202111154651.2A priority Critical patent/CN113934863B/en
Publication of CN113934863A publication Critical patent/CN113934863A/en
Application granted granted Critical
Publication of CN113934863B publication Critical patent/CN113934863B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q10/00Administration; Management
    • G06Q10/06Resources, workflows, human or project management; Enterprise or organisation planning; Enterprise or organisation modelling
    • G06Q10/063Operations research, analysis or management
    • G06Q10/0635Risk analysis of enterprise or organisation activities
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/36Creation of semantic tools, e.g. ontology or thesauri
    • G06F16/367Ontology
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q50/00Systems or methods specially adapted for specific business sectors, e.g. utilities or tourism
    • G06Q50/10Services
    • G06Q50/26Government or public services
    • G06Q50/265Personal security, identity or safety

Abstract

The invention provides a method, a device, electronic equipment and a medium for predicting food safety risk, wherein the method comprises the following steps: acquiring and analyzing historical food safety risk events to obtain each entity data and corresponding timestamp data thereof, and constructing quaternary group data according to each entity data and corresponding timestamp data thereof to obtain a knowledge graph; aggregating each head entity data and tail entity data corresponding to the head entity data at each time in the knowledge graph through a preset aggregator to obtain each local data at each time; determining corresponding global data based on each local data at each moment, and training a preset neural network through the global data at each moment and each corresponding local data to obtain a food safety knowledge map model; and determining the input moment to be predicted, and predicting the food safety risk at the moment to be predicted based on the food safety knowledge graph model. The method improves the prediction accuracy through a time-series food safety knowledge map model.

Description

Food safety risk prediction method and device, electronic equipment and medium
Technical Field
The invention relates to the technical field of data processing and risk prediction, in particular to a food safety risk prediction method, a food safety risk prediction device, electronic equipment and a medium.
Background
At present, the main method for predicting the food safety risk is a traditional prediction method, namely a static analysis method based on expert experience knowledge scoring. As machine learning is widely applied to risk study and judgment and risk inference, a static knowledge graph based on static data inference, which combines machine learning and a conventional prediction method, is widely applied to food safety risk prediction. The static knowledge graph processes the data by extracting the characteristics of the head entity data and the characteristics of the connected tail entity data to draw a conclusion, however, the method cannot solve the problem that the food data changes continuously along with the time change in the actual situation, cannot update and intercept effective information in real time, neglects the influence existing among the data, and reduces the accuracy of food safety risk prediction.
Disclosure of Invention
The invention provides a food safety risk prediction method, a food safety risk prediction device, electronic equipment and a medium, and aims to improve the accuracy of food safety risk prediction.
The invention provides a food safety risk prediction method, which comprises the following steps:
acquiring and analyzing historical food safety risk events to obtain each entity data and corresponding timestamp data thereof, and constructing corresponding quadruple data according to each entity data and corresponding timestamp data thereof to obtain a corresponding knowledge graph, wherein the entity data comprises head entity data and tail entity data;
aggregating each head entity data and tail entity data corresponding to the head entity data at each time in the knowledge graph through a preset aggregator to obtain each local data at each time;
determining corresponding global data based on each local data at each moment, and training a preset neural network through the global data at each moment and each local data corresponding to the global data at each moment to obtain a food safety knowledge map model;
and determining the input moment to be predicted, and predicting the food safety risk of the moment to be predicted based on the food safety knowledge graph model.
According to the food safety risk prediction method provided by the invention, the step of aggregating each head entity data and corresponding tail entity data in the knowledge graph at each time by a preset aggregator to obtain each local data at each time comprises the following steps:
classifying the tail entity data corresponding to each head entity data according to the relationship characteristics of the entity relationship corresponding to each head entity data at each time, and correspondingly obtaining tail entity data with a plurality of relationship characteristics;
aggregating tail entity data with the same relationship characteristics corresponding to the head entity data at each time through the preset aggregator to obtain new head entity data at each time;
and re-aggregating each new head entity data at each moment through the preset aggregator to obtain each local data at each moment.
According to the food safety risk prediction method provided by the invention, the step of determining the corresponding global data based on each local data at each moment, and training the preset neural network through the global data at each moment and each local data corresponding to the global data at each moment to obtain the food safety knowledge map model comprises the following steps:
performing maximum pooling operation on each local data at each moment to obtain maximum local data at each moment, and acquiring previous-moment global data and previous-moment local data corresponding to previous moments at each moment;
obtaining global data at each moment according to the maximum local data at each moment and the corresponding global data at the previous moment;
obtaining target local data at each moment based on the global data at each moment, each corresponding local data thereof and the corresponding local data at the last moment;
and training the preset neural network based on the global data and the corresponding target local data at each moment to obtain the food safety knowledge map model.
According to the food safety risk prediction method provided by the invention, the step of predicting the food safety risk at the moment to be predicted based on the food safety knowledge graph model comprises the following steps:
establishing a combined distribution corresponding to all food safety risk events based on the time sequence in the food safety knowledge graph model;
converting the combined distribution into a corresponding conditional distribution sequence, and determining historical food events related to the events at the moment to be predicted;
obtaining the food safety condition probability corresponding to the moment to be predicted according to the condition distribution sequence and the historical food event;
and predicting the food safety risk at the moment to be predicted according to the food safety condition probability.
According to the food safety risk prediction method provided by the invention, the step of obtaining the food safety conditional probability corresponding to the moment to be predicted according to the condition distribution sequence and the historical food event comprises the following steps:
constructing a corresponding target joint distribution according to the conditional distribution sequence and the historical food events, wherein the target joint distribution comprises a first conditional probability distribution, a second conditional probability distribution and a third conditional probability distribution;
and obtaining the food safety condition probability according to the first condition probability distribution, the second condition probability distribution and the third condition probability distribution.
According to the method for predicting the food safety risk provided by the invention, the step of obtaining the food safety conditional probability according to the first conditional probability distribution, the second conditional probability distribution and the third conditional probability distribution comprises the following steps:
determining head entity conditional probability corresponding to the time to be predicted based on the first conditional probability distribution, and sampling the head entity data to be predicted at the time to be predicted;
generating entity relation probability of the head entity data to be predicted and the historical food events at the moment to be predicted based on the second conditional probability distribution;
determining the tail entity conditional probability corresponding to the moment to be predicted based on the third conditional probability distribution;
and obtaining the food safety conditional probability according to the head entity conditional probability, the entity relation conditional probability and the tail entity conditional probability.
According to the food safety risk prediction method provided by the invention, the step of constructing corresponding quadruple data according to each entity data and the corresponding timestamp data thereof to obtain a corresponding knowledge graph comprises the following steps of:
establishing an entity relationship between each head entity data and the corresponding tail entity data according to the data characteristics of the entity data;
adding the timestamp data of each head entity data into the entity relationship of each head entity data to obtain each entity relationship carrying the timestamp data;
constructing corresponding quaternary group data according to the head entity data, the tail entity data corresponding to the head entity data and the corresponding entity relationship carrying the timestamp data;
determining a set of each of the quadruple data as the knowledge-graph.
The invention also provides a food safety risk prediction device, comprising:
the system comprises a construction module, a data analysis module and a data analysis module, wherein the construction module is used for acquiring and analyzing historical food safety risk events, acquiring each entity data and corresponding timestamp data thereof, and constructing corresponding quadruple data according to each entity data and corresponding timestamp data thereof to acquire a corresponding knowledge graph, wherein the entity data comprises head entity data and tail entity data;
the aggregation module is used for aggregating each head entity data and the corresponding tail entity data at each time in the knowledge graph through a preset aggregator to obtain each local data at each time;
the determining module is used for determining corresponding global data based on the local data at each moment, and training a preset neural network through the global data at each moment and the corresponding local data to obtain a food safety knowledge map model;
and the prediction module is used for determining the input moment to be predicted and predicting the food safety risk at the moment to be predicted based on the food safety knowledge map model.
The invention also provides an electronic device, which comprises a memory, a processor and a computer program stored on the memory and capable of running on the processor, wherein the processor executes the program to realize the steps of the food safety risk prediction method.
The present invention also provides a non-transitory computer readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of the food safety risk prediction method as described in any of the above.
The invention also provides a computer program product comprising a computer program which, when executed by the processor, carries out the steps of the food safety risk prediction method according to any one of the above.
According to the food safety risk prediction method, the food safety risk prediction device, the electronic equipment and the medium, each entity data and the corresponding timestamp data thereof are obtained by acquiring and analyzing historical food safety risk events, and quaternary group data is constructed according to each entity data and the corresponding timestamp data thereof to obtain a knowledge graph; aggregating each head entity data and tail entity data corresponding to the head entity data at each time in the knowledge graph through a preset aggregator to obtain each local data at each time; determining corresponding global data based on each local data at each moment, and training a preset neural network through the global data at each moment and each corresponding local data to obtain a food safety knowledge map model; and determining the input moment to be predicted, and predicting the food safety risk at the moment to be predicted based on the food safety knowledge graph model. Therefore, the knowledge graph with the time sequence is constructed, the entity data can be updated in real time to change along with the change of time, and meanwhile, the food safety knowledge graph model is obtained by training the knowledge graph with the time sequence, so that the food safety knowledge graph model has the time sequence and high accuracy, the food safety risk at a certain future time (to-be-predicted time) can be accurately predicted, and the accuracy of the prediction of the food safety risk is improved.
Drawings
In order to more clearly illustrate the present invention or the technical solutions in the prior art, the drawings used in the embodiments or the description of the prior art will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings can be obtained by those skilled in the art without creative efforts.
FIG. 1 is a schematic flow chart of a method for predicting food safety risk provided by the present invention;
FIG. 2 is a second schematic flow chart of a method for predicting food safety risk according to the present invention;
FIG. 3 is a third schematic flow chart of a method for predicting food safety risk according to the present invention;
FIG. 4 is a fourth schematic flowchart of a method for predicting food safety risk provided by the present invention;
FIG. 5 is a schematic structural diagram of a food safety risk prediction device provided by the present invention;
fig. 6 is a schematic structural diagram of an electronic device provided in the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings, and it is obvious that the described embodiments are some, but not all embodiments of the present invention. All other embodiments, which can be obtained by a person skilled in the art without inventive step based on the embodiments of the present invention, are within the scope of protection of the present invention.
The following describes a method, an apparatus, an electronic device and a medium for predicting food safety risk provided by the present invention with reference to fig. 1 to 6.
Specifically, the present invention provides a food safety risk prediction method, and referring to fig. 1, fig. 1 is one of the flow diagrams of the food safety risk prediction method provided by the present invention.
Embodiments of the present invention provide embodiments of a food safety risk prediction method, and it should be noted that although a logical order is shown in the flow chart, under certain data, the steps shown or described may be performed in an order different from that shown or described herein.
The method provided by the embodiment of the invention takes an electronic device as an execution subject for example, and the method for predicting the food safety risk comprises the following steps:
step S10, historical food safety risk events are obtained and analyzed, entity data and corresponding timestamp data are obtained, corresponding quadruple data are constructed according to the entity data and the corresponding timestamp data, and a corresponding knowledge graph is obtained, wherein the entity data comprise head entity data and tail entity data.
It should be noted that the risk prediction system in the embodiment of the present invention is one of the expressions of the electronic device, and is not limited to the electronic device.
The risk prediction system acquires historical food safety risk events, performs data analysis on the historical food safety risk events, and determines each entity data contained in the historical food safety risk events and timestamp data corresponding to each entity data, wherein the entity data comprise head entity data and tail entity data.
Meanwhile, the risk prediction system needs to determine an entity relationship between each head entity data and the corresponding tail entity data, construct corresponding quadruple data according to each head entity data, the corresponding tail entity data, the corresponding entity relationship and the timestamp data, and determine a set of all quadruple data as a knowledge graph to be constructed. The food safety risk events mainly include accidents caused by food safety risks, such as food poisoning and food allergy, and the sources of the food safety risks (entity data) researched by the invention are mainly various hazards contained in food or food raw materials or externally added, and the hazards include various fungi, heavy metal substances, pesticide and veterinary drugs, chemical fertilizers, food additives and the like which are a general term for threatening food safety. The data types of the entity data in the knowledge graph comprise but are not limited to food raw materials, edible articles, food safety risks and external interventions, and the entity relations comprise but are not limited to various hazard content levels, risks and interventions.
It should be noted that the relevant variables and concepts in the constructed knowledge graph are as follows. The knowledge graph can be represented as G = (V, E, T), where V is entity data, E is entity relationship, and T is timestamp data. An entity data set may be represented as V = { V = } 1 ,v 2 ,v 3 ...v N N is the number of entity data, and the entity relationship can be represented as E = { r = } 1 ,r 2 ,r3...r m M is the number of entity relationships, and the timestamp data can be represented as T = { T = } 1 ,t 2 ,t 3 ...t n And n is the number of the time stamp data. The knowledge map is a set composed of quadruplet data, and information of objective facts represented by each quadruplet data can be represented as<v h ,r s ,v o ,t s >Wherein v is h For header entity data, v o For tail entity data, v h And v o ∈V。r s For the entity relationship between the head entity data and the tail entity data, r s ∈E。t s For header entity dataCorresponding time stamp data, t s ∈T。
Further, the specific description of steps S101 to S104 is as follows:
step S101, according to the data characteristics of entity data, establishing an entity relationship between each head entity data and corresponding tail entity data;
step S102, adding the timestamp data of each head entity data to the entity relationship of each head entity data to obtain each entity relationship carrying the timestamp data;
step S103, constructing corresponding quaternary group data according to the head entity data, the tail entity data corresponding to the head entity data and the entity relation carrying the timestamp data corresponding to the tail entity data;
step S104, determining the set of the quadruple data as the knowledge graph.
Specifically, the risk prediction system establishes an entity relationship between each head entity data and the corresponding tail entity data according to data characteristics that interaction between entity data (food raw materials, edible products and food sampling toxic substances) may have risks and data characteristics that future entity data can be linked, inherited and continued with past and present entity data. And then, adding the timestamp data corresponding to each head entity data into the corresponding entity relationship by the risk prediction system to obtain the entity relationship carrying the timestamp data corresponding to each head entity data. And the risk prediction system constructs corresponding quaternary group data according to the head entity data, the tail entity data corresponding to the head entity data and the corresponding entity relationship carrying the timestamp data, and determines the set of all quaternary group data as the knowledge graph to be constructed.
According to the embodiment, the timestamp data is added on the basis of the triple data of the head entity data, the tail entity data and the entity relation, the knowledge graph of the triple data is constructed through the timestamp data, and the change of the entity data along with the time change is determined in real time through the knowledge graph of the triple data, so that the entity data has timeliness, and the accuracy of food safety risk prediction is improved.
And S20, aggregating the head entity data and the tail entity data corresponding to the head entity data at each time in the knowledge graph through a preset aggregator to obtain each local data at each time.
And the risk prediction system determines tail entity data corresponding to each head entity data at each moment according to the timestamp data of each head entity data, and determines an entity relationship corresponding to each tail entity data. And classifying the corresponding tail entity data by the risk prediction system according to the relationship characteristics of the entity relationship corresponding to the head entity data at each moment to obtain the tail entity data of each relationship characteristic, wherein the relationship characteristics comprise relationship types, relationship directions and self-connection relationships. Then, the risk prediction system aggregates tail entity data having the same relationship characteristic and corresponding to each head entity data at each time through a preset aggregator to obtain new head entity data corresponding to each head entity data at each time, where the preset aggregator is selected and set in advance, and this embodiment is not limited. And finally, the risk prediction system carries out polymerization on each new head entity data at each moment again to obtain local data corresponding to each head entity data at each moment.
And S30, determining corresponding global data based on the local data at each moment, and training a preset neural network through the global data at each moment and the corresponding local data to obtain a food safety knowledge map model.
It should be noted that, in the neural network, training can be performed only after parameterization of each entity data and entity relationship in the knowledge graph is required, so that the global variable Q is introduced in the embodiment t (Global data) and local variables q t (local data). Global data Q t Global information of the knowledge-graph before representing the time stamp data t. Local data q t Representing individual header entity data v h Or a pair of head entity data and entity relationships (v) h ,r s ) Thus, the local data may also be denoted as q t (v h ) Or q t (v h ,r s )。
The risk prediction system performs maximum pooling operation on each local data at each moment to obtain the maximum local data at each moment, and then obtains the global data Q of the previous moment corresponding to each moment t-1 And local data q at the previous time t-1 The maximum local data at each moment and the corresponding global data Q at the previous moment are acquired through a preset neural network t-1 Training is carried out to obtain global data Q at each moment t . Next, the risk prediction system passes the global data Q at each time t And each corresponding local data and the corresponding local data q at the previous moment t-1 And training to obtain corresponding target local data at each moment, and training the preset neural network according to the global data and the corresponding target local data at each moment to obtain a corresponding food safety knowledge map model. The preset neural network is preset, and the embodiment is not limited.
And S40, determining the input moment to be predicted, and predicting the food safety risk at the moment to be predicted based on the food safety knowledge graph model.
It should be noted that, if a user needs to predict a food safety risk at a certain time, a corresponding time to be predicted needs to be input into the risk prediction system, or the time to be predicted needs to be sent to the risk prediction system through a user terminal.
And after receiving the time to be predicted, the risk prediction system inputs the time to be predicted into the food safety knowledge graph model, and conjectures the conditional probability of the head entity data, the conditional probability of the entity relationship and the conditional probability of the tail entity data of the time to be predicted according to the food safety knowledge graph model. And then, predicting the food safety risk at the moment to be predicted by the risk prediction system according to the conditional probability of the head entity data, the conditional probability of the entity relationship and the conditional probability of the tail entity data.
The embodiment provides a food safety risk prediction method, which includes the steps of obtaining and analyzing historical food safety risk events to obtain entity data and corresponding timestamp data, and constructing quadruple data according to the entity data and the corresponding timestamp data to obtain a knowledge graph; aggregating each head entity data and tail entity data corresponding to the head entity data at each time in the knowledge graph through a preset aggregator to obtain each local data at each time; determining corresponding global data based on each local data at each moment, and training a preset neural network through the global data at each moment and each corresponding local data to obtain a food safety knowledge map model; and determining the input moment to be predicted, and predicting the food safety risk at the moment to be predicted based on the food safety knowledge graph model. Therefore, in the embodiment, the knowledge graph with the time sequence is constructed, the entity data can be updated in real time and change along with the time change, and meanwhile, the food safety knowledge graph model is obtained by training the knowledge graph with the time sequence, so that the food safety knowledge graph model has the time sequence and high accuracy, the food safety risk at a certain future time (to-be-predicted time) can be accurately predicted, and the accuracy of predicting the food safety risk is improved.
Further, referring to fig. 2, fig. 2 is a second schematic flow chart of the food safety risk prediction method provided by the present invention, and the step S20 includes:
s201, classifying the tail entity data corresponding to each head entity data according to the relationship characteristics of the entity relationship corresponding to each head entity data at each time, and correspondingly obtaining tail entity data with a plurality of relationship characteristics;
s202, aggregating tail entity data which are corresponding to the head entity data and have the same relation characteristics at each time through the preset aggregator to obtain new head entity data at each time;
and S203, re-aggregating each new head entity data at each moment through the preset aggregator to obtain each local data at each moment.
It should be noted that the preset aggregator in this embodiment is for aggregating information related to entity data to assist in predicting food safety events. In consideration of the diversity of entity data and entity relationships in the knowledge Graph, the embodiment cannot select a Graph Convolution Network (GCN) suitable for the same composition, and the embodiment selects a multiple Relationship Graph Convolution Network (RGCN) suitable for the different composition as a preset aggregator (RGCN aggregator), where the Graph Convolution Network is a general aggregator, and can aggregate information of multiple relationships of entity data in the knowledge Graph.
According to the relationship characteristics (relationship type, relationship direction and self-connection relationship) of the entity relationship corresponding to each head entity data at each moment, the risk prediction system classifies the tail entity data corresponding to each head entity data to correspondingly obtain tail entity data with a plurality of relationship characteristics, namely, the tail entity data with the same relationship type, the same relationship direction and the same self-connection relationship are classified into the tail entity data with one relationship characteristic. And then, the risk prediction system aggregates tail entity data which are corresponding to the head entity data and have the same relation type, the same relation direction and the same self-connection relation at each moment through an RGCN aggregator to obtain new head entity data at each moment. And finally, the risk prediction system carries out re-aggregation on each new head entity data at each moment through the RGCN aggregator to obtain local data corresponding to each head entity data at each moment.
It should be further noted that, because the RGCN considers heterogeneous graph modeling, when processing the tail entity data, the tail entity data is classified according to different entity relationships, and different weight parameters are set for the tail entity data of each entity feature. The RGCN polymerizer has the following formula:
Figure BDA0003288273530000121
wherein R represents all entity relation sets in the knowledge graph,
Figure BDA0003288273530000122
representation and header entity data v h The number of tail entity data having r entity relationships. c. C v Is a normalized parameter, this example selects c v Representation and header entity data v h Number of tail entity data having r relation, i.e.
Figure BDA0003288273530000123
Representing the weight parameter corresponding to the tail entity data with r entity relationship,
Figure BDA0003288273530000124
an entity feature representing the entity data of the tail,
Figure BDA0003288273530000125
is the weight parameter corresponding to the header entity data itself,
Figure BDA0003288273530000126
entity characteristics representing header entity data. The local graph structure of each connection between entity relationships and entity data is determined by aggregating information of tail entity data of head entity data,
namely, it is
Figure BDA0003288273530000127
And generating a piece of information under the relationship of the converged homogeneous entity on each head entity data. By aggregating the messages for all entity relationships in the knowledge-graph,
namely, it is
Figure BDA0003288273530000131
Further computing each head entityThe overall information of the data. Finally, by adding the entity information of each header entity data itself, i.e. w o q vh Then obtaining local data q through a ReLU (Rectified Linear Unit) activation function, namely
Figure BDA0003288273530000132
The embodiment provides a food safety risk prediction method, and the embodiment classifies tail entity data corresponding to each head entity data according to relationship characteristics of entity relationships corresponding to each head entity data at each time, and correspondingly obtains tail entity data with a plurality of relationship characteristics; aggregating tail entity data with the same relation characteristics corresponding to each head entity data at each time through a preset aggregator to obtain each new head entity data at each time; and re-aggregating each new head entity data at each moment through a preset aggregator to obtain each local data at each moment. Therefore, in the embodiment, according to the relationship type, the relationship direction and the self-connection relationship of the head entity data, the RGCN aggregator classifies and aggregates the tail entity data at each moment, so that each local data at each moment is accurately obtained, a basic condition is provided for training accurate global data, and meanwhile, a guarantee is provided for improving the accuracy of food safety risk prediction.
Further, referring to fig. 3, fig. 3 is a third schematic flowchart of the food safety risk prediction method provided by the present invention, and the step S30 includes:
step S301, performing maximum pooling operation on each local data at each time to obtain maximum local data at each time, and obtaining previous-time global data and previous-time local data corresponding to previous time at each time;
step S302, obtaining global data at each moment according to the maximum local data at each moment and the corresponding global data at the last moment;
step S303, obtaining target local data at each moment based on the global data at each moment, the corresponding local data at each moment and the corresponding local data at the previous moment;
and S304, training the preset neural network based on the global data and the corresponding target local data at each moment to obtain the food safety knowledge graph model.
It should be noted that, if it is necessary to predict an event to be generated in the future according to an existing event in the past, a Neural Network capable of storing and memorizing past event information and predicting a future event is required. The recurrent neural network is a neural network for time series data, which refers to data collected at different time points, and such data reflects the state or degree of change of a certain object, phenomenon, and the like over time. The core of the recurrent neural network is to cyclically use parameters of a network layer, simultaneously avoid parameter surge caused by time step increase, introduce a Hidden State (Hidden State) for recording historical information, and effectively process historical relevance of the information. The hidden state can capture historical information of the event at the current moment, and meanwhile, the number of the parameters of the recurrent neural network model does not increase along with the increase of time. As can be seen from the description of step S30, the global data is represented as Q t The local data is denoted as q t (v h ) Or q t (v h ,r s ),
The risk prediction system performs maximum pooling operation on each local data at each moment, selects the maximum local data at each moment, and performs maximum pooling operation on the local data at each moment
Figure BDA0003288273530000141
Defined as the current timestamp data t and the header entity data v h All events of interest, procedure for max pooling operation as follows g
Figure BDA0003288273530000142
g(G t ) Is time stamp dataAll food information on t G t A set of (a). Meanwhile, the risk prediction system acquires the global data Q of the last moment corresponding to the last moment of each moment t-1 And local data q at the last moment t-1 (v h ,r s ) Or q t-1 (v h ). Then, the risk prediction system uses the circular neural network to calculate the maximum local data at each moment and the corresponding global data Q at the previous moment t-1 Training is carried out to obtain global data Q at each moment t In particular Q t =RNN(g(G t ),Q t-1 ) Where g is an aggregation function determined by the RGCN aggregator. Finally, the risk prediction system uses the global data Q at each moment through a recurrent neural network t And corresponding respective local data
Figure BDA0003288273530000143
And local data q at the previous moment t-1 (v h ,r s ) Training to obtain each target local data at each moment, wherein the target local data are
Figure BDA0003288273530000144
Q t ,q t-1 (v h ,r s ) Or target local data is
Figure BDA0003288273530000145
Q t ,q t-1 (v h )). And finally, the risk prediction system trains the recurrent neural network according to the global data and the target local data at each moment to obtain a corresponding food safety knowledge graph model.
It is further noted that the global data and the local data represent different aspects of obtaining information in the knowledge-graph, and thus the global data and the local data have a complementary relationship. Global data Q t All global information of the knowledge-graph up to the timestamp t is retained. Local data q t (v h ) Or q t (v h ,r s ) More emphasis is placed on the information associated with each entity's data and entity's relationships.
The embodiment provides a food safety risk prediction method, which includes performing maximum pooling operation on each local data at each moment to obtain maximum local data at each moment, and obtaining previous-moment global data and previous-moment local data corresponding to previous moments at each moment; training based on the maximum local data at each moment and the global data at the last moment corresponding to the maximum local data to obtain the global data at each moment; obtaining target local data at each moment based on the global data at each moment, each corresponding local data and the corresponding local data at the previous moment; and training the preset neural network based on the global data and the corresponding target local data at each moment. Therefore, global data training and local data training in the time dimension are carried out through the recurrent neural network in the embodiment, so that the food safety knowledge graph model with the time sequence and high accuracy is obtained, the food safety risk at a certain future moment (to-be-predicted moment) can be accurately predicted through the food safety knowledge graph model, and the accuracy of food safety risk prediction is improved.
Further, referring to fig. 4, fig. 4 is a third schematic flowchart of the food safety risk prediction method provided by the present invention, where the step S40 includes:
step S401, establishing the joint distribution corresponding to all food safety risk events based on the time sequence in the food safety knowledge graph model;
step S402, converting the combined distribution into a corresponding conditional distribution sequence, and determining historical food events related to the events at the moment to be predicted;
step S403, obtaining the food safety condition probability corresponding to the moment to be predicted according to the condition distribution sequence and the historical food event;
and S404, predicting the food safety risk at the moment to be predicted according to the food safety condition probability.
The risk prediction system is based on the time sequence in the food safety knowledge graph model from front to backTime sequence, establishing a combined distribution G, G = { G = corresponding to all food safety risk events by using an autoregressive mode 1 ,G 2 ,G 3 ...G T }. Of course, the joint distribution cloth G, G = { G } corresponding to all food safety risk events can also be established in a time sequence from back to front by using an autoregressive mode T ...G 3 ,G 2 ,G 1 }. The risk prediction system then decomposes the joint distribution into a sequence of conditional distributions p, p = (G) t |G t-m ,G t-m+1 ,…,G t-1 )=(G t |G t-m:t-1 ) Meanwhile, the risk prediction system needs to determine the historical food event related to the event at the time to be predicted, if the event G at the time to be predicted is determined t The time step event of the related historical food event is m steps, and can be understood as the event G of the moment to be predicted t The probability of (D) depends on the probability of the historical food event of the previous m steps, i.e. G t-m ,G t-m+1 ,...,G t-1 ={G t-m:t-1 }. In the present embodiment, the event G of the time to be predicted t Previous m steps of historical food event G t-m:t-1 Are all independent of each other, then each conditional distribution sequence p (G) t |G t-m:t-1 ) Converted into the corresponding target joint distribution p (G), which is expressed as follows,
Figure BDA0003288273530000161
and the risk prediction system obtains the food safety condition probability at the moment to be predicted according to the target joint distribution p (G), and predicts the food safety risk at the moment to be predicted according to the food safety condition probability to obtain the possibility of the occurrence of the food safety risk at the moment to be predicted. Specifically, the risk prediction system determines whether the probability of the food safety condition is greater than or equal to a preset probability, where the preset probability is set according to an actual situation, and the embodiment is not limited. If the probability of the food safety condition is determined to be greater than or equal to the preset probability, the risk prediction system determines that the possibility of the food safety risk occurring at the moment to be predicted is very high. If the probability of the food safety condition is smaller than the preset probability, the risk prediction system determines that the possibility of the food safety risk at the moment to be predicted is extremely low.
Further, the specific description of step S4031 to step S4032 is as follows:
step S4031, constructing corresponding target joint distribution according to the condition distribution sequence and the historical food events, wherein the target joint distribution comprises a first condition probability distribution, a second condition probability distribution and a third condition probability distribution;
step S4032, the probability of the food safety condition is obtained according to the first conditional probability distribution, the second conditional probability distribution, and the third conditional probability distribution.
Specifically, the risk prediction system constructs a target joint distribution p (G) according to the conditional distribution sequence and the historical food events, and converts the target joint distribution p (G) into a target joint distribution p (G) according to a conditional probability calculation formula
Figure BDA0003288273530000171
Wherein p (vh | G) t-m:t-1 ) Is a first conditional probability distribution, p (r) s |vh,G t-m:t-1 ) For the second conditional probability distribution, p (v) o |v h ,r s ,G t-m:t-1 ) Is the third conditional probability distribution. Next, the risk prediction system bases on the first conditional probability distribution p (v) h |G t-m:t-1 ) Second conditional probability distribution p (r) s |v h ,G t-m:t-1 ) And a third conditional probability distribution p (v) o |v h ,r s ,G t-m:t-1 ) And respectively determining the conditional probability of the head entity data, the conditional probability of the head relation and the conditional probability of the tail entity data corresponding to the time to be predicted, and obtaining the food safety conditional probability of the time to be predicted according to the conditional probability of the head entity data, the conditional probability of the head relation and the conditional probability of the tail entity data.
According to the method and the device, the target joint distribution is constructed through the condition distribution sequence and the historical food events, and the food safety condition probability at the moment to be predicted is accurately obtained through each condition probability in the target joint distribution, so that the accuracy of predicting the food safety risk is improved.
Further, the specific description of step S40321 to step S40324 is as follows:
step S40321, based on the first conditional probability distribution, determining a head entity conditional probability corresponding to a time to be predicted, and sampling head entity data to be predicted at the time to be predicted;
step S40322, generating entity relationship probability between the head entity data to be predicted and the historical food event at the time to be predicted based on the second conditional probability distribution;
step S40323, determining a tail entity conditional probability corresponding to the time to be predicted based on the third conditional probability distribution;
step S40324, the food safety conditional probability is obtained according to the head entity conditional probability, the entity relation conditional probability and the tail entity conditional probability.
In particular, the risk prediction system bases on a first conditional probability distribution p (v) h |G t-m:t-1 ) Determining the head entity data (such as various foods) to be predicted at the moment to be predicted, and meanwhile, according to the first conditional probability distribution p (v) of h |G t-m:t-1 ) And calculating the head entity conditional probability of the head entity data at the moment to be predicted. The risk prediction system then bases on the second conditional probability distribution p (r) s |v h ,G t-m:t-1 ) Generating head entity data to be predicted and historical food events G at the moment to be predicted t-m:t-1 The entity relationship probability (such as the content of food toxic substances, food risk, etc.). The risk prediction system further based on the third conditional probability distribution p (v) o |v h ,r s ,G t-m:t-1 ) And calculating the conditional probability (such as poison content grade and risk grade) of the tail entity data at the moment to be predicted. Next, the risk prediction system determines the head entity conditional probability and the tail entity conditional probability as entity conditional probabilities and summarizes the entity relationshipsAnd (4) substituting the rate and the entity conditional probability into the target joint distribution p (G) for calculation to obtain the food safety conditional probability of the time to be predicted.
Further, the calculation method and process of the head entity conditional probability, the entity relationship probability and the tail entity conditional probability are as follows. The process of calculating the conditional probability of the tail entity is specifically described as follows: firstly, p (v) o |v h ,r s ,G t-m:t-1 ) Parameterizing, i.e. p (v) o |v h ,r s ,G t-m:t-1 )∝exp([e vh :e r :q t-1 (v h ,r s )] T ·w vo ) Wherein e is vh ,e r ∈R d Respectively head entity data v h And entity relationship r s The corresponding embedded vector. q. q of t-1 (v h ,r s )∈R d Is a combination (v) of header entity data obtained on the time stamp data (t-1) and entity relationships h ,r s ) Is represented by the local data of (a). The knowledge-graph will have different entity data and entity relationships under each timestamp data, and thus, the local data q t-1 (v h ,r s ) Dynamic updates are made at each timestamp data, for which reason it is not necessary to consider the embedded vector e vh ,e r Whether or not updating is required, therefore, e vh And e r Can be understood as header entity data v h And entity relationship r s I.e. means that the vectors are spliced together. [ e ] vh :e r :q t-1 (v h ,r s )]Has a dimension of
Figure BDA0003288273530000181
By concatenating the static and dynamic representations of the food information, the recurrent memory network can efficiently capture the head entity data and entity relationship combinations (v) up to the time stamp data (t-1) h ,r s ) The information of (1). Transmitting the coding result to a multi-layer perceptron MLP for decoding, and calculating different tail entity data v o With respect to p (v) o |v h ,r s ,G t-m:t-1 ) The probability of (c). Define MLP decoder as parameter w vo A linear softmax classifier of, w vo Is also of dimension
Figure BDA0003288273530000192
[e vh :e r :q t-1 (v h ,r s )]Is transposed with respect to w vo Multiplying to obtain product value, and using the product value as index of natural number e to obtain corresponding index result, i.e. tail entity conditional probability p (v) o |v h ,r s ,G t-m:t-1 )。
Similarly, the process of calculating the conditional probability of the entity relationship is specifically described as follows: parameterizing the entity relationship conditional probabilities: p (r) s |v h ,G t-m:t-1 )∝exp{[e vh :q t-1 (v h )] T ·w rs In which h is t-1 (v h )∈R d Is concerned with the past data v about the head entity in the knowledge-graph h Local data of (a) and H t-1 ∈R d Is to knowledge-graph global data G t-1 ,G t-2 ,…,G t-m Vector representation of the encoding is performed. For predicting head entity data v in knowledge graph h Which entity relationship will interact with in predicting the conditional probability p (r) of an entity relationship s |v h ,G t-m:t-1 ) Then, the static representation e vh ∈R d And dynamically represent q t-1 (v h ) Considered as features pieced together, i.e. [ e ] h :q t-1 (v h )]And input it to the parameter { w } rs A multilayer perceptron (MLP) decoder. [ e ] a h :q t-1 (v h ,r s )]Transpose of (a) and w rs Multiplying to obtain product value, using the product value as index of e to obtain correspondent index result, said index result is entity relation conditional probability p (r) s |v h ,G t-m:t-1 ). The same reasoning can be obtained for the calculation process of the head entity conditional probability, and this embodiment is not described again.
As described above, canCalculating the conditional probability p (v) of the entity relation h |G t-m:t-1 ) Entity relationship probability p (r) s |v h ,G t-m:t-1 ) And tail entity data probability p (v) o |v h ,r s ,G t-m:t-1 )。
Further, assume that the current timestamp data is t, and the timestamp data of the time to be predicted is at t + Δ t, where Δ t > 0. The manner in which the multi-step inference problem is translated into an inference conditional probability p (G) t+Δt |G :t ). Due to the need to all G t+1 ,…,G t+Δt-1 Integration is performed and in order to obtain an effective inference, the present embodiment provides a G t+1 To G t+Δt-1 And estimating the conditional probability as follows:
Figure BDA0003288273530000191
the formula is rewritten according to a conditional probability formula as follows:
Figure BDA0003288273530000201
the specific description is as follows: first, p (G) is calculated t+1 |G :t ) Then obtaining a sample from the condition distribution
Figure BDA0003288273530000202
Using the sample, further calculating
Figure BDA0003288273530000203
By iterative calculation of G t0 And taking a sample therefrom, and adding P (G) t+Δt |G :t ) Is estimated value of
Figure BDA0003288273530000204
Thereby obtaining P (G) t+Δt |G :t )。
By the calculation method, the head entity conditional probability, the entity relationship probability and the tail entity conditional probability with high accuracy are obtained, the food safety conditional probability with high accuracy is obtained based on the head entity conditional probability, the entity relationship probability and the tail entity conditional probability with high accuracy, and guarantee is provided for improving accuracy of food safety risk prediction.
The embodiment provides a food safety risk prediction method, which is based on a time sequence in a food safety knowledge graph model and establishes joint distribution corresponding to all food safety risk events; converting the joint distribution into a corresponding conditional distribution sequence, and determining historical food events related to events at the moment to be predicted; obtaining the food safety condition probability corresponding to the moment to be predicted according to the condition distribution sequence and the historical food events; and predicting the food safety risk at the moment to be predicted according to the food safety condition probability. Therefore, the head entity conditional probability, the entity relation probability and the tail entity conditional probability of the time to be predicted are obtained through the food safety knowledge graph model, the food safety risk of the time to be predicted is predicted in an auxiliary mode through the head entity conditional probability, the entity relation probability and the tail entity conditional probability, and accuracy of prediction of the food safety risk of the time to be predicted is improved.
Further, the food safety risk prediction device provided by the present invention is described below, and the food safety risk prediction device described below and the food safety risk prediction method described above may be referred to in correspondence with each other.
As shown in fig. 5, fig. 5 is a schematic structural diagram of a food safety risk prediction device provided by the present invention, and the food safety risk prediction device includes:
the construction module 501 is configured to acquire and analyze historical food safety risk events, obtain each entity data and timestamp data corresponding to the entity data, and construct corresponding quadruple data according to each entity data and timestamp data corresponding to the entity data to obtain a corresponding knowledge graph, where the entity data includes head entity data and tail entity data;
an aggregation module 502, configured to aggregate, by using a preset aggregator, each piece of head entity data and tail entity data corresponding to the head entity data at each time in the knowledge graph, to obtain each piece of local data at each time;
a determining module 503, configured to determine, based on each of the local data at each of the moments, global data corresponding to the local data, and train a preset neural network through the global data at each of the moments and each of the local data corresponding to the global data, so as to obtain a food safety knowledge map model;
and the prediction module 504 is configured to determine an input time to be predicted, and predict a food safety risk at the time to be predicted based on the food safety knowledge graph model.
Further, the aggregation module 502 is further configured to:
classifying the tail entity data corresponding to each head entity data according to the relationship characteristics of the entity relationship corresponding to each head entity data at each time, and correspondingly obtaining tail entity data with a plurality of relationship characteristics;
aggregating tail entity data with the same relationship characteristics corresponding to the head entity data at each time through the preset aggregator to obtain new head entity data at each time;
and re-aggregating each new head entity data at each moment through the preset aggregator to obtain each local data at each moment.
Further, the determining module 503 is further configured to:
performing maximum pooling operation on each local data at each moment to obtain maximum local data at each moment, and acquiring last-moment global data and last-moment local data corresponding to last moment of each moment;
obtaining global data at each moment according to the maximum local data at each moment and the corresponding global data at the previous moment;
and training the preset neural network based on the global data at each moment, the corresponding local data and the corresponding local data at the last moment to obtain the food safety knowledge map model.
Further, the prediction module 504 is further configured to:
establishing a combined distribution corresponding to all food safety risk events based on the time sequence in the food safety knowledge graph model;
converting the combined distribution into a corresponding conditional distribution sequence, and determining historical food events related to the events at the moment to be predicted;
obtaining the food safety condition probability corresponding to the moment to be predicted according to the condition distribution sequence and the historical food event;
and predicting the food safety risk at the moment to be predicted according to the food safety condition probability.
Further, the prediction module 504 is further configured to:
constructing a corresponding target joint distribution according to the conditional distribution sequence and the historical food events, wherein the target joint distribution comprises a first conditional probability distribution, a second conditional probability distribution and a third conditional probability distribution;
and obtaining the food safety condition probability according to the first condition probability distribution, the second condition probability distribution and the third condition probability distribution.
Further, the prediction module 504 is further configured to:
determining the head entity conditional probability corresponding to the time to be predicted based on the first conditional probability distribution, and sampling the head entity data to be predicted at the time to be predicted;
generating entity relation probability of the head entity data to be predicted and the historical food events at the moment to be predicted based on the second conditional probability distribution;
determining the tail entity conditional probability corresponding to the moment to be predicted based on the third conditional probability distribution;
and obtaining the food safety conditional probability according to the head entity conditional probability, the entity relation conditional probability and the tail entity conditional probability.
Further, the building module 501 is further configured to:
establishing an entity relationship between each head entity data and the corresponding tail entity data according to the data characteristics of the entity data;
adding the timestamp data of each head entity data into the entity relationship of each head entity data to obtain each entity relationship carrying the timestamp data;
constructing corresponding quaternary group data according to the head entity data, the tail entity data corresponding to the head entity data and the corresponding entity relationship carrying the timestamp data;
determining a set of each of the quadruple data as the knowledge-graph.
The specific embodiment of the food safety risk prediction device provided by the invention is basically the same as the embodiments of the food safety risk prediction method, and details are not repeated here.
Fig. 6 illustrates a physical structure diagram of an electronic device, which may include, as shown in fig. 6: a processor (processor) 610, a communication Interface (Communications Interface) 620, a memory (memory) 630 and a communication bus 640, wherein the processor 610, the communication Interface 620 and the memory 630 communicate with each other via the communication bus 640. Processor 610 may invoke logic instructions in memory 630 to perform a food safety risk prediction method comprising:
acquiring and analyzing historical food safety risk events to obtain each entity data and corresponding timestamp data thereof, and constructing corresponding quadruple data according to each entity data and corresponding timestamp data thereof to obtain a corresponding knowledge graph, wherein the entity data comprises head entity data and tail entity data;
aggregating each head entity data and tail entity data corresponding to the head entity data at each time in the knowledge graph through a preset aggregator to obtain each local data at each time;
determining corresponding global data based on each local data at each moment, and training a preset neural network through the global data at each moment and each local data corresponding to the global data at each moment to obtain a food safety knowledge map model;
and determining the input moment to be predicted, and predicting the food safety risk of the moment to be predicted based on the food safety knowledge graph model.
In addition, the logic instructions in the memory 630 may be implemented in software functional units and stored in a computer readable storage medium when the logic instructions are sold or used as independent products. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
In another aspect, the present invention also provides a computer program product comprising a computer program stored on a non-transitory computer readable storage medium, the computer program comprising program instructions, which when executed by a computer, enable the computer to perform the food safety risk prediction method provided by the above methods, the method comprising:
acquiring and analyzing historical food safety risk events to obtain each entity data and corresponding timestamp data thereof, and constructing corresponding quadruple data according to each entity data and corresponding timestamp data thereof to obtain a corresponding knowledge graph, wherein the entity data comprises head entity data and tail entity data;
aggregating each head entity data and tail entity data corresponding to the head entity data at each time in the knowledge graph through a preset aggregator to obtain each local data at each time;
determining corresponding global data based on each local data at each moment, and training a preset neural network through the global data at each moment and each local data corresponding to the global data at each moment to obtain a food safety knowledge map model;
and determining the input moment to be predicted, and predicting the food safety risk at the moment to be predicted based on the food safety knowledge graph model.
In yet another aspect, the present invention also provides a non-transitory computer readable storage medium having stored thereon a computer program, which when executed by a processor, is implemented to perform the food safety risk prediction methods provided above, the method comprising:
acquiring and analyzing historical food safety risk events to obtain each entity data and corresponding timestamp data thereof, and constructing corresponding quadruple data according to each entity data and corresponding timestamp data thereof to obtain a corresponding knowledge graph, wherein the entity data comprises head entity data and tail entity data;
aggregating each head entity data and tail entity data corresponding to the head entity data at each time in the knowledge graph through a preset aggregator to obtain each local data at each time;
determining corresponding global data based on each local data at each moment, and training a preset neural network through the global data at each moment and each corresponding local data to obtain a food safety knowledge graph model;
and determining the input moment to be predicted, and predicting the food safety risk of the moment to be predicted based on the food safety knowledge graph model.
The above-described embodiments of the apparatus are merely illustrative, and the units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.
Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware. With this understanding in mind, the above-described technical solutions may be embodied in the form of a software product, which can be stored in a computer-readable storage medium such as ROM/RAM, magnetic disk, optical disk, etc., and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the methods described in the embodiments or some parts of the embodiments.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.

Claims (7)

1. A method for predicting food safety risk, comprising:
acquiring and analyzing historical food safety risk events to obtain each entity data and corresponding timestamp data thereof, and constructing corresponding quadruple data according to each entity data and corresponding timestamp data thereof to obtain a corresponding knowledge graph, wherein the entity data comprises head entity data and tail entity data;
determining an entity relationship between the head entity data and the tail entity data, wherein the data types of the entity data comprise food raw materials, edible articles, food safety risks, external intervention and food sampling and inspection poisons, and the entity relationship comprises content grades, risks and intervention of various kinds of poisons;
aggregating each head entity data and tail entity data corresponding to the head entity data at each time in the knowledge graph through a preset aggregator to obtain each local data at each time;
the aggregating, by a preset aggregator, each piece of head entity data and tail entity data corresponding to the head entity data at each time in the knowledge graph to obtain each piece of local data at each time includes:
classifying the tail entity data corresponding to each head entity data according to the relationship characteristics of the entity relationship corresponding to each head entity data at each time, and correspondingly obtaining tail entity data with a plurality of relationship characteristics;
aggregating tail entity data with the same relation characteristics corresponding to the head entity data at each time through the preset aggregator to obtain new head entity data at each time;
re-aggregating each new head entity data at each time through the preset aggregator to obtain each local data at each time;
determining corresponding global data based on each local data at each moment, and training a preset neural network through the global data at each moment and each local data corresponding to the global data at each moment to obtain a food safety knowledge map model;
determining corresponding global data based on each local data at each moment, and training a preset neural network through the global data at each moment and each corresponding local data to obtain a food safety knowledge map model, wherein the method comprises the following steps:
performing maximum pooling operation on each local data at each moment to obtain maximum local data at each moment, and acquiring last-moment global data and last-moment local data corresponding to last moment of each moment;
obtaining global data at each moment according to the maximum local data at each moment and the corresponding global data at the last moment;
obtaining target local data at each moment based on the global data at each moment, each corresponding local data thereof and the corresponding local data at the last moment;
training the preset neural network based on global data and target local data corresponding to the global data at each moment to obtain the food safety knowledge graph model;
determining an input moment to be predicted, and predicting the food safety risk of the moment to be predicted based on the food safety knowledge graph model;
the predicting of the food safety risk at the moment to be predicted based on the food safety knowledge graph model comprises the following steps:
establishing a combined distribution corresponding to all food safety risk events based on the time sequence in the food safety knowledge graph model;
converting the combined distribution into a corresponding conditional distribution sequence, and determining historical food events related to the events at the moment to be predicted;
obtaining the food safety condition probability corresponding to the moment to be predicted according to the condition distribution sequence and the historical food event;
and predicting the food safety risk at the moment to be predicted according to the food safety condition probability.
2. The method for predicting food safety risk according to claim 1, wherein the step of obtaining the food safety conditional probability corresponding to the moment to be predicted according to the conditional distribution sequence and the historical food event comprises:
constructing a corresponding target joint distribution according to the conditional distribution sequence and the historical food events, wherein the target joint distribution comprises a first conditional probability distribution, a second conditional probability distribution and a third conditional probability distribution;
and obtaining the food safety condition probability according to the first condition probability distribution, the second condition probability distribution and the third condition probability distribution.
3. The method of predicting food safety risk according to claim 2, wherein the step of obtaining the food safety conditional probability according to the first conditional probability distribution, the second conditional probability distribution, and the third conditional probability distribution comprises:
determining the head entity conditional probability corresponding to the time to be predicted based on the first conditional probability distribution, and sampling the head entity data to be predicted at the time to be predicted;
generating entity relation probability of the head entity data to be predicted and the historical food events at the moment to be predicted based on the second conditional probability distribution;
determining the tail entity conditional probability corresponding to the moment to be predicted based on the third conditional probability distribution;
and obtaining the food safety conditional probability according to the head entity conditional probability, the entity relation conditional probability and the tail entity conditional probability.
4. The method of claim 1, wherein the step of constructing a corresponding quadruple of data based on each entity data and the corresponding timestamp data to obtain a corresponding knowledge graph comprises:
establishing an entity relationship between each head entity data and the corresponding tail entity data according to the data characteristics of the entity data;
adding the timestamp data of each head entity data into the entity relationship of each head entity data to obtain each entity relationship carrying the timestamp data;
constructing corresponding quaternary group data according to the head entity data, the tail entity data corresponding to the head entity data and the corresponding entity relationship carrying the timestamp data;
determining a set of each of the quadruple data as the knowledge-graph.
5. A food safety risk prediction device, comprising:
the construction module is used for acquiring and analyzing historical food safety risk events, obtaining each entity data and corresponding timestamp data thereof, and constructing corresponding quadruple data according to each entity data and corresponding timestamp data thereof to obtain a corresponding knowledge graph, wherein the entity data comprises head entity data and tail entity data;
the food safety risk prediction device is used for:
determining an entity relationship between the head entity data and the tail entity data, wherein the data types of the entity data comprise food raw materials, edible articles, food safety risks, external intervention and food sampling and inspection poisons, and the entity relationship comprises content grades, risks and intervention of various kinds of poisons;
the aggregation module is used for aggregating each head entity data and the corresponding tail entity data at each time in the knowledge graph through a preset aggregator to obtain each local data at each time;
the aggregation module is further to:
classifying the tail entity data corresponding to each head entity data according to the relationship characteristics of the entity relationship corresponding to each head entity data at each time, and correspondingly obtaining tail entity data with a plurality of relationship characteristics;
aggregating tail entity data with the same relation characteristics corresponding to the head entity data at each time through the preset aggregator to obtain new head entity data at each time;
re-aggregating each new head entity data at each time through the preset aggregator to obtain each local data at each time;
the determining module is used for determining corresponding global data based on the local data at each moment, and training a preset neural network through the global data at each moment and the corresponding local data to obtain a food safety knowledge map model;
the determination module is further to:
performing maximum pooling operation on each local data at each moment to obtain maximum local data at each moment, and acquiring previous-moment global data and previous-moment local data corresponding to previous moments at each moment;
obtaining global data at each moment according to the maximum local data at each moment and the corresponding global data at the last moment;
obtaining target local data at each moment based on the global data at each moment, each corresponding local data thereof and the corresponding local data at the last moment;
training the preset neural network based on global data and target local data corresponding to the global data at each moment to obtain the food safety knowledge graph model;
the prediction module is used for determining the input moment to be predicted and predicting the food safety risk at the moment to be predicted based on the food safety knowledge map model;
the prediction module is further to:
establishing a combined distribution corresponding to all food safety risk events based on the time sequence in the food safety knowledge graph model;
converting the combined distribution into a corresponding conditional distribution sequence, and determining historical food events related to the events at the moment to be predicted;
obtaining the food safety condition probability corresponding to the moment to be predicted according to the condition distribution sequence and the historical food event;
and predicting the food safety risk at the moment to be predicted according to the food safety condition probability.
6. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor when executing the program performs the steps of the food safety risk prediction method according to any of claims 1 to 4.
7. A non-transitory computer readable storage medium, on which a computer program is stored, wherein the computer program, when being executed by a processor, implements the steps of the food safety risk prediction method according to any one of claims 1 to 4.
CN202111154651.2A 2021-09-29 2021-09-29 Food safety risk prediction method and device, electronic equipment and medium Active CN113934863B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111154651.2A CN113934863B (en) 2021-09-29 2021-09-29 Food safety risk prediction method and device, electronic equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111154651.2A CN113934863B (en) 2021-09-29 2021-09-29 Food safety risk prediction method and device, electronic equipment and medium

Publications (2)

Publication Number Publication Date
CN113934863A CN113934863A (en) 2022-01-14
CN113934863B true CN113934863B (en) 2022-10-14

Family

ID=79277338

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111154651.2A Active CN113934863B (en) 2021-09-29 2021-09-29 Food safety risk prediction method and device, electronic equipment and medium

Country Status (1)

Country Link
CN (1) CN113934863B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11908583B2 (en) * 2022-05-02 2024-02-20 Kpn Innovations, Llc. Apparatus and method for determining toxic load quantifiers

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11475295B2 (en) * 2019-04-25 2022-10-18 Adobe Inc. Predicting and visualizing outcomes using a time-aware recurrent neural network
CN111259085B (en) * 2019-12-30 2022-08-16 福州大学 Relation prediction method of time perception translation model based on relation hyperplane
CN111445121A (en) * 2020-03-24 2020-07-24 上海明略人工智能(集团)有限公司 Risk assessment method and apparatus, storage medium, and electronic apparatus
CN112465264A (en) * 2020-12-07 2021-03-09 湖北省食品质量安全监督检验研究院 Food safety risk grade prediction method and device and electronic equipment
CN113377964B (en) * 2021-06-30 2023-04-18 武汉大学 Knowledge graph link prediction method, device, equipment and storage medium

Also Published As

Publication number Publication date
CN113934863A (en) 2022-01-14

Similar Documents

Publication Publication Date Title
CN111124840B (en) Method and device for predicting alarm in business operation and maintenance and electronic equipment
EP4198820A1 (en) Training method for semi-supervised learning model, image processing method, and device
US11775412B2 (en) Machine learning models applied to interaction data for facilitating modifications to online environments
CN111369344B (en) Method and device for dynamically generating early warning rules
CN113688957A (en) Target detection method, device, equipment and medium based on multi-model fusion
CN110781922A (en) Sample data generation method and device for machine learning model and electronic equipment
CN105279692A (en) Financial information technology system performance prediction method and apparatus
CN113934863B (en) Food safety risk prediction method and device, electronic equipment and medium
CN112562863A (en) Epidemic disease monitoring and early warning method and device and electronic equipment
CN112766402A (en) Algorithm selection method and device and electronic equipment
CN111159481B (en) Edge prediction method and device for graph data and terminal equipment
CN115994226A (en) Clustering model training system and method based on federal learning
CN114399321A (en) Business system stability analysis method, device and equipment
CN116489038A (en) Network traffic prediction method, device, equipment and medium
CN113934862B (en) Community security risk prediction method, device, electronic equipment and medium
CN116362359A (en) User satisfaction prediction method, device, equipment and medium based on AI big data
CN113869377A (en) Training method and device and electronic equipment
CN115983497A (en) Time sequence data prediction method and device, computer equipment and storage medium
CN110796170A (en) Client dynamic support model generation method and device and electronic equipment
CN115618065A (en) Data processing method and related equipment
CN115310673A (en) Navigation risk identification, prevention and control method, system, device and storage medium
CN113761388A (en) Recommendation method and device, electronic equipment and storage medium
de Carvalho et al. Dynamic threshold modelling and the US business cycle
CN112328769A (en) Automatic customer service response method, device and computer readable storage medium
WO2020121378A1 (en) Learning device and learning method

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant