Node interaction prediction method and device, computer equipment and storage medium
By acquiring and processing the spatiotemporal-encoded node representation matrix in the dynamic graph dataset, using the prediction model to predict node interaction in the dynamic graph, the prediction problem caused by not taking into account spatiotemporal characteristics in the prior art is solved, and the prediction results are improved accuracy.
Patent Information
- Application Number
- CN202410865359.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-28
- Publication Date
- 2024-11-12
AI Technical Summary
The prior art does not consider the spatiotemporal characteristics between nodes in the representation learning of dynamic graphs, resulting in inaccurate prediction results.
By obtaining the sampling node set of target node pairs at preset times in the dynamic graph dataset, the node representation matrix is determined based on the spatiotemporal encoding of each first node in each sampling node set, and the node representation matrix is represented by the pre-constructed target prediction model. Processing is performed to obtain the interaction prediction results of the target node at the preset time of the target node.
Predictive analysis is performed in combination with the spatiotemporal characteristics between nodes, which improves the accuracy of prediction results.
Smart Images

Figure CN118940878A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to a method, apparatus, computer device and storage medium for predicting node interactions. Background Art
[0002] In scenarios such as social networks and recommendation systems, dynamic graphs are often used to analyze changes in the relationship between users and items, and between users. For the representation learning of dynamic graphs, existing technologies usually use methods such as time-series message passing, but the prediction method based on this type of node representation method does not consider the temporal and spatial characteristics between nodes, resulting in inaccurate prediction results.
[0003] There is no effective solution to the problem that the relevant technology does not take into account the temporal and spatial characteristics between nodes, resulting in inaccurate prediction results. Summary of the invention
[0004] In this embodiment, a node interaction prediction method, apparatus, computer device and storage medium are provided to solve the problem that the related art does not consider the spatiotemporal characteristics between nodes, resulting in inaccurate prediction results.
[0005] In a first aspect, a method for predicting node interaction is provided in this embodiment, and the method includes:
[0006] In the dynamic graph data set, obtain the sampling node set corresponding to each target node in the target node pair at a preset time;
[0007] Based on the spatiotemporal coding of each first node in each of the sampling node sets, determining a node representation matrix corresponding to the sampling node set; wherein the spatiotemporal coding of each of the first nodes is correlated;
[0008] Each of the node representation matrices is processed by a pre-constructed target prediction model to obtain an interactive prediction result of the target node in the target node pair at the preset time.
[0009] In some embodiments, determining the node representation matrix corresponding to the sampling node set based on the spatiotemporal coding of each first node in each sampling node set includes:
[0010] Respectively determine the spatial distance and the temporal distance between each of the first nodes in the sampling node set and the target node;
[0011] Based on a preset coding function, the spatial distance and the temporal distance corresponding to each of the first nodes are coded to obtain the spatiotemporal coding of the first node with respect to the corresponding target node;
[0012] Based on the spatiotemporal coding of each of the first nodes, a node representation matrix corresponding to the sampling node set is determined.
[0013] In some embodiments, determining the spatial distance between each of the first nodes in the sampling node set and the target node includes:
[0014] In the dynamic graph data set, obtaining a multi-hop neighbor subgraph structure corresponding to each of the target nodes at the preset time;
[0015] Determine the number of hops between the target node and each first node in the multi-hop neighbor subgraph structure;
[0016] The minimum number of hops is used as the spatial distance between the first node and the target node.
[0017] In some embodiments, determining the time distance between each of the first nodes in the sampling node set and the target node includes:
[0018] Acquire an interaction time sequence between each of the first nodes and the target node before the preset time;
[0019] Based on the interaction time series, a time distance between the first node and the target node is determined.
[0020] In some embodiments, determining the node representation matrix corresponding to the sampling node set based on the spatiotemporal coding of each of the first nodes includes:
[0021] Obtaining the original node attribute of each of the first nodes;
[0022] splicing the original node attribute of each first node with the spatiotemporal code to obtain a node representation of the first node;
[0023] Based on the node representations of each of the first nodes, a node representation matrix corresponding to the sampling node set is constructed.
[0024] In some embodiments, the calculation formula of the spatiotemporal coding of the first node is:
[0025] STPE u (w;u,t pred )=MLP(Enc(TD(w,u,t pred )))||MLP(Enc(SD(w,u,t pred )));
[0026] Among them, STPE u 9w;u,t pred ) is the first node w with respect to the target node u at time tpred spatiotemporal coding; MLP is a multi-layer perceptron; Enc is a preset encoding function; || is a concatenation operation; TD9w,u,t pred ) is the first node w and the target node u at time t pred Time distance; SD9w,u,t pred ) is the first node w and the target node u at time t pred spatial distance.
[0027] In some of the embodiments, obtaining, in the dynamic graph data set, a set of sampling nodes corresponding to each target node in a target node pair at a preset time includes:
[0028] Based on each target node in the target node pair at a preset time, context node sampling is performed on the dynamic graph data set to obtain the sampling node set corresponding to each target node.
[0029] In some of the embodiments, the target prediction model includes an input layer, an intermediate layer and an output layer; wherein,
[0030] The input layer is used to receive the node representation matrix corresponding to each of the sampling node sets;
[0031] The intermediate layer is used to process each node representation matrix based on the self-attention matrix and the feedforward neural network;
[0032] The output layer is used to perform a pooling operation on the last layer representation of each of the first nodes in the processing results, and determine the interaction prediction result of the target node in the target node pair at the preset time based on the pooling result.
[0033] In a second aspect, a node interaction prediction device is provided in this embodiment, the device comprising: a sampling module, an encoding module and a prediction module;
[0034] The sampling module is used to obtain a sampling node set corresponding to each target node in a target node pair at a preset time in the dynamic graph data set;
[0035] The encoding module is used to determine the node representation matrix corresponding to the sampling node set based on the spatiotemporal encoding of each first node in each of the sampling node sets; wherein the spatiotemporal encodings of each of the first nodes are correlated;
[0036] The prediction module is used to process each of the node representation matrices through a pre-constructed target prediction model to obtain an interaction prediction result of the target node in the target node pair at the preset time.
[0037] In a third aspect, a computer device is provided in this embodiment, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the node interaction prediction method described in the first aspect is implemented.
[0038] In a fourth aspect, a storage medium is provided in this embodiment, on which a computer program is stored, and when the program is executed by a processor, the method for predicting node interaction described in the first aspect above is implemented.
[0039] Compared with the related art, the node interaction prediction method, device, computer equipment and storage medium provided in the present embodiment obtain a sampling node set corresponding to each target node in a target node pair at a preset time in a dynamic graph data set; based on the spatiotemporal coding of each first node in each sampling node set, determine the node representation matrix corresponding to the sampling node set, wherein the spatiotemporal coding of each first node is correlated; further, through a pre-constructed target prediction model, process each node representation matrix to obtain the interaction prediction result of the target node in the target node pair at the preset time, thereby solving the problem of inaccurate prediction results caused by not considering the spatiotemporal characteristics between nodes, and realizing prediction analysis combined with the spatiotemporal characteristics between nodes, thereby improving the accuracy of the prediction results.
[0040] Details of one or more embodiments of the present application are set forth in the following drawings and description to make other features, objects, and advantages of the present application more readily apparent. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0042] Figure 1 It is a hardware structure block diagram of a terminal device of a node interaction prediction method provided in an embodiment of the present application;
[0043] Figure 2 is a flowchart of a method for predicting node interaction provided by an embodiment of the present application;
[0044] Figure 3 is a schematic diagram of a node interaction event provided by an embodiment of the present application;
[0045] Figure 4 is a schematic diagram of context node sampling provided by an embodiment of the present application;
[0046] Figure 5 is a schematic diagram of node encoding processing provided by an embodiment of the present application;
[0047] Figure 6 is a schematic diagram of a target prediction model provided by an embodiment of the present application;
[0048] Figure 7 It is a flowchart of a method for predicting node interaction provided by a preferred embodiment of the present application;
[0049] Figure 8 It is a structural block diagram of a node interaction prediction device provided in one embodiment of the present application.
[0050] In the figure: 102, processor; 104, memory; 106, transmission device; 108, input and output device; 10, sampling module; 20, encoding module; 30, prediction module. DETAILED DESCRIPTION
[0051] In order to more clearly understand the purpose, technical solutions and advantages of the present application, the present application is described and illustrated below in conjunction with the accompanying drawings and embodiments.
[0052] Unless otherwise defined, the technical terms or scientific terms involved in this application shall have the general meaning understood by people with ordinary skills in the technical field to which this application belongs. The words "one", "a", "a", "the", "these" and the like in this application do not represent quantitative restrictions, and they can be singular or plural. The terms "include", "comprise", "have" and any variants thereof involved in this application are intended to cover non-exclusive inclusions; for example, a process, method and system, product or device comprising a series of steps or modules (units) is not limited to the listed steps or modules (units), but may include unlisted steps or modules (units), or may include other steps or modules (units) inherent to these processes, methods, products or devices. The words "connect", "connected", "coupled" and the like involved in this application are not limited to physical or mechanical connections, but may include electrical connections, whether directly or indirectly. The "multiple" involved in this application refers to two or more. "And / or" describes the association relationship of associated objects, indicating that there can be three relationships. For example, "A and / or B" can mean: A exists alone, A and B exist at the same time, and B exists alone. Usually, the character " / " indicates that the objects associated with each other are in an "or" relationship. The terms "first", "second", "third", etc. involved in this application are only used to distinguish similar objects and do not represent a specific ordering of the objects.
[0053] The method embodiment provided in this embodiment can be executed in a terminal, a computer or a similar computing device. For example, running on a terminal, Figure 1 FIG. 4 is a hardware structure block diagram of a terminal of the node interaction prediction method of this embodiment. Figure 1As shown, the terminal may include one or more ( Figure 1 Only one is shown in the figure) processor 102 and memory 104 for storing data, wherein processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA. The above terminal may also include a transmission device 106 and an input and output device 108 for communication functions. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above terminal. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations shown.
[0054] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the prediction method of node interaction in this embodiment. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, to implement the above method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0055] The transmission device 106 is used to receive or send data via a network. The above network includes a wireless network provided by the communication provider of the terminal. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (Radio Frequency, referred to as RF) module, which is used to communicate with the Internet wirelessly.
[0056] In this embodiment, a method for predicting node interaction is provided. Figure 2 is a flowchart of the node interaction prediction method of this embodiment, such as Figure 2 As shown, the process includes the following steps:
[0057] Step S210, obtaining a sampling node set corresponding to each target node in a target node pair at a preset time in the dynamic graph data set;
[0058] Step S220, determining a node representation matrix corresponding to the sampling node set based on the spatiotemporal coding of each first node in each sampling node set; wherein the spatiotemporal coding of each first node is correlated with each other;
[0059] Step S230, processing each node representation matrix through a pre-constructed target prediction model to obtain an interaction prediction result of a target node in a target node pair at a preset time.
[0060] In this embodiment, the dynamic graph dataset records the interaction events that occur at different nodes at different times. Each interaction event usually includes the two nodes and time information where the interaction occurs. M represents the total time, u i and v i Represents the associated node, e i Indicates the properties of the node event, t i Represents the node interaction time. Among them, the tuple (u i , v i , t i ) represents node u i and v i At time t i An interaction event occurs, such as Figure 3 As shown, node u and node v are at time t 9 An interaction event occurs.
[0061] Specifically, in the dynamic graph data set, the target node pair at a preset time is determined as the object to be predicted, for example, at the preset time t pred The node pair (u, v) is sampled based on each target node in the target node pair at a preset moment, and a sampling node set corresponding to each target node is obtained, and each first node in the sampling node set is the context node of the target node.
[0062] It should be noted that the categories to which the above target nodes belong vary with different application scenarios. For example, in social network relationship prediction, each target node in a target node pair is usually a different user; in a recommendation system, each target node in a target node pair is a user and an item, etc.
[0063] Furthermore, the spatial distance and time distance between each first node and the target node in the sampling node set are calculated respectively, and the spatial distance and time distance corresponding to each first node are encoded based on a preset encoding function to obtain the spatiotemporal encoding of the first node. The spatiotemporal encoding is the encoding of the first node with respect to the corresponding target node, that is, the spatiotemporal encodings of the first nodes are correlated.
[0064] Afterwards, based on the spatiotemporal coding of each first node, a node representation matrix corresponding to the sampling node set is constructed to obtain the node representation matrix corresponding to each target node, thereby achieving effective and accurate node representation. Each node representation matrix is input into the pre-constructed target prediction model to obtain the interaction probability of the target node in the target node pair at the preset time.
[0065] For representation learning of dynamic graphs, existing technologies usually adopt methods such as time-series message passing. However, the prediction method based on this type of node representation does not consider the temporal and spatial characteristics between nodes, resulting in inaccurate prediction results.
[0066] Compared with the prior art, the present application obtains the sampling node set corresponding to each target node in the target node pair at a preset time in the dynamic graph data set; based on the spatiotemporal coding of each first node in each sampling node set, the node representation matrix corresponding to the sampling node set is determined, wherein the spatiotemporal coding of each first node is correlated; further, each node representation matrix is processed through a pre-constructed target prediction model to obtain the interactive prediction result of the target node in the target node pair at the preset time. Based on this, by determining the context node of the target node, using the spatiotemporal coding of the context node with respect to the correlation of each target node, an effective and accurate node representation is achieved, and prediction is performed based on the node representation of the context node, which solves the problem of inaccurate prediction results caused by not considering the spatiotemporal characteristics between nodes, and realizes prediction analysis combined with the spatiotemporal characteristics between nodes, thereby improving the accuracy of the prediction results.
[0067] In some embodiments, determining the node representation matrix corresponding to the sampling node set based on the spatiotemporal coding of each first node in each sampling node set in step S220 includes the following steps:
[0068] Step S221, respectively determining the spatial distance and the temporal distance between each first node in the sampling node set and the target node;
[0069] Step S222: encoding the spatial distance and temporal distance corresponding to each first node based on a preset encoding function to obtain the spatiotemporal encoding of the first node with respect to the corresponding target node;
[0070] Step S223: determining a node representation matrix corresponding to the sampling node set based on the spatiotemporal coding of each first node.
[0071] Specifically, a coding function is predefined, and the coding function is used to encode the spatial distance corresponding to each first node. For each first node in the sampling node set, the spatial distance and time distance between the first node and the corresponding target node are calculated respectively, and based on the preset coding function, the spatial distance and time distance corresponding to each first node are encoded to obtain the spatiotemporal coding of the first node with respect to the corresponding target node. In this embodiment, different coding methods can be used, such as converting the distance from each first node to the target node into a vector through sinusoidal position coding, or converting the distance between nodes into a vector by multiplying a learnable vector with a corresponding numerical value, etc., to realize coding processing and obtain the spatiotemporal coding of each first node with respect to the corresponding target node.
[0072] For example, the encoding function Enc:R + →R 2d as follows:
[0073]
[0074] Among them, Enc(x) is the encoding function, such as Figure 4 As shown, the distance from each first node to the target node is converted into a vector through sinusoidal position coding; ∈ is used to enhance the impact on x. Based on this, for the preset time t pred The first node w under the space-time encoding STPE of the corresponding target node u u 9w;u,t pred ) is as follows: STPE u (w;u,t pred )=MLP(Enc(TD(w,u,t pred )))||MLP(Enc(SD(w,u,t pred )));
[0075] Where MLP represents multi-layer perceptron; Enc is the encoding function; || represents the concatenation operation; TD(w,u,t pred ) represents nodes w and u at time t pred The time distance; SD(w,u,t pred ) represents nodes w and u at time t pred The spatial distance of the first node. The spatiotemporal encoding STPE of the target node pair (u, v) c (w; {u,v},t pred )as follows:
[0076] STPE c (w; {u,v},t pred )=STPE u (w;u,t pred )+STPEv 9w;v,t pred );
[0077] Among them, STPE u 9w;u,t pred ) represents the spatiotemporal encoding of the first node with respect to the target node u; STPE v (w; v, t pred ) represents the spatiotemporal encoding of the first node with respect to the target node v.
[0078] Furthermore, the original node attributes of each first node are obtained, the original node attributes of each first node are spliced with the spatiotemporal coding to obtain the node representation of the first node, and based on the node representation of each first node, a node representation matrix corresponding to the sampling node set is constructed.
[0079] Through this embodiment, the spatial distance and temporal distance between each first node in the sampling node set and the target node are respectively determined, and based on a preset coding function, the spatial distance and temporal distance corresponding to each first node are encoded to obtain the spatiotemporal coding of the first node with respect to the corresponding target node, and based on the spatiotemporal coding of each first node, the node representation matrix corresponding to the sampling node set is determined, thereby utilizing the spatiotemporal coding of the association of the context node with respect to each target node to achieve effective and accurate node representation.
[0080] In some embodiments, determining the spatial distance between each first node in the sampling node set and the target node in step S221 includes the following steps:
[0081] In the dynamic graph dataset, obtain the multi-hop neighbor subgraph structure corresponding to each target node at a preset time;
[0082] Determine the number of hops between the target node and each first node in the multi-hop neighbor subgraph structure;
[0083] The minimum number of hops is taken as the spatial distance between the first node and the target node.
[0084] Specifically, in the dynamic graph data set, based on each target node at a preset time, node sampling is performed on the dynamic graph data set to obtain a multi-hop neighbor subgraph structure corresponding to each target node.
[0085] Furthermore, taking the first node w as an example, the node spatial distance calculation process is explained. Determine the multi-hop neighbor subgraph structure corresponding to the first node w, traverse multiple first nodes w in the subgraph structure, calculate the number of hops between the target node and each first node w in the current context node tree, filter out the minimum number of hops, and use the minimum number of hops as the spatial distance between the current first node and the target node. The specific calculation formula is as follows:
[0086] SD(w,w 0 ,t pred )=min{hop(w′,C(w 0 ,t pred )|w=w′,w′∈C(w 0 ,t pred ))};
[0087] Among them, SD(w,w 0 ,t pred ) represents the first node w and the target node w 0 At time t pred The spatial distance of 0 ,t pred ) represents the multi-hop neighbor subgraph structure corresponding to the target node; the hop function represents the number of hops from node w′ to the target node in the context node tree; min() represents the minimum number of hops. It should be noted that when node w′ does not appear in the context node tree, the spatial distance between the current first node and the target node is set to infinity.
[0088] It should be noted that if Figure 4 As shown, the sampling node set corresponding to each target node includes multiple first nodes w i , this embodiment calculates the spatial distance between each first node and the corresponding target node. In addition to the above calculation method, the spatial distance between each first node and the target node can be determined by random walk, and the shortest path between two points on the random walk link is used as the spatial distance between the first node and the corresponding target node.
[0089] Through this embodiment, in a dynamic graph data set, a multi-hop neighbor subgraph structure corresponding to each target node at a preset moment is obtained, and in a sampling node set corresponding to the target node, the number of hops between the target node and each second node in the multi-hop neighbor subgraph structure is determined, and the minimum number of hops is used as the spatial distance between the first node and the target node, thereby realizing accurate calculation of the spatial distance of the nodes.
[0090] In some embodiments, determining the time distance between each first node in the sampling node set and the target node in step S221 includes the following steps:
[0091] Obtaining the interaction time series between each first node and the target node before a preset time;
[0092] Based on the interaction time series, a temporal distance between the first node and the target node is determined.
[0093] Specifically, for each first node in the sampling node set, the interaction time series t={t 1 ,t 2 ,…,t n}, and based on the interaction time series, calculate the time distance between the first node and the target node. In this embodiment, different time series point processes can be used to calculate the time distance between the first node and the target node. For example, based on the pine-cypress point process hypothesis, the interaction strength between the nodes is estimated to obtain the time distance, or based on the Hawkes process hypothesis, according to the historical interaction time series between the two points, the maximum likelihood is used to estimate the interaction strength between the nodes at a preset time to obtain the time distance, etc.
[0094] For example, based on the pine-cypress point process hypothesis, the interaction intensity between nodes is estimated to obtain the time distance. The specific calculation formula is as follows:
[0095]
[0096] Among them, TD(w,w 0 ,t pred ) represents the first node w and the target node w 0 At time t pred ; α and β are hyperparameters, and both α and β are greater than 0.
[0097] It should be noted that if Figure 4 As shown, the sampling node set corresponding to each target node includes multiple first nodes w i , this embodiment calculates the time distance between each first node and the corresponding target node.
[0098] Through this embodiment, the interaction time sequence between each first node and the target node before the preset time is obtained, and the time distance corresponding to the first node is determined based on the interaction time sequence, so as to accurately calculate the time distance between the nodes.
[0099] In some embodiments, determining the node representation matrix corresponding to the sampling node set based on the spatiotemporal coding of each first node in step S223 includes the following steps:
[0100] Get the original node attributes of each first node;
[0101] splicing the original node attribute of each first node with the spatiotemporal encoding to obtain a node representation of the first node;
[0102] Based on the node representations of each first node, a node representation matrix corresponding to the sampling node set is constructed.
[0103] Specifically, for each sampling node set, the original node attributes of each first node in the set are obtained, that is, the characteristic information of the first node in the continuous-time dynamic graph, including the node type, attribute value, and state change, etc. The original node attributes of each first node are spliced with its spatiotemporal coding to obtain the node representation of the first node, and based on the node representation of each first node, a node representation matrix corresponding to the current sampling node set is constructed.
[0104] It should be noted that each sampling node set corresponds to a node representation matrix, each node representation matrix is used as the input of the target detection model, and the specific expression of each node representation matrix is as follows:
[0105]
[0106] Among them, X is the node representation matrix; w 1 ,w 2 ,…,w C represents the first nodes in the sampling node set; x(w 1 ),x(w 2 ),…,x(w C ) represents the node representation of each first node.
[0107] Through this embodiment, the original node attributes of each first node are obtained, and the original node attributes of each first node are spliced with the spatiotemporal coding to obtain the node representation of the first node, and based on the node representation of each first node, a node representation matrix corresponding to the sampling node set is constructed to achieve effective and accurate node representation, and obtain the input of the target detection model to facilitate the subsequent node interaction prediction.
[0108] In some of the embodiments, the calculation formula of the spatiotemporal coding of the first node is:
[0109] STPE u (w;u,t pred )=MLP(Enc(TD(w,u,t pred )))||MLP(Enc(SD(w,u,t pred )));
[0110] Among them, STPE u (w;u,t pred ) is the first node w with respect to the target node u at time t pred spatiotemporal coding; MLP represents multi-layer perceptron; Enc is the preset encoding function; || is the concatenation operation; TD(w,u,t pred ) is the first node w and the target node u at time t pred The time distance; SD(w,u,t pred) is the first node w and the target node u at time t pred spatial distance.
[0111] Specifically, for each first node w in the sampling node set, the spatial distance SD(w,u,t pred ) and time distance TD(w,u,t pred ), and based on the preset encoding function, the spatial distance SD(w,u,t pred ) and time distance TD(w,u,t pred ) is encoded to obtain the first node with respect to the corresponding target node at time t pred Space-time encoding STPE u (w;u,t pred ).
[0112] Among them, the interaction strength between nodes can be estimated based on the pine-cypress point process hypothesis to obtain the time distance, or based on the Hawkes process hypothesis, the interaction strength between nodes at a preset time can be estimated by maximum likelihood according to the historical interaction time series between two points to obtain the time distance. When calculating the spatial distance, the time t can be obtained in advance. pred The multi-hop neighbor subgraph structure corresponding to the target node is obtained, and the number of hops between the target node and each first node in the multi-hop neighbor subgraph structure is used to calculate the time between the first node and the target node. pred The spatial distance between each first node and the target node is determined by using a random walk method.
[0113] Through this embodiment, based on the preset coding function, the spatial distance and temporal distance corresponding to each first node are encoded and processed to obtain the spatiotemporal coding of the first node with respect to the corresponding target node, thereby fully considering the spatiotemporal characteristics between the nodes, facilitating the subsequent use of the spatiotemporal coding of the context node with respect to the correlation of each target node, and realizing effective and accurate node representation.
[0114] In some embodiments, obtaining a set of sampling nodes corresponding to each target node in a target node pair at a preset time in the dynamic graph data set in step S210 includes the following steps:
[0115] Step S211, based on each target node in the target node pair at a preset time, context node sampling is performed on the dynamic graph data set to obtain a sampling node set corresponding to each target node.
[0116] Specifically, based on the target node pairs at the preset time, the context node sampling based on the tree is performed on the dynamic graph dataset to obtain the sampling node set corresponding to each target node in the target node pair. The node sampling process usually includes multiple rounds of iterations. In the first round of iteration, n 1 One-hop historical neighbors are added to the sampling node set, and in the kth iteration, n nodes sampled in each k-1 round are sampled. k One-hop historical neighbors are added to the sampling node set, where n 1 ,n 1 ,…,n k is a hyperparameter.
[0117] For example, for the preset time t pred The target node pair (u, v) is selected, and the context nodes of node u and node v are sampled based on the tree, and the first sampling node set C(u, t pred ), and the second sampling node set C(v, t pred ).like Figure 5 As shown, nodes w1, w2 and w4 are context nodes of target node u, and nodes w2, w3 and w5 are context nodes of target node v.
[0118] Through this embodiment, based on each target node in the target node pair at a preset moment, context node sampling is performed on the dynamic graph data set, and the historical neighbors with which the nodes have interacted in the continuous-time dynamic graph are sampled as the context nodes of the target node, so as to obtain the sampling node set corresponding to each target node.
[0119] In some of the embodiments, the target prediction model includes an input layer, an intermediate layer, and an output layer; wherein,
[0120] An input layer, used to receive the node representation matrix corresponding to each sampling node set;
[0121] The middle layer is used to process the representation matrix of each node based on the self-attention matrix and feedforward neural network;
[0122] The output layer is used to perform a pooling operation on the last layer representation of each first node in the processing result, and based on the pooling result, determine the interaction prediction result of the target node in the target node pair at a preset time.
[0123] Specifically, the target prediction model is used to predict the interaction probability of the target node in the target node pair at a preset time, and the model includes an input layer, an intermediate layer and an output layer. This embodiment does not limit the loss function used to train the target prediction model, and the preferred loss function is the binary cross entropy loss.
[0124] Among them, Figure 6As shown in the figure, the input layer is used to receive the node representation matrix corresponding to each target node; the middle layer is used to process each node representation matrix based on the self-attention matrix and the feedforward neural network; and the output layer is used to average pool the last layer representation of each first node in the processing result to obtain the pooling result. H (l) (i,:) represents all elements in the i-th row of the matrix, and based on the pooling result, the interactive prediction result of the target node in the target node pair at the preset time is determined, and the calculation expression is as follows:
[0125] S(u,v,t pred )=σ(MLP(z(u,t pred ),z(v,t pred )));
[0126] Among them, S(u,v,t pred ) represents the target node pair (u,v) at the preset time t pred The interaction probability; σ represents the Sigmoid function; MLP represents the multi-layer perceptron; z(u,t pred ) and z(v,t pred ) represent the pooling results corresponding to the node representation of node u and the pooling results corresponding to the node representation of node v respectively.
[0127] It should be noted that the node representation matrix X of the input model is denoted as H (0) , then in the middle layer of the target prediction model, the event attributes and temporal relationships are used as biases and masks to obtain the improved self-attention matrix CorDGTAttn. The specific definition of the self-attention matrix is as follows:
[0128]
[0129] in, Indicates H (l) The i-th row of the matrix; W Q , W K , W EK and W EV represents the learnable parameters, Scaling factor; M∈R C×C represents the mask matrix and is defined as E=[e ij ] 1≤i,j≤C Represents the event attribute matrix of the dynamic graph dataset; Softmax() is a normalized exponential function.
[0130] Based on the above improved self-attention matrix, the intermediate layer of the target prediction model is defined as follows:
[0131] H' (l)=CorDGTAttn(LN(H (l-1) ),E)+H (l-1) ;
[0132] H (l) =FFN(LN(H' (l) ))+H' (l) ;
[0133] Where CorDGTAttn represents the self-attention matrix; FFN represents the feedforward neural network; LN represents layer normalization; E = [e ij ] 1≤i,j≤C Represents the event attribute matrix of the dynamic graph dataset.
[0134] Through this embodiment, a target prediction model is constructed to predict the interaction probability of a target node in a target node pair at a preset time, thereby achieving accurate prediction of the node interaction probability.
[0135] The present embodiment is described and illustrated below through preferred embodiments.
[0136] Figure 7 is a flowchart of the node interaction prediction method of this preferred embodiment, such as Figure 7 As shown, the prediction method of the node interaction includes the following steps:
[0137] Step S710, based on each target node in the target node pair at a preset time, context node sampling is performed on the dynamic graph data set to obtain a sampling node set corresponding to each target node;
[0138] Step S720, respectively determining the spatial distance and the temporal distance between each first node in the sampling node set and the target node;
[0139] Step S730, encoding the spatial distance and temporal distance corresponding to each first node based on a preset encoding function to obtain the spatiotemporal encoding of the first node with respect to the corresponding target node;
[0140] Step S740, concatenating the original node attribute of each first node with the spatiotemporal code to obtain a node representation of the first node;
[0141] Step S750, constructing a node representation matrix corresponding to the sampling node set based on the node representation of each first node;
[0142] Step S760, processing each node representation matrix through a pre-built target prediction model to obtain an interactive prediction result of a target node in a target node pair at a preset time.
[0143] Through this embodiment, based on each target node in the target node pair at a preset time, context node sampling is performed on the dynamic graph data set to obtain a sampling node set corresponding to each target node. The spatial distance and time distance between each first node and the target node in the sampling node set are determined respectively, and based on a preset encoding function, the spatial distance and time distance corresponding to each first node are encoded to obtain the spatiotemporal encoding of the first node with respect to the corresponding target node, and the original node attributes of each first node are spliced with the spatiotemporal encoding to obtain the node representation of the first node, and the spatiotemporal encoding of the relevance of the context node with respect to each target node is used to achieve effective and accurate node representation.
[0144] Furthermore, based on the node representation of each first node, a node representation matrix corresponding to the sampling node set is constructed. Through the pre-constructed target prediction model, each node representation matrix is processed to obtain the interactive prediction result of the target node in the target node pair at the preset time. This solves the problem of inaccurate prediction results caused by not considering the spatiotemporal characteristics between nodes, realizes the prediction analysis based on the spatiotemporal characteristics between nodes, and improves the accuracy of the prediction results.
[0145] It should be noted that the steps shown in the above process or the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0146] In this embodiment, a prediction device for node interaction is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and will not be repeated hereafter. The terms "module", "unit", "subunit", etc. used below can implement a combination of software and / or hardware for a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0147] Figure 8 is a structural block diagram of the node interaction prediction device of this embodiment, such as Figure 8 As shown, the device includes: a sampling module 10, an encoding module 20 and a prediction module 30;
[0148] The sampling module 10 is used to obtain, in the dynamic graph data set, a set of sampling nodes corresponding to each target node in the target node pair at a preset time;
[0149] The coding module 20 is used to determine the node representation matrix corresponding to the sampling node set based on the spatiotemporal coding of each first node in each sampling node set; wherein the spatiotemporal coding of each first node is correlated with each other;
[0150] The prediction module 30 is used to process each node representation matrix through a pre-built target prediction model to obtain an interactive prediction result of a target node in a target node pair at a preset time.
[0151] Through the device provided by this embodiment, in a dynamic graph data set, a sampling node set corresponding to each target node in a target node pair at a preset time is obtained; based on the spatiotemporal coding of each first node in each sampling node set, a node representation matrix corresponding to the sampling node set is determined, wherein the spatiotemporal coding of each first node is correlated; further, through a pre-constructed target prediction model, each node representation matrix is processed to obtain an interactive prediction result of the target node in the target node pair at the preset time, thereby solving the problem of inaccurate prediction results caused by not considering the spatiotemporal characteristics between nodes, and realizing prediction analysis combined with the spatiotemporal characteristics between nodes, thereby improving the accuracy of prediction results.
[0152] In some of the embodiments, the encoding module 20 is also used to respectively determine the spatial distance and temporal distance between each first node in the sampling node set and the target node; based on a preset encoding function, the spatial distance and temporal distance corresponding to each first node are encoded to obtain the spatiotemporal encoding of the first node with respect to the corresponding target node; based on the spatiotemporal encoding of each first node, the node representation matrix corresponding to the sampling node set is determined.
[0153] In some of the embodiments, the encoding module 20 is also used to obtain a multi-hop neighbor subgraph structure corresponding to each target node at a preset moment in a dynamic graph data set; determine the number of hops between the target node and each first node in the multi-hop neighbor subgraph structure; and use the minimum number of hops as the spatial distance between the first node and the target node.
[0154] In some of the embodiments, the encoding module 20 is further used to obtain an interaction time sequence between each first node and the target node before a preset time; and determine a time distance between the first node and the target node based on the interaction time sequence.
[0155] In some of the embodiments, the encoding module 20 is also used to obtain the original node attributes of each first node; splice the original node attributes of each first node with the spatiotemporal coding to obtain the node representation of the first node; and construct a node representation matrix corresponding to the sampling node set based on the node representation of each first node.
[0156] In some of the embodiments, the sampling module 10 is further used to perform context node sampling on the dynamic graph data set based on each target node in the target node pair at a preset moment to obtain a sampling node set corresponding to each target node.
[0157] It should be noted that the above modules can be functional modules or program modules, and can be implemented by software or hardware. For modules implemented by hardware, the above modules can be located in the same processor; or the above modules can be located in different processors in any combination.
[0158] In this embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0159] Optionally, the computer device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.
[0160] Optionally, in this embodiment, the processor may be configured to perform the following steps through a computer program:
[0161] S1, in the dynamic graph data set, obtain the sampling node set corresponding to each target node in the target node pair at a preset time;
[0162] S2, based on the spatiotemporal coding of each first node in each sampling node set, determining a node representation matrix corresponding to the sampling node set; wherein the spatiotemporal coding of each first node is correlated with each other;
[0163] S3, through the pre-built target prediction model, the representation matrix of each node is processed to obtain the interactive prediction result of the target node in the target node pair at the preset time.
[0164] It should be noted that the specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementation modes, and will not be repeated in this embodiment.
[0165] In addition, in combination with the node interaction prediction method provided in the above embodiments, a storage medium may be provided in this embodiment to implement the method. The storage medium stores a computer program; when the computer program is executed by a processor, any node interaction prediction method in the above embodiments is implemented.
[0166] It should be understood that the specific embodiments described herein are only used to explain the application, rather than to limit it. Based on the embodiments provided in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the protection scope of this application.
[0167] Obviously, the drawings are only some examples or embodiments of the present application. For ordinary technicians in the field, the present application can also be applied to other similar situations based on these drawings without creative work. In addition, it is understandable that although the work done in this development process may be complicated and lengthy, for ordinary technicians in the field, certain changes in design, manufacturing or production based on the technical content disclosed in this application are only conventional technical means and should not be regarded as insufficient content disclosed in this application.
[0168] The term "embodiment" in this application refers to a specific feature, structure or characteristic described in conjunction with the embodiment that can be included in at least one embodiment of the present application. The appearance of this phrase in various locations in the specification does not necessarily mean the same embodiment, nor does it mean that it is mutually exclusive with other embodiments and is independent or optional. It is clearly or implicitly understood by those of ordinary skill in the art that the embodiments described in this application can be combined with other embodiments without conflict.
[0169] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of patent protection. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the scope of protection of the present application. Therefore, the scope of protection of the present application shall be subject to the attached claims.
Claims
1. A method for predicting node interaction, characterized in that: The method comprises: In the dynamic graph data set, obtain the sampling node set corresponding to each target node in the target node pair at a preset time; Based on the spatiotemporal coding of each first node in each of the sampling node sets, determining a node representation matrix corresponding to the sampling node set; wherein the spatiotemporal coding of each of the first nodes is correlated; Each of the node representation matrices is processed by a pre-constructed target prediction model to obtain an interactive prediction result of the target node in the target node pair at the preset time.
2. The node interaction prediction method according to claim 1, characterized in that: The determining, based on the spatiotemporal coding of each first node in each of the sampling node sets, a node representation matrix corresponding to the sampling node set comprises: Respectively determine the spatial distance and the temporal distance between each of the first nodes in the sampling node set and the target node; Based on a preset coding function, the spatial distance and the temporal distance corresponding to each of the first nodes are coded to obtain the spatiotemporal coding of the first node with respect to the corresponding target node; Based on the spatiotemporal coding of each of the first nodes, a node representation matrix corresponding to the sampling node set is determined.
3. The node interaction prediction method according to claim 2, characterized in that: The determining the spatial distance between each of the first nodes in the sampling node set and the target node comprises: In the dynamic graph data set, obtaining a multi-hop neighbor subgraph structure corresponding to each of the target nodes at the preset time; Determine the number of hops between the target node and each first node in the multi-hop neighbor subgraph structure; The minimum number of hops is used as the spatial distance between the first node and the target node.
4. The node interaction prediction method according to claim 2, characterized in that: Determining the time distance between each of the first nodes in the sampling node set and the target node includes: Acquire an interaction time sequence between each of the first nodes and the target node before the preset time; Based on the interaction time series, a time distance between the first node and the target node is determined.
5. The node interaction prediction method according to claim 2, characterized in that: The determining, based on the spatiotemporal coding of each of the first nodes, a node representation matrix corresponding to the sampling node set includes: Obtaining the original node attribute of each of the first nodes; splicing the original node attribute of each first node with the spatiotemporal code to obtain a node representation of the first node; Based on the node representations of each of the first nodes, a node representation matrix corresponding to the sampling node set is constructed.
6. The node interaction prediction method according to claim 1, characterized in that: The calculation formula of the space-time coding of the first node is: STPE u (w;u,t pred )=MLP(Enc(TD(w,u,t pred )))||MLP(Enc(SD(w,u,t pred ))); Among them, STPE u (w;u,t pred ) is the first node w with respect to the target node u at time t pred spatiotemporal coding; MLP is a multi-layer perceptron; Enc is a preset encoding function; || is a concatenation operation; TD(w,u,t pred ) is the first node w and the target node u at time t pred The time distance; SD(w,u,t pred ) is the first node w and the target node u at time t pred spatial distance.
7. The node interaction prediction method according to claim 1, characterized in that: The step of obtaining, in the dynamic graph data set, a set of sampling nodes corresponding to each target node in a target node pair at a preset time comprises: Based on each target node in the target node pair at a preset time, context node sampling is performed on the dynamic graph data set to obtain the sampling node set corresponding to each target node.
8. The node interaction prediction method according to claim 1, characterized in that: The target prediction model includes an input layer, an intermediate layer and an output layer; wherein, The input layer is used to receive the node representation matrix corresponding to each of the sampling node sets; The intermediate layer is used to process each node representation matrix based on the self-attention matrix and the feedforward neural network; The output layer is used to perform a pooling operation on the last layer representation of each of the first nodes in the processing results, and determine the interaction prediction result of the target node in the target node pair at the preset time based on the pooling result.
9. A node interaction prediction device, characterized in that: The device comprises: a sampling module, a coding module and a prediction module; The sampling module is used to obtain a sampling node set corresponding to each target node in a target node pair at a preset time in the dynamic graph data set; The encoding module is used to determine the node representation matrix corresponding to the sampling node set based on the spatiotemporal encoding of each first node in each of the sampling node sets; wherein the spatiotemporal encodings of each of the first nodes are correlated; The prediction module is used to process each of the node representation matrices through a pre-constructed target prediction model to obtain an interaction prediction result of the target node in the target node pair at the preset time.
10. A computer device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps of the node interaction prediction method according to any one of claims 1 to 8.
11. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the node interaction prediction method according to any one of claims 1 to 8 are implemented.
