Red date market link relation prediction method and system based on multi-head attention
By using a multi-head attention model and a GNN model to calculate the potential link relationships in the jujube market, the problem of predicting local structures and multiple objects in traditional methods is solved. This enables dynamic and accurate prediction of link relationships in the jujube market, improving the accuracy and robustness of the prediction.
Patent Information
- Application Number
- CN202311845798.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-28
- Publication Date
- 2026-05-01
AI Technical Summary
Traditional link prediction methods struggle to capture the local structure and complex relationships of nodes in the jujube sales market, making it difficult to accurately predict connections between multiple objects. Furthermore, the incompleteness of graph data leads to insufficient prediction robustness and generalization ability.
A multi-head attention model and graph neural network (GNN) are used to compute the predicted structure and node representation. Feature matrices and adjacency matrices are constructed through local subgraphs to dynamically predict potential link relationships. The prediction accuracy is improved by utilizing the multi-head attention mechanism and GNN model.
It enables dynamic and accurate prediction of potential link relationships in the jujube market, improves the accuracy and robustness of link prediction, adapts to complex relationship patterns, and is suitable for multiple objects and incomplete data.
Smart Images

Figure CN121961639A_ABST
Abstract
Description
A method and system for predicting market link relationships in jujubes based on multi-head attention Technical Field
[0001] This invention relates to the field of graph data processing technology, and in particular to a method and system for predicting the link relationships in the jujube market based on multi-head attention. Background Technology
[0002] With the expansion of the jujube industry and the increase in the number of employees, its problems have become increasingly prominent, such as the lack of single sales channels and information asymmetry in the supply and demand market, resulting in increased production costs and decreased income for jujube farmers. Link prediction is a crucial issue in the jujube sales market. The goal of link prediction is to use existing market data to predict and discover valuable potential sales channels. Traditional link prediction methods often rely on predefined feature engineering and algorithm models, which are difficult to capture the potential patterns and relationships in the complex jujube sales market. Traditional methods usually require manual definition and feature extraction, which may lead to information loss or an inability to fully express the complex relationships between nodes. Feature engineering often relies on domain knowledge and experience, and for complex graph structures and large-scale datasets, manually defined features often fail to capture hidden patterns and relationships. Furthermore, traditional methods often treat link prediction as a global problem, ignoring the local structure and contextual information of nodes in the graph. However, the neighbor relationships and subgraph structure of nodes have a significant impact on link prediction, and traditional methods often fail to effectively capture this local structural information, making it difficult to accurately predict the connections between nodes. For the complex jujube sales market, it is difficult to capture the potential patterns and relationships. Meanwhile, jujube sales market data often takes the form of a graph structure, exhibiting characteristics of multiple objects and attributes, with multiple links and dynamic changes between market entities. Jujube data contains various objects, such as suppliers, distributors, and retailers. Traditional link prediction methods typically assume only a single type of node, making it difficult to handle connection predictions between multiple objects. This may lead to the model failing to accurately capture the relationships and interactions between different objects. Furthermore, traditional link prediction methods often rely on node attribute features for similarity calculations. Due to the multiple attributes, traditional methods may not fully utilize these attributes, resulting in missing information. Therefore, to overcome the limitations of traditional methods, introducing Graph Neural Network (GNN) technology into the jujube sales market for link prediction is of great significance.
[0003] Traditional link prediction methods typically assume that graph data is fully observed, meaning that the information about known nodes and edges is complete. However, in real-world applications, graph data is often incomplete, containing missing nodes and edges. Graph Neural Networks (GNNs) can effectively handle incomplete and missing data by learning representations of nodes and edges to fill in the missing information, thereby improving the robustness and generalization ability of link prediction. Furthermore, GNNs can adapt to complex relationship patterns. Relationships in graph data often exhibit complex patterns and dependencies, which traditional link prediction methods often struggle to capture. GNNs, through multi-layered information transmission and aggregation, can learn higher-order and more complex relationship patterns, extracting richer feature representations and thus improving the accuracy of link prediction. Therefore, introducing Graph Neural Network (GNN) technology into the jujube sales market for link prediction is of great significance in overcoming the limitations of traditional methods.
[0004] In summary, there is an urgent need in this field for a highly accurate method and system for predicting the red date supply chain in order to quickly and accurately identify potential red date market channels. Summary of the Invention
[0005] The purpose of this invention is to provide a method and system for predicting link relationships in the jujube market based on multi-head attention. This invention calculates the predicted structure representation Z and the predicted node representation H using a multi-head attention model and a GNN model, respectively, and determines whether there is a potential link relationship between the nodes based on the predicted similarity score between the nodes. This achieves dynamic prediction of potential link relationships in the jujube market and improves the accuracy of the prediction.
[0006] To achieve the above objectives, the present invention provides the following solution:
[0007] A method for predicting market link relationships in jujubes based on multi-head attention, characterized in that the prediction method includes:
[0008] A local subgraph is constructed based on the acquired jujube market data; the local subgraph is composed of the target link node D relationship, the target link node D includes: source node i, target node j and neighbor nodes;
[0009] Construct the feature matrix M and adjacency matrix A based on the local subgraph;
[0010] The adjacency matrix A is used to calculate the predicted structural representation Z through a multi-head attention model, and the predicted node representation H is calculated based on the feature matrix M and the adjacency matrix A through a GNN model.
[0011] The predicted similarity score is calculated based on the predicted structural representation Z and the predicted node representation H to determine whether there is a potential link relationship between the source node i and the target node j.
[0012] Determine if the predicted similarity score is greater than the preset value. If the similarity is greater than the preset value, the output prediction result is that the source node i and the target node j have a potential link relationship. Otherwise, the output prediction result is that the source node i and the target node j do not have a potential link relationship.
[0013] Optionally, a local subplot can be constructed based on the acquired jujube market data, specifically including:
[0014] The acquired jujube market data is organized into tabular data, converted into heterogeneous graph data, and the data nodes of the heterogeneous graph data are mapped to data nodes in the same feature space. The data nodes in the same feature space are extracted to obtain a local subgraph composed of the relationship between the target link nodes D.
[0015] Optionally, a feature matrix M and an adjacency matrix A are constructed based on the local subgraph, specifically including:
[0016] A feature matrix M is constructed based on the attributes of each node in the local subgraph; the nodes in the local subgraph are labeled to obtain the node index labels, and an adjacency matrix A is constructed based on the index labels of each node in the local subgraph.
[0017] Optionally, node labeling can be performed on the local subgraph to obtain node index labels, specifically including:
[0018] Mark the source node i in the target link node D of the local subgraph as 0, the target node j as 1, and the neighbor nodes as 2, to obtain the index marking of each node.
[0019] A string marker is constructed based on the index marker of each node and the index markers of all adjacent connectable nodes of that node; the string marker is a marker in ascending order of the index markers of adjacent connectable nodes;
[0020] Sort all nodes by their index labels in ascending order. When nodes have the same index label, sort them by their string labels in ascending order. When nodes have the same string labels, assign the same index label to nodes that have the same index label and string label.
[0021] Re-execute "Construct a string marker based on the sequence number of each node and the sequence numbers of all adjacent connectable nodes of that node; the string marker is a marker in ascending order of the sequence numbers of adjacent connectable nodes;
[0022] Sort all node indexes in ascending order. When nodes have the same index, sort them in ascending order by their string labels. When nodes also have the same string labels, assign the same index to nodes with the same index and string labels. Continue until no nodes have the same index but different string labels. Then, reorder all node indexes in ascending order. For nodes with the same index and string labels, random ascending order can be used to obtain the node indexes.
[0023] Optionally, the adjacency matrix A is used to calculate the predicted structural representation Z through a multi-head attention model, specifically including:
[0024] The adjacency matrix A is input into a multi-head attention model to obtain the structural feature vector X. The structural feature vector X is then diagonalized to obtain the structural feature matrix X. S , the structural feature matrix X S Multiplying the adjacency matrix A yields the structural representation Z.
[0025] Optionally, the adjacency matrix A is input into the structural feature vector X obtained by incorporating a multi-head attention model, specifically including:
[0026] The adjacency matrix A is input into the multi-head attention model to obtain the node feature representation. Based on node feature representation Obtain edge feature representation Based on node feature representation Sum and edge feature representation Construct the structural feature vector X;
[0027] The calculation formula for the node feature representation is as follows:
[0028]
[0029] in, Let i be the node feature representation of source node i at layer t. Let j be the node feature representation of the target node at layer t-1. This represents the weight matrix of the k-th head in layer t, where k is the number of heads. This represents the k-th head attention coefficient between source node i and target node j;
[0030] The calculation formula for the edge feature representation is as follows:
[0031]
[0032] The formula for calculating the structural feature vector X is:
[0033]
[0034] Optionally, the prediction structure represents the calculation formula for Z as follows:
[0035] Z = AX S ;
[0036] The formula for calculating the prediction node H is as follows:
[0037]
[0038] Where M is the characteristic matrix, W represents the normalized adjacency matrix. GNN These are the parameters of the GNN.
[0039] Optionally, the formula for calculating the predicted similarity score of the potential link relationship between the source node i and the target node j is as follows:
[0040]
[0041] Let α represent the predicted similarity score indicating a potential link relationship between source node i and target node j, where α is a trainable parameter, σ(*) represents the activation function, s(*) represents the similarity metric function based on node attributes, and z... i Let Z, z be the predicted structure representation of the source node. j Let Z and h be the predicted structure representation of target node j. i Let H be the predicted node representation of source node i, h j Let H be the predicted node representation of the target node j.
[0042] Optionally, before calculating the predicted structural representation Z from the adjacency matrix A using a multi-head attention model, and calculating the predicted node representation H from the feature matrix M and the adjacency matrix A using a GNN model, the prediction method further includes: training the multi-head attention model and the GNN model with the goal of minimizing the multi-class cross-entropy loss function;
[0043] The formula for calculating the multi-class cross-entropy loss function is as follows:
[0044]
[0045] Where BCE(*) represents the binary cross-entropy loss function; λ1, λ2, and λ3 are adjustable hyperparameters used to control the weights of different loss terms; y ij This represents the actual observation value indicating a potential link relationship between source node i and target node j.
[0046] A jujube market link relationship prediction system based on multi-head attention, the prediction system comprising:
[0047] The data processing module is used to construct a local subgraph based on the acquired jujube market data; the local subgraph is composed of the target link node D relationship, and the target link node D includes: source node i, target node j and neighbor nodes;
[0048] The matrix construction module is used to construct the feature matrix M and the adjacency matrix A based on the local subgraph;
[0049] The prediction structure representation building module is used to calculate the prediction structure representation Z from the adjacency matrix A through a multi-head attention model, and to calculate the prediction node representation H based on the feature matrix M and the adjacency matrix A through a GNN model;
[0050] The similarity calculation module calculates the predicted similarity score between source node i and target node j based on the predicted structure representation Z and the predicted node representation H, indicating a potential link relationship.
[0051] The judgment module determines whether the predicted similarity score is greater than a set value. If the similarity is greater than the preset value, the output prediction result is that the source node i and the target node j have a potential link relationship; otherwise, the output prediction result is that the source node i and the target node j do not have a potential link relationship.
[0052] According to specific embodiments provided by the present invention, the present invention discloses the following technical effects:
[0053] This invention constructs a feature matrix M and an adjacency matrix A from a local subgraph obtained from acquired jujube market data. The adjacency matrix A is then used to calculate a predicted structural representation Z using a multi-head attention model. Based on the feature matrix M and adjacency matrix A, a predicted node representation H is calculated using a GNN model. Based on the predicted structural representation Z and predicted node representation H, a predicted similarity score is calculated indicating a potential link relationship between source node i and target node j. This determines whether a potential link relationship exists between source node i and target node j, enabling dynamic prediction of potential link relationships in the jujube market and improving prediction accuracy. Attached Figure Description
[0054] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0055] Figure 1 is a flowchart of a method for predicting the link relationship in the jujube market based on multi-head attention, provided by an embodiment of the present invention;
[0056] Figure 2 is a partial flowchart of a method for predicting the link relationship in the jujube market based on multi-head attention, provided in an embodiment of the present invention.
[0057] Figure 3 is a structural diagram of a jujube market link relationship prediction system based on multi-head attention provided in an embodiment of the present invention;
[0058] Figure 4 is a node marking diagram provided in an embodiment of the present invention;
[0059] Figure 5 is a schematic diagram of the internal structure of the structural feature generator provided in an embodiment of the present invention;
[0060] Figure 6 is a schematic diagram of the multi-head attention model structure provided in an embodiment of the present invention. Detailed Implementation
[0061] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0062] The purpose of this invention is to provide a method and system for predicting link relationships in the jujube market based on multi-head attention. The method calculates the predicted structure representation Z and the predicted node representation H using a multi-head attention model and a GNN model, respectively, and determines whether there is a potential link relationship between the nodes based on the predicted similarity score between the nodes. This enables dynamic prediction of potential link relationships in the jujube market and improves the accuracy of the prediction.
[0063] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0064] Example 1
[0065] As shown in Figures 1 and 2, this invention provides a method for predicting the market chain relationship of jujubes based on multi-head attention. The prediction method includes:
[0066] S1. Construct a local subgraph based on the acquired jujube market data; the local subgraph consists of target link node D relationships, where target link node D includes: source node i, target node j, and neighbor nodes. The jujube market data includes, but is not limited to, the object and relationship attributes of suppliers, distributors, and retailers.
[0067] During the extraction of the local subgraph, the predicted node information and parameter φ are input to initialize an empty local subgraph. First-order neighbor nodes of the target link node are added to the local subgraph. If the number of neighbors is less than parameter φ, higher-order neighbor nodes of the target link are added in sequence. If the number is still less than φ after all nodes have been added, virtual nodes are added to make up the number. If the number of neighbor nodes is greater than parameter φ, higher-order neighbor nodes are deleted first, and nodes closer to the target node j are retained. The resulting local subgraph composed of the neighbors around the target link node contains φ nodes.
[0068] As an optional implementation, step S1 specifically includes:
[0069] S11. Organize the acquired jujube market data into tabular data, convert the tabular data into heterogeneous graph data, map the data nodes of the heterogeneous graph data to data nodes in the same feature space, extract the data nodes in the same feature space, and obtain a local subgraph composed of the target link node D relationship.
[0070] S2. Construct the feature matrix M and adjacency matrix A based on the local subgraph.
[0071] Optionally, step S2 specifically includes:
[0072] S21. Construct a feature matrix M based on the attributes of each node in the local subgraph; label the nodes in the local subgraph to obtain the node index labels, and construct an adjacency matrix A based on the index labels of each node in the local subgraph.
[0073] Optionally, as shown in Figure 4, step S2 involves labeling the nodes of the local subgraph to obtain the node index labels, specifically including:
[0074] Mark the source node i in the target link node D of the local subgraph as 0, the target node j as 1, and the neighbor nodes as 2, to obtain the index marking of each node.
[0075] A string marker is constructed based on the sequence number of each node and the sequence numbers of all adjacent connectable nodes of that node; the string marker is a marker in ascending order of the sequence numbers of adjacent connectable nodes.
[0076] Sort all node indexes in ascending order. When nodes have the same index, sort them in ascending order by their string labels. When nodes also have the same string labels, assign the same index to nodes that have the same index and string labels.
[0077] Re-execute "Construct a string marker based on the sequence number of each node and the sequence numbers of all adjacent connectable nodes of that node; the string marker is a marker in ascending order of the sequence numbers of adjacent connectable nodes".
[0078] Sort all node indexes in ascending order. When nodes have the same index, sort them in ascending order by their string labels. When nodes also have the same string labels, assign the same index to nodes with the same index and string labels. Continue until no nodes have the same index but different string labels. Then, reorder all node indexes in ascending order. For nodes with the same index and string labels, random ascending order can be used to obtain the node indexes.
[0079] S3. Calculate the predicted structure representation Z from the adjacency matrix A using a multi-head attention model, and calculate the predicted node representation H from the feature matrix M and the adjacency matrix A using a GNN model.
[0080] Optionally, in step S3, node labeling is performed on the local subgraph to obtain node index labels. The adjacency matrix A is then used to calculate the predicted structural representation Z through a multi-head attention model. Specifically, this includes: inputting the adjacency matrix A into the structural feature vector X obtained by incorporating the multi-head attention model, and diagonalizing the structural feature vector X to obtain the structural feature matrix X. S , the structural feature matrix X S Multiplying the structure by the adjacency matrix A yields the structural representation Z. Here, the structural characteristic matrix X... S Multiplying the adjacency matrix A with the adjacency matrix A can aggregate neighborhood features.
[0081] Optionally, the adjacency matrix A is input into the structural feature vector X obtained by incorporating a multi-head attention model, specifically including:
[0082] The adjacency matrix A is input into the multi-head attention model to obtain the node feature representation. Based on node feature representation Obtain edge feature representation Based on node feature representation Sum and edge feature representation Construct the structural feature vector X.
[0083] As shown in Figures 5 and 6, the multi-head attention model includes a structural feature generator, which comprises two multilayer perceptrons for nodes and edges, respectively. and Used to generate structural feature vectors X. The structural feature generator can generate various structural features that match the heuristic method, when... At that time, the structural feature generator can generate the same structural features as the AdamicAdar method. A multi-head attention mechanism is incorporated, using different features as different heads to generate different node representation vectors. Each head learns a different weight matrix, thus performing attention calculations on different features. By changing the parameter weights, the desired feature fusion vector representation can be obtained.
[0084] The calculation formula for the node feature representation is as follows:
[0085]
[0086] in, Let i be the node feature representation of source node i at layer t. Let j be the node feature representation of the target node at layer t-1. This represents the weight matrix of the k-th head in layer t, where k is the number of heads. This represents the k-th head attention coefficient between source node i and target node j.
[0087] Optional, The calculation method is as follows:
[0088]
[0089] Where a k Let be the attention vector of the k-th head, and || denote the vector concatenation operation. Let i be the node feature representation of the target node i at layer t-1.
[0090] The calculation formula for the edge feature representation is as follows:
[0091]
[0092] The formula for calculating the structural feature vector X is:
[0093]
[0094] As an optional implementation, the prediction structure represents the calculation formula for Z as follows:
[0095] Z = AX S .
[0096] in, The structural feature matrix is formed by diagonalizing the structural vectors, with the structural vectors x on the diagonal. [i] All other positions are 0.
[0097] The formula for calculating the prediction node H is as follows:
[0098]
[0099] Where M is the characteristic matrix, W represents the normalized adjacency matrix. GNN These are the parameters of the GNN.
[0100] S4. Calculate the predicted similarity score based on the predicted structure representation Z and the predicted node representation H to determine if there is a potential link relationship between the source node i and the target node j.
[0101] Optionally, the formula for calculating the predicted similarity score of the potential link relationship between the source node i and the target node j is as follows:
[0102]
[0103] Let α represent the predicted similarity score indicating a potential link relationship between source node i and target node j, where α is a trainable parameter, σ(*) represents the activation function, s(*) represents the similarity metric function based on node attributes, and z... i Let Z, z be the predicted structure representation of the source node. j Let Z and h be the predicted structure representation of target node j. i Let H be the predicted node representation of source node i, h j Let H be the predicted node representation of the target node j.
[0104] S5. Determine whether the predicted similarity score is greater than the set value. If the similarity is greater than the preset value, the output prediction result is that the source node i and the target node j have a potential link relationship. Otherwise, the output prediction result is that the source node i and the target node j do not have a potential link relationship.
[0105] Optionally, the multi-head attention-based method for predicting the link relationship in the jujube market in this invention also includes a process for accurately evaluating the prediction results, with the evaluation metric being Hits@K. Specifically, on different datasets, each model ranks the positive test edges and randomly sampled negative edges, and then calculates the proportion of positive test edges at or above the Kth position.
[0106] Optionally, before calculating the predicted structural representation Z from the adjacency matrix A using a multi-head attention model, and calculating the predicted node representation H based on the feature matrix M and the adjacency matrix A using a GNN model, the prediction method further includes:
[0107] S6. The multi-head attention model and GNN model are trained with the goal of minimizing the multi-class cross-entropy loss function.
[0108] Optionally, the multi-class cross-entropy loss function can be the standard binary cross-entropy loss function, or there can be three multi-class cross-entropy loss functions.
[0109] The goal of the loss function is to minimize the difference between the predicted and true values, making the model's predictions closer to the true labels. The gradient of the loss function with respect to the model parameters is calculated using the backpropagation algorithm, and the model parameters are then updated.
[0110] The formula for calculating the multi-class cross-entropy loss function is as follows:
[0111]
[0112] Where BCE(*) represents the binary cross-entropy loss function; λ1, λ2, and λ3 are adjustable hyperparameters used to control the weights of different loss terms; y ij This represents the actual observation value indicating a potential link relationship between source node i and target node j.
[0113] Example 2
[0114] As shown in Figure 3, this invention also discloses a jujube market link relationship prediction system based on multi-head attention, the prediction system comprising:
[0115] The data processing module 101 is used to construct a local subgraph based on the acquired jujube market data; the local subgraph is composed of target link node D relationships, and the target link node D includes: source node i, target node j and neighbor nodes.
[0116] Matrix construction module 102 is used to construct feature matrix M and adjacency matrix A based on local subgraphs.
[0117] The prediction structure representation construction module 103 is used to calculate the prediction structure representation Z from the adjacency matrix A through a multi-head attention model, and to calculate the prediction node representation H from the feature matrix M and the adjacency matrix A through a GNN model.
[0118] The similarity calculation module 104 calculates the predicted similarity score of the potential link relationship between the source node i and the target node j based on the predicted structure representation Z and the predicted node representation H.
[0119] The judgment module 105 determines whether the predicted similarity score is greater than a set value. If the similarity is greater than the preset value, the output prediction result is that the source node i and the target node j have a potential link relationship; otherwise, the output prediction result is that the source node i and the target node j do not have a potential link relationship.
[0120] This invention constructs a feature matrix M and an adjacency matrix A from a local subgraph obtained from acquired jujube market data. The adjacency matrix A is then used to calculate a predicted structural representation Z using a multi-head attention model. Based on the feature matrix M and adjacency matrix A, a predicted node representation H is calculated using a GNN model. Based on the predicted structural representation Z and predicted node representation H, a predicted similarity score is calculated indicating a potential link relationship between source node i and target node j. This determines whether a potential link relationship exists between source node i and target node j, enabling dynamic prediction of potential link relationships in the jujube market and improving prediction accuracy.
[0121] The purpose of this invention is to provide a method and system for predicting the sales chain of jujubes based on a multi-head attention mechanism and heterogeneous graph neural networks. This aims to solve the problems of insufficient utilization of structural features, low accuracy, and the inability of traditional graph neural network methods to dynamically process jujube sales channels, resulting in poor flexibility. This improves the accuracy and efficiency of jujube sales chain prediction. This invention also aims to provide an efficient and reliable node labeling algorithm for optimizing graph structure data. By labeling subgraph nodes, the uniqueness of nodes in the topology can be determined, thereby obtaining the graph topology and improving the efficiency and accuracy of structural feature calculation. Furthermore, this invention aims to provide a dynamic adjustment method for jujube sales chain prediction. By dynamically adjusting the weights of different features through a multi-head mechanism, links under different demand conditions can be obtained, achieving the goal of dynamic link prediction. This application transforms heterogeneous graph data into the same feature space, enabling homogeneous processing of heterogeneous data and solving the problem of multiple objects and attributes in the sales chain. Meanwhile, in the subgraph extraction module of the heterogeneous multi-head attention model, this application employs a novel node labeling method. This method quickly identifies neighboring nodes that significantly influence the target link while ensuring the uniqueness of the labels. Compared to existing node labeling methods, this method can directly find the target and source nodes in the local subgraph, ensuring the uniqueness of all node labels in the subgraph and avoiding structural similarity issues. Furthermore, in generating node features, this application introduces a multi-head attention mechanism. Without adding additional training parameters, it achieves dynamic link prediction by adjusting weights and fusing multi-head features. This application boasts advantages such as high accuracy, few neural network parameters, strong scalability, and high efficiency.
[0122] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the systems disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the descriptions are relatively simple; relevant parts can be referred to the method section.
[0123] This document uses specific examples to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. Furthermore, those skilled in the art will recognize that, based on the ideas of the present invention, there will be changes in the specific implementation methods and application scope. Therefore, the content of this specification should not be construed as a limitation of the present invention.
Claims
1. A method for predicting the market link relationship of jujubes based on multi-head attention, characterized in that, The prediction method includes: constructing a local subgraph based on acquired jujube market data; the local subgraph consists of target link node D relationships, where target link node D includes: source node i, target node j, and neighbor nodes; constructing a feature matrix M and an adjacency matrix A based on the local subgraph; calculating the predicted structure representation Z using a multi-head attention model on the adjacency matrix A, and calculating the predicted node representation H using a GNN model based on the feature matrix M and the adjacency matrix A; calculating the predicted similarity score indicating a potential link relationship between source node i and target node j based on the predicted structure representation Z and the predicted node representation H; determining whether the predicted similarity score is greater than a preset value; if the similarity is greater than the preset value, the output prediction result is that source node i and target node j have a potential link relationship; otherwise, the output prediction result is that source node i and target node j do not have a potential link relationship.
2. The method for predicting the market link relationship of jujubes based on multi-head attention according to claim 1, characterized in that, The process of constructing a local subgraph based on the acquired jujube market data includes: organizing the acquired jujube market data into tabular data, converting the tabular data into heterogeneous graph data, mapping the data nodes of the heterogeneous graph data to data nodes in the same feature space, extracting the data nodes in the same feature space, and obtaining a local subgraph composed of the target link node D relationship.
3. The method for predicting the market link relationship of jujubes based on multi-head attention according to claim 1, characterized in that, The construction of feature matrix M and adjacency matrix A based on local subgraphs specifically includes: constructing feature matrix M based on the attributes of each node in the local subgraph; labeling nodes in the local subgraph to obtain node index labels; and constructing adjacency matrix A based on the index labels of each node in the local subgraph.
4. The method for predicting the market link relationship of jujubes based on multi-head attention according to claim 3, characterized in that, The local subgraph is labeled with node indices. Specifically, this involves: labeling the source node i in the target link node D of the local subgraph with an index of 0, the target node j with an index of 1, and all neighboring nodes with an index of 2, thus obtaining the index of each node; constructing a string label based on the index of each node and the indexes of all its adjacent connectable nodes; the string label is a list of the indexes of adjacent connectable nodes arranged in ascending order; arranging all node indexes in ascending order, when nodes have the same index, sorting them by their string labels in ascending order; when nodes also have the same string labels, assigning the same index label to nodes with both the index and string labels. ; Re-execute "Construct a string tag based on the sequence number tag of each node and the sequence number tags of all adjacent connectable nodes of that node; the string tag is a tag in ascending order of the sequence number tags of adjacent connectable nodes; arrange the sequence number tags of all nodes in ascending order, when the sequence number tags of nodes are the same, sort them in ascending order according to the string tag of each node, when the string tags of nodes are also the same, assign the same sequence number tag to nodes with the same sequence number tag and string tag", until there are no nodes with the same sequence number tag but different string tags, then re-sort the sequence number tags of all nodes in ascending order, wherein nodes with the same sequence number tag and string tag can be randomly sorted in ascending order to obtain the node's sequence number tag.
5. The method for predicting the market link relationship of jujubes based on multi-head attention according to claim 1, characterized in that, The adjacency matrix A is used to calculate the predicted structural representation Z through a multi-head attention model. Specifically, this involves: inputting the adjacency matrix A into the structural feature vector X obtained by incorporating the multi-head attention model, and diagonalizing the structural feature vector X to obtain the structural feature matrix X. S , the structural feature matrix X S Multiplying the adjacency matrix A yields the structural representation Z.
6. The method for predicting the market link relationship of jujubes based on multi-head attention according to claim 5, characterized in that, The adjacency matrix A is input into the multi-head attention model to obtain the structural feature vector X. Specifically, this includes: inputting the adjacency matrix A into the multi-head attention model to obtain the node feature representation. Based on node feature representation Obtain edge feature representation Based on node feature representation Sum and edge feature representation Construct a structural feature vector X; the calculation formula for the node feature representation is: in, Let i be the node feature representation of source node i at layer t. Let j be the node feature representation of the target node at layer t-1. This represents the weight matrix of the k-th head in layer t, where k is the number of heads. Let represent the k-th head attention coefficient between source node i and target node j; the calculation formula for the edge feature representation is: The formula for calculating the structural feature vector X is:
7. The method for predicting the market link relationship of jujubes based on multi-head attention according to claim 5, characterized in that, The prediction structure represents the formula for calculating Z as follows: Z = AX S The formula for calculating the predicted node H is as follows: Where M is the characteristic matrix, W represents the normalized adjacency matrix. GNN These are the parameters of the GNN.
8. The method for predicting the market link relationship of jujubes based on multi-head attention according to claim 1, characterized in that, The formula for calculating the predicted similarity score of the potential link relationship between source node i and target node j is as follows: Let α represent the predicted similarity score indicating a potential link relationship between source node i and target node j, where α is a trainable parameter, σ(*) represents the activation function, s(*) represents the similarity metric function based on node attributes, and z... i Let Z, z be the predicted structure representation of the source node. j Let Z and h be the predicted structure representation of target node j. i Let H, h be the predicted node representation of source node i. j Let H be the predicted node representation of the target node j.
9. The method for predicting the market link relationship of jujubes based on multi-head attention according to claim 8, characterized in that, Before calculating the predicted structural representation Z from the adjacency matrix A using a multi-head attention model, and calculating the predicted node representation H based on the feature matrix M and the adjacency matrix A using a GNN model, the prediction method further includes: training the multi-head attention model and the GNN model with the objective of minimizing the multi-class cross-entropy loss function; the formula for calculating the multi-class cross-entropy loss function is as follows: Where BCE(*) represents the binary cross-entropy loss function; λ1, λ2, and λ3 are adjustable hyperparameters used to control the weights of different loss terms; y ij This represents the actual observation value indicating a potential link relationship between source node i and target node j.
10. A jujube market link relationship prediction system based on multi-head attention, characterized in that, The prediction system includes: a data processing module for constructing a local subgraph based on acquired jujube market data; the local subgraph consists of target link nodes D, which include source node i, target node j, and neighbor nodes; a matrix construction module for constructing a feature matrix M and an adjacency matrix A based on the local subgraph; a prediction structure representation construction module for calculating the prediction structure representation Z from the adjacency matrix A using a multi-head attention model, and calculating the prediction node representation H from the feature matrix M and adjacency matrix A using a GNN model; a similarity calculation module for calculating the predicted similarity score between source node i and target node j based on the prediction structure representation Z and the prediction node representation H; and a judgment module for judging whether the predicted similarity score is greater than a preset value. If the similarity is greater than the preset value, the output prediction result is that source node i and target node j have a potential link relationship; otherwise, the output prediction result is that source node i and target node j do not have a potential link relationship.
