A link prediction method and system based on improved cosine similarity
Patent Information
- Application Number
- CN202410132516.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-31
- Publication Date
- 2026-09-22
- Estimated Expiration
- 2044-01-31
AI Technical Summary
[0005]基于路径和随机游走法考虑了节点间的多步连接路径,能够捕捉到网络的全局结构特征,但计算复杂度较高;例如Clauset等人提出的层次随机图模型(HierarchicalRandom Graph model),以及Guimerà和Sales-Pardo介绍的随机块模型(Stochastic BlockModel),这些方法能够捕捉到网络的全局结构特征,但计算复杂度较高
[0026]1、解决了传统方法在局部结构处理上的局限性,并通过平衡节点度的影响,提高了算法在各种网络类型上的适应性和准确性;
Smart Images

Figure CN118070070B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of link prediction technology, and in particular to a link prediction method and system based on improved cosine similarity. Background Technology
[0002] Link prediction is a core problem in complex network analysis, focusing on predicting links that do not yet exist within a network. Complex networks are ubiquitous in nature and human society, encompassing various types such as biological networks, social networks, transportation networks, and the Internet. A common characteristic of these networks is that they consist of a large number of nodes and connections between them, and the formation and disappearance of these connections are dynamic. Link prediction arose in this context, aiming to predict potential future connections by analyzing existing network structures.
[0003] Link prediction methods can be broadly classified into three categories: similarity-based methods, path-based and random walk-based methods, and neural network-based methods.
[0004] Similarity-based methods primarily predict whether a link will form between two nodes in a network by calculating their similarity. This method is simple and intuitive, but it may overlook the global characteristics of the network structure. Other methods, such as the semantic method explored by Hasan et al. that combines topological information with node content data, and the method by Wang et al. that uses a logistic regression classifier, are also simple and intuitive, but they may overlook the global characteristics of the network structure.
[0005] Path-based and random walk-based methods consider multi-step connection paths between nodes and can capture the global structural features of the network, but they have high computational complexity. For example, the hierarchical random graph model proposed by Clauset et al., and the stochastic block model introduced by Guimerà and Sales-Pardo, can capture the global structural features of the network, but they also have high computational complexity.
[0006] Neural network-based methods predict potential links by learning complex interaction patterns between network nodes. These methods use deep learning techniques, such as graph neural networks (GNNs), to automatically extract high-level features of nodes from data. However, this increases the complexity of model training and poses a challenge to understanding the model's decision-making process. For example, Li et al. (2021) demonstrated a novel neural network-based link prediction method in their research; Wang et al. (2019) proposed a link prediction method based on deep convolutional neural networks, which outperformed other benchmark algorithms on multiple datasets; and Liu et al. (2024) demonstrated a method that combines community detection algorithms and graph neural network models to enhance link prediction in scientific literature networks. Summary of the Invention
[0007] To address the shortcomings of existing methods, this invention significantly improves the accuracy of link prediction by adding local structural information.
[0008] The technical solution adopted in this invention is: a link prediction method based on improved cosine similarity, comprising the following steps:
[0009] Step 1: Obtain the dataset and divide it proportionally to construct the data required for link prediction;
[0010] In a preferred embodiment of the present invention, the dataset includes: email-Eu-core, lesmis, and football.
[0011] Step 2: Obtain the degree of a given node, its connected edges, all nodes connected to that node, and the common neighbors between any two nodes.
[0012] In a preferred embodiment of the present invention, the dict function is used to obtain the node degree and the edges.
[0013] In a preferred embodiment of the present invention, the set function is used to obtain all connected nodes of a given node and the common neighbors between two nodes.
[0014] Step 3: The improved SI algorithm enhances the influence of the number of common neighbors by using the exponential function with the base of the natural logarithm, introduces the square root to reduce the impact of node degree differences on the prediction, and ensures that the sum of node degrees contributes positively to the similarity score by multiplying by the sum of the node degree values of the two nodes. The node degree and the edges are input into the improved SI algorithm to obtain the structural similarity matrix of each node.
[0015] As a preferred embodiment of the present invention, the formula for the improved SI algorithm is:
[0016]
[0017] Where Γ(A) and Γ(B) are the sets of all connection points between nodes A and B; the number of common neighbors of A and B is obtained by the union of the two sets; k A and k B are the node degree values of nodes A and B, respectively, and e is the natural constant.
[0018] Step 4: Sort all non-existent edges in descending order of structural similarity value, select the top few edges as existing links, and evaluate the improved SI algorithm using accuracy, recall, F-score, and AUC metrics.
[0019] In a preferred embodiment of the present invention, the formula for the AUC index is:
[0020]
[0021] Where N represents the total number of predictions, N = TP + TN; λ is a random number; TP represents correctly predicted positive samples; TN represents correctly predicted negative samples.
[0022] In a preferred embodiment of the present invention, 0.5 = <λ < 1.
[0023] As a preferred embodiment of the present invention, a link prediction system based on improved cosine similarity includes: a memory for storing instructions executable by a processor; and a processor for executing the instructions to implement a link prediction method based on improved cosine similarity.
[0024] As a preferred embodiment of the present invention, a computer-readable medium storing computer program code implements a link prediction method based on improved cosine similarity when executed by a processor.
[0025] The beneficial effects of this invention are:
[0026] 1. It overcomes the limitations of traditional methods in handling local structures and improves the adaptability and accuracy of the algorithm on various network types by balancing the influence of node degree;
[0027] 2. Methods that consider different network characteristics, especially when dealing with complex networks with uneven node degree distribution and rich local structural information, enable the IpSI algorithm to have better prediction performance than CN, SI, RA, PA and LSCN. Attached Figure Description
[0028] Figure 1 This is a flowchart of the link prediction method based on improved cosine similarity of the present invention;
[0029] Figure 2 This is the network node topology diagram of the present invention. Detailed Implementation
[0030] The present invention will be further described below with reference to the accompanying drawings and embodiments. The drawings are simplified schematic diagrams, which only illustrate the basic structure of the present invention in a schematic manner, and therefore only show the components related to the present invention.
[0031] like Figure 1 As shown, a link prediction method based on improved cosine similarity includes the following steps:
[0032] Step 1: Obtain the dataset and divide it proportionally to construct the training set required for link prediction;
[0033] Predict the connection probability between nodes based on the feature information of nodes in the training set, and use the test set to verify the accuracy of the prediction results; randomly select 90% of the edges in the dataset as the training set and 10% of the edges as the test set.
[0034] Three public datasets were used, including the email-Eu-core dataset, the lesmis dataset, and the football dataset.
[0035] The email-Eu-core dataset was generated using email data from a large European research institution, spanning from October 2003 to May 2005 (18 months). All incoming and outgoing emails between members of the research institution were anonymous. The emails only represent communications between members or core members of the institution. 986 email addresses were used as nodes, and 332,334 emails were used as timestamped edges.
[0036] The Lesmis dataset is based on Victor Hugo's novel Les Misérables, which organizes the network of relationships between characters. Nodes in the network represent characters in the novel, and edges represent two characters appearing in one or more scenes. The study examines the key edges in the interpersonal network, i.e., the connections between characters, and their impact on the overall performance of the network. Discovering key edges within the network is of great significance for understanding the spread of public opinion and diseases. The network consists of 77 nodes and 508 edges.
[0037] The football dataset is a complex social network created based on the American college football league. It contains 115 nodes and 616 edges. The nodes in the network represent football teams, and the edges between two nodes indicate that the two teams have played a match. The 115 college teams are divided into 12 conferences. The competition process is that teams within a conference first play group matches, and then teams from different conferences play against each other.
[0038] To verify the accuracy of the IpSI (Improved Salton Index) algorithm, experiments typically involve randomly dividing the known dataset E into a training set Ei and a training set Ei. T and test set E P Using training set E T The network information in the test set E predicts the possible edges that may be generated. P The accuracy of the IpSI algorithm is determined by comparing different evaluation metrics, E = E P ∪E T and
[0039] Step 2: Calculate the degree of all nodes in the training set and their corresponding degrees as the initial conditions required by the algorithm.
[0040] Figure 2 For a NetworkX format network, use the dict() function to obtain the required node degree data and edges; for example... Figure 2 Node A in (a) has two edges connected to it, meaning node A has two degrees. The number of edges connecting node A is l. DA and l AE Use the set() function to get all the connection points of nodes A and B. For example, all the connection points of node A are nodes D and E. Get the common neighbors of A and B by set union. For example, node E is the common neighbor of A and B.
[0041] Step 3: Substitute the node degree data and edges into the IpSI algorithm to obtain the structural similarity matrix of each node;
[0042] Existing methods for predicting local similarity links, such as CN, SI, RA, PA, and LSCN, generally suffer from the following shortcomings:
[0043] Simplifying local structure processing: For example, the number of common neighbors (CN method, RA method) often only considers the basic dimension of local similarity, while ignoring more complex local structural information.
[0044] Degree distribution bias: When dealing with networks with uneven node degree distribution, RA and PA methods may lead to prediction bias. RA method overemphasizes low-degree nodes, while PA method tends to favor high-degree nodes.
[0045] Lack of comprehensive consideration: Although LSCN attempts to consider the similarity between public neighbors, these methods as a whole lack a comprehensive consideration of different network characteristics.
[0046] The existing SI algorithm uses the following formula to calculate structural similarity values:
[0047]
[0048] Where Γ(A) and Γ(B) are the sets of all connection points between nodes A and B; ∩ sets represent the number of common neighbors of A and B; k A and k B These are the node degree values of nodes A and B, respectively.
[0049] To address the aforementioned shortcomings, the IpSI algorithm has been improved as follows:
[0050] Enhanced local structure analysis: The IpSI algorithm comprehensively considers the number of common neighbors and emphasizes the impact of the number of common neighbors through an exponential function with the natural logarithm base, which represents richer structural characteristics.
[0051] Balancing the impact of node degree: The IpSI algorithm introduces |k A -k B The square root of |+1 is used to reduce the impact of node degree differences on the prediction, and multiplication by (k) is also used. A +k B This ensures that the sum of node degrees contributes positively to the similarity score, which to some extent solves the bias problem of certain types of nodes in the RA and PA algorithms.
[0052] Figure 2 Taking the email network as an example, different local network structures are shown, and the connection probability of A and B is determined by the connection status and node degree information of network nodes A and B.
[0053] exist Figure 2 In (a) nodes A and B have only one common neighbor E. In the IpSI algorithm, this node E enhances its contribution to the connection probability through an exponential function. Since the number of common neighbors is small, even if their degrees are similar or their sum is large, the connection probability between nodes A and B will not be particularly high.
[0054] The structural similarity values between nodes A and B are:
[0055]
[0056] Figure 2 Figure (b) illustrates a more complex scenario where nodes A and B have three common neighbors. In this case, due to the increased number of common neighbors, the contribution of the exponential term in the IpSI algorithm to the connection probability increases significantly, and the connection probability between nodes A and B may grow exponentially.
[0057] The structural similarity values between nodes A and B are:
[0058]
[0059] Figure 2(c) further increases the complexity of the network, with nodes A and B having not only multiple common neighbors but also more connections. In the IpSI algorithm, the number of common neighbors, the difference in node degree, and the sum of node degrees are all taken into account. Since the difference in node degree is adjusted by the square root of the denominator plus a term, it is ensured that the connection probability will not be greatly affected even if the node degrees are different. At the same time, the sum of node degrees is also emphasized through the multiplication term, which further improves the connection probability.
[0060] The structural similarity values between nodes A and B are:
[0061]
[0062] In summary, the unique feature of the IpSI algorithm is that it not only considers the number of common neighbors, but also emphasizes this feature through an exponential function, while balancing the difference and sum of node degrees to comprehensively assess the probability of establishing a connection between two nodes; this method provides a more detailed and comprehensive perspective for predicting new connections between nodes in a network.
[0063] Step 4: Sort all non-existent edges in descending order of structural similarity value, and take the top L edges as the most likely links; then use accuracy, recall, F_score and AUC to evaluate the prediction performance of the IpSI algorithm, and compare it with the accuracy of link prediction by CN, SI, RA, PA and LSCN criterions.
[0064] The IpSI algorithm is used to obtain the structural similarity values of all edges. Edges existing in the training set are removed, and the remaining edges are arranged in descending order of structural similarity value to form an edge table. The number of edges L in the validation set is obtained, and L edges are selected from top to bottom in the edge table. These selected edges are used as the prediction results and compared with the validation set.
[0065] The accuracy of the IpSI algorithm was evaluated using the metrics of accuracy, recall, F-score, and AUC.
[0066] 1. Accuracy is the ratio of the selected relevant items to the number of selected items. The first L links are used as prediction links, and only L links are selected in the test set. r If there are 1 correct link, the accuracy value is:
[0067]
[0068] 2. Recall is the proportion of data predicted as positive out of the actual positive data. Correctly predicted positive samples are called TP, and incorrectly predicted negative samples are called FN. Therefore, Recall is:
[0069]
[0070] 3. The F-Score is a combined measure of precision and recall. Recall is defined as the ratio of m existing links to all links M, i.e., recall = m / M. Therefore, the F-Score is:
[0071]
[0072] 4. AUC is the probability that a missing link has a higher score than a non-existent link. If a link with n1 missing occurrences has a higher score, and a link with n2 missing occurrences has the same score, then the AUC value is:
[0073]
[0074] Where N represents the total number of predictions, N = TP + TN; λ is a random number, 0.5 < λ < 1; TP represents correctly predicted positive samples; TN represents correctly predicted negative samples.
[0075] In AUC calculation, λ typically represents the prediction level of a random probability level. In binary classification tasks, the AUC value is a method used to measure the predictive performance of a model. λ represents the effect of random guessing, meaning that the model's predictive ability is no different from random guessing. If the AUC value is greater than 0.5, the model's predictive ability is considered useful. If the AUC value is close to 1.0, it indicates that the model has excellent predictive ability. The AUC calculation in this invention involves the model's ability to rank positive and negative sample pairs. Therefore, setting the λ coefficient to 0.5 as a judgment of the random probability level when the model cannot distinguish between positive and negative sample pairs can more accurately evaluate the model.
[0076] The algorithm achieved good prediction results on the public datasets: email-Eu-core, lesmis, and football. Table 1-4 compares the accuracy, recall, F-score, and AUC of the proposed algorithm with several traditional link prediction similarity algorithms. As can be seen from the table, the IpSI algorithm has a significant improvement in all four metrics compared to other algorithms.
[0077] Table 1 Comparison of accuracy metrics for different algorithms
[0078] CN 0.268 0.283 0.560 SI 0.273 0.220 0.520 RA 0.048 0.017 0.080 PA 0.155 0.034 0.040 LSCN 0.083 0.288 0.440 IpSI 0.273 0.305 0.610
[0079] Table 2 Comparison of Recall metrics for different algorithms
[0080] CN 0.134 0.146 0.280 SI 0.136 0.110 0.260 RA 0.024 0.008 0.040 PA 0.078 0.017 0.020 LSCN 0.042 0.144 0.220 IpSI 0.136 0.153 0.300
[0081] Table 3 Comparison of F-Score metrics for different algorithms
[0082] CN 0.179 0.195 0.027 SI 0.191 0.147 0.347 RA 0.032 0.011 0.053 PA 0.103 0.023 0.027 LSCN 0.055 0.192 0.293 IpSI 0.182 0.203 0.400
[0083] Table 4 Comparison of AUC metrics for different algorithms
[0084] CN 0.965 0.905 0.970 SI 0.975 0.910 0.970 RA 0.725 0.680 0.660 PA 0.940 0.765 0.940 LSCN 0.935 0.900 0.955 IpSI 0.975 0.935 0.975
[0085] Compared to CN, SI, RA, PA, and LSCN, the IpSI method of this invention improves performance on all three datasets. The advantages of the IpSI algorithm lie in its comprehensiveness and flexibility. It not only solves the limitations of traditional methods in handling local structure, but also improves the adaptability and accuracy of the algorithm on various network types by balancing the influence of node degree. This method, which comprehensively considers the characteristics of different networks, especially when dealing with complex networks with uneven node degree distribution and rich local structural information, makes the IpSI algorithm have better prediction performance than CN, SI, RA, PA, and LSCN.
[0086] Based on the above-described preferred embodiments of the present invention, and through the foregoing description, those skilled in the art can make various changes and modifications without departing from the inventive concept. The technical scope of this invention is not limited to the contents of the specification, but must be determined according to the scope of the claims.
Claims
1. A link prediction method based on improved cosine similarity, characterized in that, Includes the following steps: Step 1: Obtain the dataset and divide it proportionally to construct the data required for link prediction; Step 2: Obtain the degree of a given node, its connected edges, all nodes connected to that node, and the common neighbors between any two nodes. Step 3: The improved SI algorithm enhances the influence of the number of common neighbors by using the exponential function with the base of the natural logarithm, introduces the square root to reduce the impact of node degree differences on the prediction, and ensures that the sum of node degrees contributes positively to the similarity score by multiplying by the sum of the node degree values of the two nodes. The node degree and the edges are input into the improved SI algorithm to obtain the structural similarity matrix of each node. The formula for the improved SI algorithm is: in, and Let be the set of all connection points between node A and node B; and are the node degree values of nodes A and B, respectively, and e is the natural constant; Step 4: Sort all non-existent edges in descending order of structural similarity value, select the top few edges as existing links, and evaluate the improved SI algorithm using accuracy, recall, F-score, and AUC metrics.
2. The link prediction method based on improved cosine similarity according to claim 1, characterized in that, Use the dict function to get the node degree.
3. The link prediction method based on improved cosine similarity according to claim 1, characterized in that, Use the set function to get all the connected nodes of a given node.
4. The link prediction method based on improved cosine similarity according to claim 1, characterized in that, The dataset includes: email-Eu-core, lesmis, and football.
5. The link prediction method based on improved cosine similarity according to claim 1, characterized in that, The formula for the AUC indicator is: in, N Represents the total number of predictions. N = TP + TN λ is a random number; TP For a correct prediction and a positive sample; TN This is for a correct prediction that results in a negative sample.
6. The link prediction method based on improved cosine similarity according to claim 5, characterized in that, 0.5 = < λ < 1.
7. A link prediction system based on improved cosine similarity, characterized in that, include: Memory is used to store instructions that can be executed by the processor; A processor for executing instructions to implement the link prediction method based on improved cosine similarity as described in any one of claims 1-6.
8. A computer-readable medium storing computer program code, characterized in that, The computer program code, when executed by a processor, implements the link prediction method based on improved cosine similarity as described in any one of claims 1-6.
Citation Information
Patent Citations
Link prediction similarity index method based on improved local path
CN112579708A
Complex network link prediction method and device, electronic equipment and medium
CN112700056A