Calculation method, device, electronic device and storage medium for joint probability distribution
By converting the DAG graph into an undirected graph and extracting the undirected subgraph, determining the node relationship and calculating the joint probability distribution, the problem of low query efficiency in Bayesian network is solved, and more efficient calculation is achieved.
Patent Information
- Application Number
- CN202110164631.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-02-05
- Publication Date
- 2025-08-19
- Estimated Expiration
- 2041-02-05
AI Technical Summary
When calculating the joint probability distribution of Bayesian networks, the query efficiency is low and the timeliness is poor, especially when the network structure is large, it cannot operate effectively.
The directed acyclic graph DAG graph is converted into an undirected graph, and the target node and undirected subgraph are extracted from it, and the joint probability distribution is calculated by determining the node relationship and the DAG graph.
The calculation speed and efficiency of joint probability distribution are improved, and the problem of low query timeliness in large-scale networks is solved.
Smart Images

Figure CN114880623B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a method, device, electronic device and storage medium for calculating joint probability distribution. Background Art
[0002] Marginal distribution queries (calculations) based on discrete Bayesian networks currently often use a joint probability distribution combined with the chain rule of Bayesian networks. Probabilistic queries require precise inference, which uses probability formulas based on the model network structure and parameters of the probability graph to calculate probabilities without approximation, resulting in the most accurate results. Common precise inference algorithms include variable elimination, cliquetree, and belief propagation.
[0003] In related technologies, a Bayesian network is defined using two elements: network structure and conditional probability distribution. When querying the joint probability distribution of two nodes, it is necessary to traverse and search all nodes of the Bayesian network, which results in low query efficiency. When the network structure is large, the query may be inefficient or even unable to run. Summary of the Invention
[0004] The first embodiment of the present application proposes a method for calculating joint probability distribution, which can effectively improve the speed and efficiency of joint probability distribution calculation.
[0005] The second embodiment of the present application proposes a computing device for joint probability distribution.
[0006] A third embodiment of the present application provides an electronic device.
[0007] The fourth embodiment of the present application proposes a computer-readable storage medium.
[0008] The first embodiment of the present application proposes a method for calculating a joint probability distribution, including:
[0009] Obtain a directed acyclic graph (DAG) and convert the DAG into an undirected graph.
[0010] extracting a first target node and a second target node from the undirected graph;
[0011] Extracting a corresponding undirected subgraph from the undirected graph according to the first target node and the second target node;
[0012] determining a node relationship between the first target node and the second target node according to the undirected subgraph; and
[0013] A joint probability distribution between the first target node and the second target node is calculated based on the node relationship and the DAG graph.
[0014] According to the calculation method of the joint probability distribution of the embodiment of the present application, a directed acyclic graph (DAG) is first obtained, and the DAG is converted into an undirected graph, and the first target node and the second target node are extracted from the undirected graph. Then, the corresponding undirected subgraph is extracted from the undirected graph based on the first target node and the second target node, and the node relationship between the first target node and the second target node is determined based on the undirected subgraph. Finally, the joint probability distribution between the first target node and the second target node is calculated based on the node relationship and the DAG. Thus, the speed and efficiency of the joint probability distribution calculation can be effectively improved.
[0015] In addition, the method for calculating the joint probability distribution according to the above embodiment of the present application may also have the following additional technical features:
[0016] In one embodiment of the present application, the first target node and the second target node are two non-adjacent nodes.
[0017] In one embodiment of the present application, extracting a corresponding undirected subgraph from the undirected graph according to the first target node and the second target node includes:
[0018] Calculate the target shortest path between the first target node and the second target node in the undirected graph;
[0019] Determine a node between the first target node and the second target node according to the target shortest path;
[0020] The undirected subgraph is extracted from the undirected graph according to the first target node, the second target node, and the node.
[0021] In one embodiment of the present application, the node relationship is one of an indirect causal chain relationship, a same-effect relationship, a same-cause relationship and a candidate relationship, and the indirect causal chain relationship includes an indirect cause chain relationship and an indirect effect chain relationship, wherein the candidate relationship is any node relationship other than the indirect causal chain relationship, the same-effect relationship and the same-cause relationship.
[0022] In one embodiment of the present application, determining the node relationship between the first target node and the second target node according to the undirected subgraph includes:
[0023] Get the attribute relationship between each node in the undirected subgraph.
[0024] The node relationship between the first target node and the second target node is determined according to the attribute relationship between each node.
[0025] In one embodiment of the present application, the attribute relationship includes one of a descendant node relationship, an ancestor node relationship, a common ancestor node relationship, and a common descendant node relationship.
[0026] In one embodiment of the present application, determining the node relationship between the first target node and the second target node according to the attribute relationship between each node includes:
[0027] If one of the first target node and the second target node is a descendant node or an ancestor node of the other target node, determining that the node relationship between the first target node and the second target node is the indirect causal chain relationship;
[0028] If the first target node and the second target node have a common ancestor node, determining that the node relationship between the first target node and the second target node is the common cause relationship;
[0029] If the first target node and the second target node have a common descendant node, the node relationship between the first target node and the second target node is determined to be the same-result relationship.
[0030] In one embodiment of the present application, the above-mentioned method for calculating the joint probability distribution further includes:
[0031] When it is determined that the node relationship between the first target node and the second target node is not the indirect causal chain relationship, the common cause relationship or the common effect relationship, the node relationship between the first target node and the second target node is determined to be the candidate relationship.
[0032] In one embodiment of the present application, calculating the joint probability distribution between the first target node and the second target node according to the node relationship and the DAG graph includes:
[0033] Extracting a corresponding directed acyclic subgraph from the DAG graph according to the first target node, the second target node, and the node;
[0034] If the node relationship is the same-result relationship or the candidate relationship, the directed acyclic subgraph is processed according to a probabilistic graphical model to obtain a joint probability distribution between the first target node and the second target node.
[0035] In one embodiment of the present application, the above-mentioned method for calculating the joint probability distribution further includes:
[0036] If the node relationship is the indirect causal chain relationship, a joint probability distribution between the first target node and the second target node is generated according to a preset algorithm and the directed acyclic subgraph.
[0037] In one embodiment of the present application, the above-mentioned method for calculating the joint probability distribution further includes:
[0038] If the node relationship is the same-cause relationship, obtaining a common ancestor node of the first target node and the second target node;
[0039] Calculating a first shortest path between the first target node and the common ancestor node in the undirected subgraph, and calculating a second shortest path between the second target node and the common ancestor node in the undirected subgraph;
[0040] Extracting a first subgraph corresponding to the first shortest path and a second subgraph corresponding to the second shortest path from the directed acyclic subgraph according to the first shortest path and the second shortest path;
[0041] A joint probability distribution between the first target node and the second target node is generated according to the preset algorithm, the first subgraph, and the second subgraph.
[0042] The second embodiment of the present application provides a device for calculating a joint probability distribution, including:
[0043] An acquisition module is used to acquire a directed acyclic graph (DAG) and convert the DAG into an undirected graph;
[0044] A first extraction module, configured to extract a first target node and a second target node from the undirected graph;
[0045] A second extraction module, configured to extract a corresponding undirected subgraph from the undirected graph according to the first target node and the second target node;
[0046] a determining module, configured to determine a node relationship between the first target node and the second target node according to the undirected subgraph; and
[0047] A calculation module is used to calculate the joint probability distribution between the first target node and the second target node based on the node relationship and the DAG graph.
[0048] The computing device for the joint probability distribution of the embodiment of the present application first acquires a directed acyclic graph (DAG) through an acquisition module, converts the DAG into an undirected graph, extracts a first target node and a second target node from the undirected graph through a first extraction module, and extracts a corresponding undirected subgraph from the undirected graph based on the first target node and the second target node through a second extraction module, then determines the node relationship between the first target node and the second target node based on the undirected subgraph through a determination module, and finally calculates the joint probability distribution between the first target node and the second target node based on the node relationship and the DAG through a calculation module. Thus, the speed and efficiency of the joint probability distribution calculation can be effectively improved.
[0049] In addition, the joint probability distribution calculation device according to the above embodiment of the present application may also have the following additional technical features:
[0050] In one embodiment of the present application, the first target node and the second target node are two non-adjacent nodes.
[0051] In one embodiment of the present application, the second extraction module is specifically configured to:
[0052] Calculate the target shortest path between the first target node and the second target node in the undirected graph;
[0053] Determine a node between the first target node and the second target node according to the target shortest path;
[0054] The undirected subgraph is extracted from the undirected graph according to the first target node, the second target node, and the node.
[0055] In one embodiment of the present application, the node relationship is one of an indirect causal chain relationship, a same-effect relationship, a same-cause relationship and a candidate relationship, and the indirect causal chain relationship includes an indirect cause chain relationship and an indirect effect chain relationship, wherein the candidate relationship is any node relationship other than the indirect causal chain relationship, the same-effect relationship and the same-cause relationship.
[0056] In one embodiment of the present application, the determining module includes:
[0057] The acquisition unit is used to obtain the attribute relationship between each node in the undirected subgraph.
[0058] A determining unit is configured to determine a node relationship between the first target node and the second target node according to an attribute relationship between each of the nodes.
[0059] In one embodiment of the present application, the attribute relationship includes one of a descendant node relationship, an ancestor node relationship, a common ancestor node relationship, and a common descendant node relationship.
[0060] In one embodiment of the present application, the determining unit is specifically configured to:
[0061] If one of the first target node and the second target node is a descendant node or an ancestor node of the other target node, determining that the node relationship between the first target node and the second target node is the indirect causal chain relationship;
[0062] If the first target node and the second target node have a common ancestor node, determining that the node relationship between the first target node and the second target node is the common cause relationship;
[0063] If the first target node and the second target node have a common descendant node, the node relationship between the first target node and the second target node is determined to be the same-result relationship.
[0064] In one embodiment of the present application, the determining unit is further configured to:
[0065] When it is determined that the node relationship between the first target node and the second target node is not the indirect causal chain relationship, the common cause relationship or the common effect relationship, the node relationship between the first target node and the second target node is determined to be the candidate relationship.
[0066] In one embodiment of the present application, the computing module is specifically configured to:
[0067] Extracting a corresponding directed acyclic subgraph from the DAG graph according to the first target node, the second target node, and the node;
[0068] If the node relationship is the same-result relationship or the candidate relationship, the directed acyclic subgraph is processed according to a probabilistic graphical model to obtain a joint probability distribution between the first target node and the second target node.
[0069] In one embodiment of the present application, the computing module is further configured to:
[0070] If the node relationship is the indirect causal chain relationship, a joint probability distribution between the first target node and the second target node is generated according to a preset algorithm and the directed acyclic subgraph.
[0071] In one embodiment of the present application, the computing module is further configured to:
[0072] If the node relationship is the same-cause relationship, obtaining a common ancestor node of the first target node and the second target node;
[0073] Calculating a first shortest path between the first target node and the common ancestor node in the undirected subgraph, and calculating a second shortest path between the second target node and the common ancestor node in the undirected subgraph;
[0074] Extracting a first subgraph corresponding to the first shortest path and a second subgraph corresponding to the second shortest path from the directed acyclic subgraph according to the first shortest path and the second shortest path;
[0075] A joint probability distribution between the first target node and the second target node is generated according to the preset algorithm, the first subgraph, and the second subgraph.
[0076] The third aspect embodiment of the present application proposes an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and runnable on the processor. When the processor executes the program, it implements the method for calculating the joint probability distribution as described in the first aspect embodiment above.
[0077] The electronic device of the embodiment of the present application can effectively improve the speed and efficiency of joint probability distribution calculation by executing a computer program stored in a memory through a processor.
[0078] The fourth embodiment of the present application proposes a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, it implements the method for calculating the joint probability distribution as described in the first embodiment above.
[0079] The computer-readable storage medium of the embodiment of the present application can effectively improve the speed and efficiency of joint probability distribution calculation by storing a computer program and being executed by a processor.
[0080] Additional aspects and advantages of the present application will be given in part in the description below, and in part will become apparent from the description below, or will be learned through practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0081] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:
[0082] Figure 1 1 is a flow chart of a method for calculating a joint probability distribution according to one embodiment of the present application;
[0083] Figure 2 1 is a flow chart of a method for calculating a joint probability distribution according to another embodiment of the present application;
[0084] FIG3( a ) is a DAG diagram according to an embodiment of the present application;
[0085] FIG3( b ) is an undirected subgraph of a same-result relationship according to an embodiment of the present application;
[0086] Figure 4 1 is a flow chart of a method for calculating a joint probability distribution according to another embodiment of the present application;
[0087] FIG5( a ) is an undirected subgraph of an indirect causal chain relationship according to an embodiment of the present application;
[0088] FIG5( b ) is an undirected subgraph of a common cause relationship according to an embodiment of the present application;
[0089] Figure 6 1 is a flow chart of a method for calculating a joint probability distribution according to another embodiment of the present application;
[0090] Figure 7 is a directed acyclic subgraph of an indirect causal chain relationship according to an embodiment of the present application;
[0091] Figure 8 is a block diagram of a device for calculating joint probability distribution according to one embodiment of the present application; and
[0092] Figure 9 Schematic diagram of the structure of an electronic device according to one embodiment of the present application. DETAILED DESCRIPTION
[0093] The following describes in detail embodiments of the present application, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present application, and should not be construed as limiting the present application.
[0094] The following describes the calculation method, device, electronic device and storage medium of the joint probability distribution according to the embodiments of the present application with reference to the accompanying drawings.
[0095] The method for calculating the joint probability distribution provided in the embodiment of the present application can be executed by an electronic device, which may be a PC (Personal Computer), a tablet computer, or a server, etc., without any limitation here.
[0096] In an embodiment of the present application, an electronic device may be provided with a processing component, a storage component, and a driver component. Optionally, the driver component and the processing component may be integrated, the storage component may store an operating system, an application program, or other program modules, and the processing component implements the joint probability distribution calculation method provided in the embodiment of the present application by executing the application program stored in the storage component.
[0097] In the embodiments of the present application, the directed acyclic graph (DAG) can be applied to a shopping platform (website) to analyze and mine the data of the shopping platform (website) (e.g., time series data mining). For example, the DAG can be applied to analyze and mine the shopping information of users on the shopping platform (website), or to analyze and mine the sales information of a product and its supporting products on the shopping platform (website), without any limitation here.
[0098] Among them, the calculation method of the joint probability distribution provided in the embodiment of the present application can calculate (query) the joint probability distribution of two nodes (i.e., data) in the directed acyclic graph DAG graph, so that users can better analyze the data and their relationships in the directed acyclic graph DAG graph.
[0099] Figure 1 4 is a flow chart of a method for calculating a joint probability distribution according to an embodiment of the present application.
[0100] The calculation method of the joint probability distribution of the embodiment of the present application can also be executed by the calculation device of the joint probability distribution provided by the embodiment of the present application. The device can be configured in an electronic device to obtain a directed acyclic graph DAG graph, convert the DAG graph into an undirected graph, and extract the first target node and the second target node from the undirected graph, and then extract the corresponding undirected subgraph from the undirected graph based on the first target node and the second target node, and determine the node relationship between the first target node and the second target node based on the undirected subgraph, and calculate the joint probability distribution between the first target node and the second target node based on the node relationship and the DAG graph, thereby effectively improving the speed and efficiency of the joint probability distribution calculation.
[0101] As a possible scenario, the method for calculating the joint probability distribution in the embodiment of the present application can also be executed on the server side. The server can be a cloud server, and the method for calculating the joint probability distribution can be executed in the cloud.
[0102] like Figure 1 As shown, the calculation method of the joint probability distribution may include:
[0103] Step 101: Obtain a directed acyclic graph (DAG) and convert the DAG into an undirected graph.
[0104] It should be noted that the directed acyclic graph (DAG) described in this embodiment can be pre-generated by relevant personnel according to needs and can be pre-stored in the storage space of the electronic device for easy retrieval and use. The storage space is not limited to physical storage space, such as a hard disk, but can also be a storage space of a network hard disk connected to the electronic device (cloud storage space).
[0105] In an embodiment of the present application, a directed acyclic graph (DAG) may be transformed into an undirected graph through a transformation model.
[0106] Specifically, the electronic device can obtain a directed acyclic graph DAG graph (ie, a DAG graph to be processed) from its own storage space, and input the DAG graph into a conversion model, thereby converting the DAG graph through the conversion model to output an undirected graph.
[0107] It should be noted that the conversion model described in this embodiment may be trained in advance and pre-stored in the storage space of the electronic device for easy retrieval and application.
[0108] The training and generation of the conversion model can be performed by a related server, which can be a cloud server or a computer host. A communication connection is established between the server and the electronic device that can execute the joint probability distribution calculation method provided in the application embodiment. The communication connection can be at least one of a wireless network connection and a wired network connection. The server can send the trained conversion model to the electronic device so that the electronic device can call it when needed, thereby greatly reducing the computing pressure of the electronic device.
[0109] In other embodiments of the present application, the directed acyclic graph DAG graph can also be converted based on a preset conversion algorithm to generate an undirected graph, wherein the preset conversion algorithm can be calibrated according to actual conditions.
[0110] Step 102: Extract a first target node and a second target node from the undirected graph. The first target node and the second target node may be non-adjacent nodes. It should be noted that the joint probability distribution of two adjacent nodes is relatively easy to calculate, and this application will primarily focus on calculating the joint probability distribution of two non-adjacent nodes.
[0111] In an embodiment of the present application, an undirected graph can be extracted using a node extraction model to obtain two target nodes, namely a first target node and a second target node. It should be noted that the node extraction model described in this embodiment can be pre-trained and pre-stored in the storage space of the electronic device for easy retrieval and application.
[0112] Specifically, after converting the DAG graph into an undirected graph, the electronic device can input the undirected graph into a node extraction model, thereby extracting the undirected graph according to user needs through the node extraction model to output two target nodes, namely the first target node and the second target node.
[0113] It should be noted that the user requirements described in this embodiment may be input into the node extraction model in advance, so that the node extraction model extracts two target nodes that meet the user requirements.
[0114] In other embodiments of the present application, after converting the DAG graph into an undirected graph, the electronic device may further extract the undirected graph based on user requirements and a preset node extraction algorithm to extract two target nodes that meet the user requirements. The preset node extraction algorithm may be calibrated according to actual conditions.
[0115] Step 103: extract a corresponding undirected subgraph from the undirected graph according to the first target node and the second target node.
[0116] In an embodiment of the present application, an undirected subgraph corresponding to the first target node and the second target node can be extracted from the undirected graph using an undirected subgraph extraction model or a preset undirected subgraph extraction algorithm, wherein the preset undirected subgraph extraction algorithm can be calibrated according to actual conditions.
[0117] It should be noted that the undirected subgraph extraction model described in this embodiment may also be trained in advance and pre-stored in the storage space of the electronic device for easy retrieval and application.
[0118] Specifically, after obtaining the first target node and the second target node, the electronic device can extract an undirected subgraph corresponding to the first target node and the second target node from the undirected graph based on the first target node, the second target node and a preset undirected subgraph extraction algorithm.
[0119] Step 104: Determine a node relationship between the first target node and the second target node based on the undirected subgraph. The node relationship may be one of an indirect causal chain relationship, a common-effect relationship, a common-cause relationship, and a candidate relationship. The indirect causal chain relationship may include an indirect cause chain relationship and an indirect effect chain relationship. The candidate relationship may be any node relationship other than an indirect causal chain relationship, a common-effect relationship, and a common-cause relationship.
[0120] Step 105 : Calculate the joint probability distribution between the first target node and the second target node according to the node relationship and the DAG graph.
[0121] Specifically, after the electronic device has an undirected subgraph corresponding to the first target node and the second target node, the undirected subgraph can be parsed to obtain the node relationship between the first target node and the second target node, and then the joint probability distribution between the first target node and the second target node can be calculated based on the node relationship and the above-mentioned DAG graph.
[0122] In an embodiment of the present application, a directed acyclic graph (DAG) is first obtained, and the DAG is converted into an undirected graph, and a first target node and a second target node are extracted from the undirected graph. Then, a corresponding undirected subgraph is extracted from the undirected graph based on the first target node and the second target node, and the node relationship between the first target node and the second target node is determined based on the undirected subgraph. Finally, a joint probability distribution between the first target node and the second target node is calculated based on the node relationship and the DAG. Thus, the speed and efficiency of the joint probability distribution calculation can be effectively improved.
[0123] In order to clearly illustrate the above embodiment, in one embodiment of the present application, as shown in FIG. Figure 2 As shown, extracting a corresponding undirected subgraph from an undirected graph according to the first target node and the second target node may include:
[0124] Step 201 : Calculate the target shortest path between a first target node and a second target node in an undirected graph.
[0125] In an embodiment of the present application, a target shortest path between a first target node and a second target node in an undirected graph can be calculated using a preset shortest path algorithm, wherein the preset shortest path algorithm can be calibrated according to actual conditions. The preset undirected subgraph extraction algorithm may include the preset shortest path algorithm.
[0126] Step 202: Determine nodes between the first target node and the second target node according to the target shortest path.
[0127] It should be noted that the number of nodes described in this embodiment may be at least one, that is, there is at least one node between the first target node and the second target node.
[0128] Step 203: extract an undirected subgraph from the undirected graph according to the first target node, the second target node, and the node.
[0129] Specifically, after obtaining the first target node and the second target node, the electronic device can directly calculate the target shortest path between the first target node and the second target node in the undirected graph using a preset shortest path algorithm, and determine all nodes between the first target node and the second target node based on the target shortest path. Then, an undirected subgraph is extracted from the undirected graph based on the first target node, the second target node, and all nodes between the first target node and the second target node. That is, all nodes on the shortest path and the connection relationships (structures) between the nodes are extracted from the undirected graph to form an undirected subgraph.
[0130] For example, referring to Figure 3(a) and Figure 3(b), assuming that node A and node C are the first target node and the second target node, for Figure 3(a), after being converted into an undirected graph, the shortest path between node A and node C is ABC. The subgraph composed of the three nodes A, B, and C (A->B<-C) can be used as the influence range of the two nodes A and C, and it can be extracted from the undirected graph converted from Figure 3(a) to form Figure 3(b).
[0131] Therefore, the shortest path can be used to define the influence range of the two target nodes, an undirected subgraph covering the influence range can be constructed, and the joint probability distribution of the two target nodes can be calculated (queried) on the undirected subgraph, thereby achieving the effect of shortening the calculation efficiency.
[0132] In one embodiment of the present application, Figure 4 As shown, determining the node relationship between the first target node and the second target node according to the undirected subgraph may include:
[0133] Step 401: Acquire the attribute relationship between each node in the undirected subgraph, wherein the attribute relationship may include one of a descendant node relationship, an ancestor node relationship, a common ancestor node relationship, and a common descendant node relationship.
[0134] In the embodiment of the present application, the attribute relationship between each node in the undirected subgraph can be obtained through an attribute relationship acquisition model or a preset attribute relationship acquisition algorithm. The preset attribute relationship acquisition algorithm can be calibrated according to actual conditions.
[0135] It should be noted that the attribute relationship acquisition model described in this embodiment may be trained in advance and pre-stored in the storage space of the electronic device for easy retrieval and application.
[0136] Specifically, after obtaining the undirected subgraph corresponding to the first target node and the second target node, the electronic device can input the undirected subgraph into the attribute relationship acquisition model, thereby processing the undirected subgraph through the attribute relationship acquisition model to output the attribute relationship between each node in the undirected subgraph, or directly obtain the attribute relationship between each node in the undirected subgraph according to the preset attribute relationship acquisition algorithm and the undirected subgraph calculation. No limitations are made here.
[0137] Step 402: Determine the node relationship between the first target node and the second target node according to the attribute relationship between each node.
[0138] To clearly illustrate the previous embodiment, in one embodiment of the present application, determining the node relationship between the first target node and the second target node based on the attribute relationship between each node may include: if one of the first target node and the second target node is a descendant node or ancestor node of the other target node, determining that the node relationship between the first target node and the second target node is a non-direct causal chain relationship; if the first target node and the second target node have a common ancestor node, determining that the node relationship between the first target node and the second target node is a common cause relationship; if the first target node and the second target node have a common descendant node, determining that the node relationship between the first target node and the second target node is a common result relationship.
[0139] Furthermore, in another embodiment of the present application, the above-mentioned calculation method of the joint probability distribution may also include, when it is determined that the node relationship between the first target node and the second target node is not an indirect causal chain relationship, a common cause relationship or a common effect relationship, determining that the node relationship between the first target node and the second target node is a candidate relationship.
[0140] Specifically, after obtaining the attribute relationship between each node in the undirected subgraph, the electronic device can first determine the attribute relationship between the first target node and the second target node. If one of the first target node and the second target node is a descendant node or ancestor node of the other target node, it can be directly judged that the node relationship between the first target node and the second target node is an indirect causal chain relationship, for example, the indirect causal chain relationship between node A and node C in Figure 5(a).
[0141] If the node relationship between the first target node and the second target node is not an indirect causal chain relationship, it is possible to check whether the first target node and the second target node have a common ancestor node. If the first target node and the second target node have a common ancestor node, it can be determined that the node relationship between the first target node and the second target node is a common cause relationship, for example, the common cause relationship between node A and node C in Figure 5(b).
[0142] If the node relationship between the first target node and the second target node is neither an indirect causal chain relationship nor a common cause relationship, it is possible to continue to check whether the first target node and the second target node have a common descendant node. If so, it can be determined that the node relationship between the first target node and the second target node is a common result relationship, for example, the common result relationship between node A and node C in Figure 3(b).
[0143] If the node relationship between the first target node and the second target node does not belong to any of the above, the node relationship between the first target node and the second target node can be directly determined to be a candidate relationship, and the candidate relationship can cover any node relationship except the above three relationships.
[0144] In one embodiment of the present application, Figure 6 Calculating the joint probability distribution between the first target node and the second target node based on the node relationship and the DAG graph may include:
[0145] Step 601: extract the corresponding directed acyclic subgraph from the DAG graph according to the first target node, the second target node and the node.
[0146] Specifically, after determining the node relationship between the first target node and the second target node, the electronic device can extract the corresponding directed acyclic subgraph from the DAG graph based on the first target node, the second target node and the node, that is, the first target node, the second target node and the node and the connection relationship between them are extracted from the DAG graph to form a directed acyclic subgraph.
[0147] Step 602: If the node relationship is a same-result relationship or a candidate relationship, the directed acyclic subgraph is processed according to the probabilistic graph model to obtain a joint probability distribution between the first target node and the second target node.
[0148] It should be noted that the probabilistic graph model described in this embodiment may be trained in advance and pre-stored in the storage space of the electronic device for easy retrieval and application.
[0149] Specifically, after the electronic device obtains the directed acyclic subgraph corresponding to the first target node and the second target node, if it determines that the node relationship between the first target node and the second target node is a same-result relationship or a candidate relationship, the directed acyclic subgraph can be input into the probabilistic graphical model, thereby processing the directed acyclic subgraph through the probabilistic graphical model to output the joint probability distribution between the first target node and the second target node.
[0150] It should be noted that the probabilistic graphical model can be obtained based on Bayesian network training, wherein, according to the basic independence and D-separation of the Bayesian network, if the first target node A and the second target node C are on the same DAG graph, have no common ancestor node and are not each other's ancestor / descendant nodes, then there must be a v-structure between the first target node A and the second target node C. In the absence of observed variables, there is no valid trace between the first target node A and the second target node C. Then the first target node A and the second target node C can be D-separated, and P(A, C) = P(A) x P(C) can be used to solve their joint probability distribution.
[0151] Among them, effective trace: Let G be a Bayesian network structure, and is a trace in G, let Z be a subset of the observed variables, given Z, if:
[0152] a) Once there is a v-structure X i-1 →X i →X i+1 , then X i Or one of its descendants is in Z.
[0153] b) No other nodes on the trace are in Z.
[0154] Then the trace It is a valid trace.
[0155] D-separation: In a Bayesian network G, for two nodes X and Y, if any path Trail between X and Y exists in a node set Z that satisfies one of the following two conditions, then X and Y are D-separated: 1. There is no collider in the Trail, and all the connection points between X and Y are in the set Z; 2. There is a collider in the Trail, and the collider between X and Y is not in Z, and none of the descendants of the collider are in Z.
[0156] Collision point (collider): For example, node B in Figure 3(b).
[0157] Step 603: If the node relationship is an indirect causal chain relationship, a joint probability distribution between the first target node and the second target node is generated based on a preset algorithm and a directed acyclic subgraph. The preset algorithm can be calibrated according to actual conditions.
[0158] Specifically, after the electronic device obtains the directed acyclic subgraph corresponding to the first target node and the second target node, if it is determined that the node relationship between the first target node and the second target node is a non-direct causal chain relationship, it can directly generate a joint probability distribution between the first target node and the second target node according to the preset algorithm and the directed acyclic subgraph, that is, for each node in the directed acyclic subgraph (that is, the node chain), the preset algorithm is used to remove the influence, and the conditional probability distribution within the influence range of each node in the directed acyclic subgraph (that is, the joint probability distribution) is stored.
[0159] It should be noted that the preset algorithm described in this embodiment may refer to: in the process of building and learning the Bayesian network, the number of events of each node variable is calculated and retained. When performing conditional probability query (calculation), the conditional probability distribution corresponding to the node and the number of corresponding events are first obtained. Combined with the conditional probability distribution of the node and the number of corresponding events, the required distribution corresponding to the node is calculated. The conditional probability of a under the given condition b is expressed as P(a|b). For a network containing X1,…,X N The Bayesian network of N nodes, P(X0|X N )=∑…∑P(X0|X1,…,X N )×P(X2,…,X N |X1). For example, for Figure 3(a), the obtained subgraph is as follows Figure 7 As shown, what we want to calculate is the joint probability distribution of nodes A and E: P(A,E), P(A,E) = ∑ B P(E|B)×P(B|A)×P(A). However, the data stored in the original image is only P(B|A,C). Therefore, we need to use the preset algorithm to calculate P(B|A). P(B|A) can be calculated using C(B,A). The formula is: C(B,A) is the number of times the value combination of B and A occurs simultaneously.
[0160] Step 604: If the node relationship is a common cause relationship, obtain the common ancestor node of the first target node and the second target node.
[0161] Specifically, after the electronic device obtains the directed acyclic subgraph corresponding to the first target node and the second target node, if it determines that the node relationship between the first target node and the second target node is a common cause relationship, the common ancestor node of the first target node and the second target node can be extracted from the undirected subgraph.
[0162] Step 605 , calculating a first shortest path between the first target node and the common ancestor node in the undirected subgraph, and calculating a second shortest path between the second target node and the common ancestor node in the undirected subgraph.
[0163] Step 606 : extracting a first subgraph corresponding to the first shortest path and a second subgraph corresponding to the second shortest path from the directed acyclic subgraph according to the first shortest path and the second shortest path.
[0164] Step 607 : Generate a joint probability distribution between the first target node and the second target node according to a preset algorithm, the first subgraph, and the second subgraph.
[0165] Specifically, after obtaining the common ancestor node of the first target node and the second target node, the electronic device can directly calculate the first shortest path between the first target node and the common ancestor node in the undirected subgraph, and calculate the second shortest path between the second target node and the common ancestor node in the undirected subgraph using a preset shortest path algorithm. Then, based on the first shortest path and the second shortest path, the first subgraph corresponding to the first shortest path and the second subgraph corresponding to the second shortest path can be extracted from the directed acyclic subgraph, that is, all nodes on the first shortest path and the second shortest path and the connection relationship (structure) between each node are extracted from the directed acyclic subgraph to form the first subgraph and the second subgraph respectively.
[0166] Then, the electronic device can calculate the first joint probability distribution and the second joint probability distribution according to the preset algorithm and the first subgraph, and according to the preset algorithm and the second subgraph, respectively, and finally add the first joint probability distribution and the second joint probability distribution together to generate a joint probability distribution between the first target node and the second target node.
[0167] In the embodiments of the present application, the problem of low timeliness in solving the joint probability distribution of two nodes in the related art can be solved, and the highly complex solution process of traversing all nodes of the Bayesian network to solve the joint probability distribution can be skipped. At the same time, the influence range of the two nodes for which the joint probability distribution needs to be calculated (queried) can be defined and extracted from the original discrete Bayesian network using the shortest path method, and a subgraph can be constructed. The joint probability distribution is calculated on the subgraph by using the number of events to remove the influence of nodes outside the influence range, thereby achieving the effect of improving computational efficiency.
[0168] Moreover, by using the calculation method of the joint probability distribution provided in the embodiment of the present application, users can accurately and quickly calculate (query) the joint probability distribution of any two nodes (i.e., data) in the directed acyclic graph (DAG), so that users can better analyze the data and their relationships in the directed acyclic graph (DAG).
[0169] In summary, according to the calculation method of the joint probability distribution of the embodiment of the present application, first obtain a directed acyclic graph (DAG) graph, convert the DAG graph into an undirected graph, and extract the first target node and the second target node from the undirected graph. Then, according to the first target node and the second target node, extract the corresponding undirected subgraph from the undirected graph, and determine the node relationship between the first target node and the second target node based on the undirected subgraph. Finally, calculate the joint probability distribution between the first target node and the second target node based on the node relationship and the DAG graph. In this way, the speed and efficiency of the joint probability distribution calculation can be effectively improved.
[0170] Figure 8 4 is a block diagram of a device for calculating joint probability distribution according to one embodiment of the present application.
[0171] The calculation device for the joint probability distribution of the embodiment of the present application can be configured in an electronic device to obtain a directed acyclic graph (DAG) and convert the DAG into an undirected graph, and extract the first target node and the second target node from the undirected graph, and then extract the corresponding undirected subgraph from the undirected graph based on the first target node and the second target node, and determine the node relationship between the first target node and the second target node based on the undirected subgraph, and calculate the joint probability distribution between the first target node and the second target node based on the node relationship and the DAG, thereby effectively improving the speed and efficiency of the joint probability distribution calculation.
[0172] like Figure 8 As shown, the joint probability distribution calculation device 800 may include: an acquisition module 810 , a first extraction module 820 , a second extraction module 830 , a determination module 840 and a calculation module 850 .
[0173] The acquisition module 810 is used to acquire a directed acyclic graph (DAG) and convert the DAG into an undirected graph.
[0174] The first extraction module 820 is used to extract a first target node and a second target node from the undirected graph.
[0175] The second extraction module 830 is configured to extract a corresponding undirected subgraph from the undirected graph according to the first target node and the second target node.
[0176] The determination module 840 is configured to determine a node relationship between a first target node and a second target node according to the undirected subgraph.
[0177] The calculation module 850 is used to calculate the joint probability distribution between the first target node and the second target node according to the node relationship and the DAG graph.
[0178] In one embodiment of the present application, the first target node and the second target node are two non-adjacent nodes.
[0179] In one embodiment of the present application, the second extraction module 830 is specifically used to: calculate the target shortest path between the first target node and the second target node in the undirected graph; determine the nodes between the first target node and the second target node based on the target shortest path; and extract an undirected subgraph from the undirected graph based on the first target node, the second target node and the node.
[0180] In one embodiment of the present application, the node relationship is one of an indirect causal chain relationship, a same-effect relationship, a same-cause relationship and a candidate relationship, and the indirect causal chain relationship includes an indirect cause chain relationship and an indirect effect chain relationship, wherein the candidate relationship is any node relationship other than the indirect causal chain relationship, the same-effect relationship and the same-cause relationship.
[0181] In one embodiment of the present application, Figure 8 As shown, the determination module 840 may include: an acquisition unit 841 and a determination unit 842.
[0182] The acquisition unit 841 is used to acquire the attribute relationship between each node in the undirected subgraph.
[0183] The determining unit 842 is configured to determine a node relationship between the first target node and the second target node according to an attribute relationship between each node.
[0184] In one embodiment of the present application, the attribute relationship includes one of a descendant node relationship, an ancestor node relationship, a common ancestor node relationship, and a common descendant node relationship.
[0185] In one embodiment of the present application, the determination unit 842 is specifically used to: if one of the first target node and the second target node is a descendant node or ancestor node of the other target node, then determine that the node relationship between the first target node and the second target node is an indirect causal chain relationship; if the first target node and the second target node have a common ancestor node, then determine that the node relationship between the first target node and the second target node is a common cause relationship; if the first target node and the second target node have a common descendant node, then determine that the node relationship between the first target node and the second target node is a common effect relationship.
[0186] In one embodiment of the present application, the determination unit 842 is also used to: when it is determined that the node relationship between the first target node and the second target node is not an indirect causal chain relationship, a common cause relationship or a common effect relationship, determine that the node relationship between the first target node and the second target node is a candidate relationship.
[0187] In one embodiment of the present application, the computing module 850 is specifically used to: extract a corresponding directed acyclic subgraph from the DAG graph according to the first target node, the second target node and the node; if the node relationship is a same-result relationship or a candidate relationship, the directed acyclic subgraph is processed according to the probabilistic graph model to obtain a joint probability distribution between the first target node and the second target node.
[0188] In one embodiment of the present application, the calculation module 850 is also used to: if the node relationship is an indirect causal chain relationship, generate a joint probability distribution between the first target node and the second target node according to a preset algorithm and a directed acyclic subgraph.
[0189] In one embodiment of the present application, the calculation module 850 is also used to: if the node relationship is a common cause relationship, obtain the common ancestor node of the first target node and the second target node; calculate the first shortest path between the first target node and the common ancestor node in the undirected subgraph, and calculate the second shortest path between the second target node and the common ancestor node in the undirected subgraph; extract the first subgraph corresponding to the first shortest path and the second subgraph corresponding to the second shortest path from the directed acyclic subgraph according to the first shortest path and the second shortest path; generate a joint probability distribution between the first target node and the second target node according to a preset algorithm, the first subgraph and the second subgraph.
[0190] It should be noted that for details not disclosed in the joint probability distribution calculation device of the embodiment of the present invention, please refer to the details disclosed in the joint probability distribution calculation method of the embodiment of the present invention, and the details will not be repeated here.
[0191] In summary, the calculation device of the joint probability distribution of the embodiment of the present application first obtains the directed acyclic graph DAG graph through the acquisition module, and converts the DAG graph into an undirected graph, and extracts the first target node and the second target node from the undirected graph through the first extraction module, and extracts the corresponding undirected subgraph from the undirected graph according to the first target node and the second target node through the second extraction module, and then determines the node relationship between the first target node and the second target node according to the undirected subgraph through the determination module, and finally calculates the joint probability distribution between the first target node and the second target node according to the node relationship and the DAG graph through the calculation module. In this way, the speed and efficiency of the joint probability distribution calculation can be effectively improved.
[0192] In order to implement the above embodiment, Figure 9 As shown, the present invention also proposes an electronic device 900, including a memory 910, a processor 920, and a computer program stored in the memory 910 and executable on the processor 920. The processor 920 executes the program to implement the calculation method of the joint probability distribution proposed in the aforementioned embodiment of the present application.
[0193] The electronic device of the embodiment of the present application can effectively improve the speed and efficiency of joint probability distribution calculation by executing a computer program stored in a memory through a processor.
[0194] In order to implement the above embodiments, the present invention also proposes a non-temporary computer-readable storage medium on which a computer program is stored. The program is executed by a processor to implement the calculation method of the joint probability distribution proposed in the above embodiments of the present application.
[0195] The computer-readable storage medium of the embodiment of the present application can effectively improve the speed and efficiency of joint probability distribution calculation by storing a computer program and being executed by a processor.
[0196] In the description of this specification, the terms "first" and "second" are used for descriptive purposes only and should not be understood to indicate or imply relative importance or implicitly specify the number of the technical features indicated. Therefore, a feature specified as "first" or "second" may explicitly or implicitly include at least one of such features. In the description of this application, "plurality" means at least two, for example, two, three, etc., unless otherwise specifically defined.
[0197] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art can combine and combine different embodiments or examples described in this specification and features of different embodiments or examples without contradiction.
[0198] Although the embodiments of the present application have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limitations on the present application. Ordinary technicians in this field can change, modify, replace and modify the above embodiments within the scope of the present application.
Claims
1. A method for calculating joint probability distribution, which is used to analyze and mine time series data of a shopping platform, characterized in that: include: Obtaining a directed acyclic graph (DAG) corresponding to time series data of a shopping platform, and converting the DAG into an undirected graph, wherein the time series data includes at least one of the following: shopping information of users on the shopping platform, and sales information of a product and its supporting products on the shopping platform; extracting a first target node and a second target node from the undirected graph; Calculate the target shortest path between the first target node and the second target node in the undirected graph; Determine a node between the first target node and the second target node according to the target shortest path; Extracting an undirected subgraph from the undirected graph according to the first target node, the second target node, and the node; Determine a node relationship between the first target node and the second target node according to the undirected subgraph; as well as A joint probability distribution between the first target node and the second target node is calculated based on the node relationship and the DAG graph.
2. The method for calculating the joint probability distribution according to claim 1, wherein: in, The first target node and the second target node are two non-adjacent nodes.
3. The method for calculating the joint probability distribution according to claim 1, wherein: in, The node relationship is one of an indirect causal chain relationship, a same-effect relationship, a same-cause relationship and a candidate relationship, and the indirect causal chain relationship includes an indirect cause chain relationship and an indirect effect chain relationship, wherein the candidate relationship is any node relationship other than the indirect causal chain relationship, the same-effect relationship and the same-cause relationship.
4. The method for calculating the joint probability distribution according to claim 3, wherein: The determining the node relationship between the first target node and the second target node according to the undirected subgraph includes: Obtain the attribute relationship between each node in the undirected subgraph; The node relationship between the first target node and the second target node is determined according to the attribute relationship between each node.
5. The method for calculating the joint probability distribution according to claim 4, wherein: in, The attribute relationship includes one of a descendant node relationship, an ancestor node relationship, a common ancestor node relationship, and a common descendant node relationship.
6. The method for calculating the joint probability distribution according to claim 5, wherein: The determining the node relationship between the first target node and the second target node according to the attribute relationship between each node includes: If one of the first target node and the second target node is a descendant node or an ancestor node of the other target node, determining that the node relationship between the first target node and the second target node is the indirect causal chain relationship; If the first target node and the second target node have a common ancestor node, determining that the node relationship between the first target node and the second target node is the common cause relationship; If the first target node and the second target node have a common descendant node, the node relationship between the first target node and the second target node is determined to be the same-result relationship.
7. The method for calculating the joint probability distribution according to claim 6, wherein: Also includes: When it is determined that the node relationship between the first target node and the second target node is not the indirect causal chain relationship, the common cause relationship or the common effect relationship, the node relationship between the first target node and the second target node is determined to be the candidate relationship.
8. The method for calculating the joint probability distribution according to claim 7, wherein: The calculating a joint probability distribution between the first target node and the second target node according to the node relationship and the DAG graph includes: Extracting a corresponding directed acyclic subgraph from the DAG graph according to the first target node, the second target node, and the node; If the node relationship is the same-result relationship or the candidate relationship, the directed acyclic subgraph is processed according to a probabilistic graphical model to obtain a joint probability distribution between the first target node and the second target node.
9. The method for calculating the joint probability distribution according to claim 8, wherein: Also includes: If the node relationship is the indirect causal chain relationship, a joint probability distribution between the first target node and the second target node is generated according to a preset algorithm and the directed acyclic subgraph.
10. The method for calculating the joint probability distribution according to claim 8, wherein: Also includes: If the node relationship is the same-cause relationship, obtaining a common ancestor node of the first target node and the second target node; Calculating a first shortest path between the first target node and the common ancestor node in the undirected subgraph, and calculating a second shortest path between the second target node and the common ancestor node in the undirected subgraph; Extracting a first subgraph corresponding to the first shortest path and a second subgraph corresponding to the second shortest path from the directed acyclic subgraph according to the first shortest path and the second shortest path; A joint probability distribution between the first target node and the second target node is generated according to a preset algorithm, the first subgraph, and the second subgraph.
11. A device for calculating joint probability distribution, used for analyzing and mining time series data of a shopping platform, characterized in that: include: an acquisition module, configured to acquire a directed acyclic graph (DAG) corresponding to time series data of a shopping platform and convert the DAG into an undirected graph, wherein the time series data includes at least one of the following: shopping information of users on the shopping platform, and sales information of a product and its supporting products on the shopping platform; A first extraction module, configured to extract a first target node and a second target node from the undirected graph; A second extraction module is configured to calculate a target shortest path between the first target node and the second target node in the undirected graph; Determine a node between the first target node and the second target node according to the target shortest path; Extracting an undirected subgraph from the undirected graph according to the first target node, the second target node, and the node; a determination module, configured to determine a node relationship between the first target node and the second target node according to the undirected subgraph; as well as A calculation module is used to calculate the joint probability distribution between the first target node and the second target node based on the node relationship and the DAG graph.
12. The method for calculating the joint probability distribution according to claim 11, wherein: in, The first target node and the second target node are two non-adjacent nodes.
13. The method for calculating the joint probability distribution according to claim 11, wherein: in, The node relationship is one of an indirect causal chain relationship, a same-effect relationship, a same-cause relationship and a candidate relationship, and the indirect causal chain relationship includes an indirect cause chain relationship and an indirect effect chain relationship, wherein the candidate relationship is any node relationship other than the indirect causal chain relationship, the same-effect relationship and the same-cause relationship.
14. The method for calculating the joint probability distribution according to claim 13, wherein: The determining module includes: An acquisition unit, configured to acquire an attribute relationship between each node in the undirected subgraph; A determining unit is configured to determine a node relationship between the first target node and the second target node according to an attribute relationship between each of the nodes.
15. The method for calculating the joint probability distribution according to claim 14, wherein: in, The attribute relationship includes one of a descendant node relationship, an ancestor node relationship, a common ancestor node relationship, and a common descendant node relationship.
16. The method for calculating the joint probability distribution according to claim 15, wherein: The determining unit is specifically configured to: If one of the first target node and the second target node is a descendant node or an ancestor node of the other target node, determining that the node relationship between the first target node and the second target node is the indirect causal chain relationship; If the first target node and the second target node have a common ancestor node, determining that the node relationship between the first target node and the second target node is the common cause relationship; If the first target node and the second target node have a common descendant node, the node relationship between the first target node and the second target node is determined to be the same-result relationship.
17. The method for calculating a joint probability distribution according to claim 16, wherein: The determining unit is further configured to: When it is determined that the node relationship between the first target node and the second target node is not the indirect causal chain relationship, the common cause relationship or the common effect relationship, the node relationship between the first target node and the second target node is determined to be the candidate relationship.
18. The method for calculating a joint probability distribution according to claim 15, wherein: The computing module is specifically configured to: Extracting a corresponding directed acyclic subgraph from the DAG graph according to the first target node, the second target node, and the node; If the node relationship is the same-result relationship or the candidate relationship, the directed acyclic subgraph is processed according to a probabilistic graphical model to obtain a joint probability distribution between the first target node and the second target node.
19. The method for calculating a joint probability distribution according to claim 18, wherein: The computing module is further configured to: If the node relationship is the indirect causal chain relationship, a joint probability distribution between the first target node and the second target node is generated according to a preset algorithm and the directed acyclic subgraph.
20. The method for calculating a joint probability distribution according to claim 18, wherein: The computing module is further configured to: If the node relationship is the same-cause relationship, obtaining a common ancestor node of the first target node and the second target node; Calculating a first shortest path between the first target node and the common ancestor node in the undirected subgraph, and calculating a second shortest path between the second target node and the common ancestor node in the undirected subgraph; Extracting a first subgraph corresponding to the first shortest path and a second subgraph corresponding to the second shortest path from the directed acyclic subgraph according to the first shortest path and the second shortest path; A joint probability distribution between the first target node and the second target node is generated according to a preset algorithm, the first subgraph, and the second subgraph.
21. An electronic device, characterized in that: The method comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the method for calculating the joint probability distribution according to any one of claims 1 to 10 is implemented.
22. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method for calculating the joint probability distribution according to any one of claims 1 to 10 is implemented.
Citation Information
Patent Citations
Systems, methods, and computer program products for generating a query specific bayesian network
US20170024652A1