Friend recommendation method based on cross-view comparative learning in location social network
By generating metapathic path examples of distance and time constraints in the location social network, and using cross-view comparison learning method, combining the comparison tasks of fine-grained and coarse-grained views, the sparsity and edge noise problems of heterogeneous graph comparison learning method when processing spatiotemporal information is solved, achieving more accurate and high-quality friend recommendation effects.
Patent Information
- Application Number
- CN202411624916.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-14
- Publication Date
- 2025-03-04
- Estimated Expiration
- 2044-11-14
AI Technical Summary
When dealing with location social networks, the existing heterogeneous graph comparison learning method fails to effectively utilize spatiotemporal information, resulting in spatiotemporal and edge noise problems, and only considers the consistency or complementarity of heterogeneous information, resulting in poor recommendations from friends.
By generating distance-constrained metapath instances and time-constrained metapath instances, using cross-view comparison learning methods, combining the comparison tasks of fine-grained and coarse-grained views, the consistency and complementarity of heterogeneous information are captured, and user node embedding is optimized to improve recommendation accuracy.
It effectively alleviates the sparsity and edge noise problems of location social networks, improves the accuracy and robustness of friend recommendations, and improves the performance of the model and the quality of user recommendations by considering the consistency and complementarity of information.
Smart Images

Figure CN119557521A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of recommendation, and in particular relates to a friend recommendation method based on cross-view contrast learning in a location social network. Background Art
[0002] Traditional friend recommendation systems make recommendations based on users' interest tags, social network relationships, and behavior patterns, while the check-in data of location-based social networks introduces information in spatial and temporal dimensions, making recommendations more personalized and accurate. By analyzing the check-in data, users' interests, travel habits, and potential social relationships can be revealed, thereby recommending new friends that may be of interest to users.
[0003] The success of graph representation learning based on neural networks in graph analysis tasks has promoted the development of heterogeneous graph neural networks for friend recommendation. Traditional heterogeneous graph neural networks all follow the semi-supervised learning paradigm. However, in practical applications, it is always expensive and difficult to obtain labeled data. Therefore, self-supervised learning that explores the intrinsic information hidden in the data itself has become a promising solution for unlabeled data. In the self-supervised learning paradigm, contrastive learning has become a highly regarded heterogeneous graph learning method due to its outstanding achievements in computer vision and natural language processing. Currently, the known heterogeneous graph contrastive learning methods mainly use meta-paths and network patterns to design contrastive views. In "Heterogeneous graph contrastive multi-view learning" (Wang, 2023), a variety of contrastive methods are used based on meta-paths, including intra-view contrast and inter-view contrast. A view is constructed for each meta-path, and contrasts are performed between two perturbed views of a meta-path induced view, between two meta-path induced views, and between a meta-path induced view and the summary representation of the meta-path induced view. Only the consistency of the structural and semantic information carried by different meta-paths is considered. In "Heterogeneous graph contrastive learning with metapath contexts and weighted negative samples" (Yu & Li, 2023), two contrast methods are used: one is the contrast between the coarse-grained view constructed by aggregating metapath neighbors and the fine-grained view constructed by fusing metapath node embeddings, and the other is the contrast between the coarse-grained view and the cluster representation generated by the clustering algorithm, which only considers the complementarity of information. In "Self-supervised heterogeneous graph neural network with co-contrastive learning" (Wang, 2021), in addition to the meta-path view, a network pattern view is also proposed and compared. The meta-path view is constructed by fusing the node embeddings of the meta-path, while the network pattern view is constructed by aggregating first-order neighbors from different types, which only considers the consistency of information carried by different perspectives of the heterogeneous graph.
[0004] At present, there are two main shortcomings in the comparative learning methods of heterogeneous graphs for friend recommendation: 1) these methods do not make good use of spatiotemporal information to deal with the sparsity and edge noise of heterogeneous networks; 2) these methods only consider the consistency or complementarity of heterogeneous information, resulting in poor friend recommendation effects. Summary of the invention
[0005] The purpose of the present invention is to provide a friend recommendation method based on cross-view contrastive learning in location social networks, which alleviates the sparsity and edge noise of location social networks by utilizing time and space constraints, and captures the consistency and complementarity of heterogeneous information to improve the accuracy of recommendations.
[0006] The technical solution adopted by the present invention is a friend recommendation method based on cross-view contrast learning in a location social network, comprising the following steps:
[0007] S1. Obtain the user's social platform data and build a location social network based on the social platform data;
[0008] S2, generating a distance constraint meta-path instance and a time constraint meta-path instance;
[0009] S3, perform cross-view comparison on fine-grained views;
[0010] S4, perform cross-view comparison on coarse-grained views;
[0011] S5. Calculate the final contrast loss, and train the contrastive learning model based on the final contrast loss to optimize the user node embedding;
[0012] S6. Calculate user similarity and make friend recommendations based on the user similarity.
[0013] Furthermore, in step S1, the social platform data includes user check-in data and user friend relationship data, the user check-in data includes the user, check-in time, and check-in location, the check-in location includes the location latitude and longitude information, the friend relationship data includes the user, and the user-user edge expressing the friend relationship between users. In the location social network, when a user checks in at a check-in location, an edge between the user-check-in location containing the check-in time is generated, and complements the user friend relationship data.
[0014] Furthermore, in step S2, the distance constraint meta-path instance is generated as follows:
[0015] Calculate the distance between check-in locations:
[0016] D = distance (L x ,L y )
[0017] Where D is the distance between check-in locations, distance(·) is the distance function, and L x For location x, L y is location y;
[0018] Set the distance threshold τ, τ>0, if D≤τ, then generate a distance constraint meta-path instance, if D>τ, then do not generate;
[0019] The time constraint meta-path example is:
[0020] Divide the 24 hours of a day into n time periods, represented by {T1, T2, ..., T n},0 <n≤24,T n For the nth time period, if the check-in time is within a time period, the distance constraint meta-path instance is retained and recorded as the time constraint meta-path instance. If it is not within a time period, it is deleted.
[0021] Furthermore, in step S3, the fine-grained view includes a meta-path view, a meta-path enhanced view, a node type view, and a node type enhanced view, and further includes:
[0022] The meta-path view generates the user's node embedding based on each meta-path, which is:
[0023] {X mp |mp∈{UUU,ULU,ULLU}}
[0024] Where, X mp is the node embedding of the user based on the meta-path mp in the meta-path view, mp is any meta-path in the meta-path set, {UUU,ULU,ULLU} is the meta-path set, U is the user, and L is the location;
[0025] The meta-path enhanced view generates user node embeddings based on each meta-path, which is:
[0026] {Y mp |mp∈{UUU,ULU,ULLU}};
[0027] Where Y mp Node embedding based on meta-path mp of users in meta-path enhanced view;
[0028] The node type view generates user node embeddings based on the first-order neighbors of each meta-path as:
[0029] {X nt |nt∈{U UUU ,L ULU ,L ULLU}}
[0030] Where, X nt is the node embedding of the user's first-order nt-type neighbors based on the meta-path in the node type view, nt is any type of the first-order neighbor of the meta-path, {U UUU ,L ULU ,L ULLU} is the type set of the first-order neighbors of the meta-path;
[0031] The node type augmented view generates user node embeddings based on the first-order neighbors of each meta-path, which is:
[0032] {Y nt |nt∈{U UUU ,L ULU ,L ULLU}}
[0033] Where Y nt Node embeddings of user's first-order nt-type neighbors based on meta-paths in node-type enhanced view.
[0034] Furthermore, in step S3, the cross-view comparison of the fine-grained views includes:
[0035] S31. Comparison between meta-path views, and comparison between a meta-path view and a meta-path enhanced view, specifically:
[0036]
[0037] In the formula, is the contrast loss between the meta-path view and the meta-path enhanced view, log(·) is the logarithmic function, The intermediate parameters have no practical meaning. is the positive sample comparison between different meta-path views, is the negative sample comparison between different meta-path views, is the negative sample comparison within the same meta-path view, is the positive sample comparison between different meta-path views and enhanced views, is the negative sample comparison between different meta-path views and enhanced views, is the negative sample comparison between the same meta-path view and the enhanced view, X i is the user node embedding matrix in the meta-path view corresponding to the ith meta-path, X j is the user node embedding matrix in the meta-path view corresponding to the j-th meta-path, Y i The user node embedding matrix in the meta-path enhanced view corresponding to the i-th meta-path, Y j is the user node embedding matrix in the meta-path enhanced view corresponding to the j-th meta-path, u is the user, i is the i-th meta-path in the meta-path set, j is the j-th meta-path in the meta-path set, i≠j, cos(·) is the cosine similarity function, s + (u) is the positive sample set of user u, s - (u) is the negative sample set of user u, v is any user in the positive sample set or negative sample set of user u;
[0038] S32. Comparison between node type views and comparison between node type views and node type enhanced views, specifically:
[0039]
[0040] In the formula, Contrastive loss for node type view and node type enhancement view, The intermediate parameters have no practical meaning. is the positive sample comparison between views of different node types, is the negative sample comparison between views of different node types, For negative sample comparison within the same node type view, is the positive sample comparison between different node type views and enhanced views, For the negative sample comparison between different node type views and enhanced views, is the negative sample comparison between the same node type view and the enhanced view, X m is the user node embedding matrix in the node type view corresponding to the mth type, X n is the user node embedding matrix in the node type view corresponding to the nth type, Y m is the user node embedding matrix in the node type enhanced view corresponding to the mth type, Y n is the user node embedding matrix in the node type enhancement view corresponding to the nth type, m is the mth type in the type set of the first-order neighbors of the meta-path, n is the nth type in the type set of the first-order neighbors of the meta-path, and m≠n.
[0041] Furthermore, in step S4, the coarse-grained view includes a meta-path summary view and a node type summary view, and further includes:
[0042] Meta-path summary view for {X mp |mp∈{UUU,ULU,ULLU}} is weighted summed to generate the node embedding representation H based on the user's meta-path summary view smp , X mp is the node embedding of the user based on the meta-path mp in the meta-path view, mp is any meta-path in the meta-path set, and {UUU,ULU,ULLU} is the meta-path set;
[0043] In the node type summary view, nt |nt∈{U UUU ,L ULU ,L ULLU}} Perform weighted summation to generate the node embedding representation H of the user's node type summary view snt , X ntis the node embedding of the user's first-order nt-type neighbor based on the meta-path in the node type view, nt is any type in the type set of the first-order neighbor of the meta-path, {U UUU ,L ULU ,L ULLU} is the type set of the first-order neighbors of the meta-path.
[0044] Furthermore, in step S4, the cross-view comparison of the coarse-grained view includes the comparison of the meta-path summary view and the node type summary view, specifically:
[0045]
[0046] Where, L SP_ST (u) is the contrast loss between the meta-path summary view and the node type summary view, is the positive sample comparison between the meta-path summary view and the node type summary view, is the negative sample comparison between the meta-path summary view and the node type summary view, s + (u) is the positive sample set of user u, s - (u) is the negative sample set of user u, H smp H is the node embedding representation of the user's meta-path summary view. snt is the node embedding representation of the user based on the node type summary view, cos(·) is the cosine similarity function, u is the user, and v is any user in the positive and negative sample sets of user u.
[0047] Furthermore, in step S5, the final contrast loss is calculated as:
[0048]
[0049] Where L is the final contrast loss, u is the user, and User is the user set. is the contrast loss for the meta-path view and the meta-path enhancement view, Contrastive loss for node type view and node type enhanced view, LSP _ST (u) is the contrast loss between the meta-path summary view and the node type summary view.
[0050] Furthermore, in step S6, the user similarity is calculated as:
[0051] Calculate the similarity of non-friend user node pairs (u, w) in the user's original relationship data, where u is the user and w is any user who is not in a friend relationship with user u.
[0052] The beneficial effects of the present invention are:
[0053] (1) The present invention proposes a friend recommendation method based on cross-view contrastive learning in a location social network. According to the first law of geography, "everything is related to everything else, but things that are close are more related than things that are far away", an enhanced edge between LL (place-place) is generated between two places (L) less than a certain distance threshold, and then a meta-path instance based on ULLU (user-place-place-user) is obtained. Then, in order to capture users (U) with the same travel habits and exclude a certain degree of edge noise, the present invention uses time information to constrain the generation process of ULU (user-place-user) and ULLU meta-path instances. The generated ULU and ULLU instances capture the edge relationship between two users visiting the same and similar places in the same time period. The edge enhancement technology based on distance and time constraints is used to alleviate the sparsity problem of the network with spatiotemporal information and reduce the noise in the network, thereby overcoming the problem of poor representation of learned node embeddings due to the network being too sparse and complex noise.
[0054] (2) The present invention takes into account both the consistency and complementarity of information, and designs two levels of comparison views: fine-grained views (meta-path views, meta-path enhanced views, node type views, and node type enhanced views) and coarse-grained views (meta-path summary views and node type summary views). When designing the comparison task, the present invention uses the comparison between different fine-grained views to learn the consistent representation of nodes in different views to capture the consistency of information, and uses the comparison between two coarse-grained views to capture the complementarity of information. The two levels of comparison tasks cooperate with each other and complement each other to jointly learn the embedded representation of nodes, thereby helping the model to better learn the representation of nodes and improve the performance and robustness of the model. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0056] Figure 1 It is a schematic diagram of the process of distance and time constraints in the present invention;
[0057] Figure 2 It is a schematic diagram of the process of performing cross-view comparison in the present invention. DETAILED DESCRIPTION
[0058] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0059] The present invention provides a friend recommendation method based on cross-view contrastive learning in a location social network, comprising the following steps:
[0060] S1. Acquire social platform data of users on the social platform, wherein the social platform data includes user check-in data and user friend relationship data, wherein the user check-in data includes user (U), check-in time, and check-in location (L), wherein the check-in location includes location latitude and longitude information, and the friend relationship data includes user (U), user-user edges (UU) expressing friend relationships between users, and construct a location social network based on the social platform data. In the location social network, when a user checks in at a check-in location, an edge between user and check-in location (UL) including the check-in time is generated, and the edge is supplemented with the user friend relationship data.
[0061] S2, generating a distance constraint meta-path instance and a time constraint meta-path instance;
[0062] In order to compensate for the sparsity of data, the present invention uses the latitude and longitude information of the check-in locations to calculate the distance between the check-in locations. x Check-in, user U2 is at the check-in location L y Check-in, the distance between check-in locations is:
[0063] D = distance (L x ,L y )
[0064] Where D is the distance between check-in locations, and distance(·) is the distance function;
[0065] Set the distance threshold τ, τ>0, if D≤τ, then generate the distance constraint enhanced edge between user U1 and user U2, and get the distance constraint meta-path instance U1L x L y U2; if L x =L y , then the distance constraint meta-path instance is U1L x U2, if D>τ, no processing;
[0066] The time constraint meta-path example is:
[0067] To reduce the noise of spatio-temporal information in the location social network, the present invention further constrains the distance-constrained meta-path instances according to the user check-in time, that is, divides 24 hours of a day into n time periods, denoted as {T1, T2,..., Tn}, 0 < n ≤ 24, Tn is the nth time period. If the check-in times of user U1 and user U2 are within one time period, then retain this meta-path instance to obtain the time-constrained meta-path instance; if not, then delete it.
[0068] As Figure 1 shown, it is a schematic diagram of the process for distance and time constraints.
[0069] S3. Conduct cross-view comparison on the fine-grained views;
[0070] The fine-grained views include the meta-path view, the meta-path enhanced view, the node type view, and the node type enhanced view, and also include:
[0071] The meta-path view generates node embeddings of users based on each meta-path, that is, generates a one-hot code feature matrix for users. According to the time-constrained meta-path instances, generate the adjacency matrix of users. For each meta-path mp in the meta-path set {UUU, ULU, ULLU}, input the one-hot code feature matrix of users and the user adjacency matrix of the time-constrained meta-path instances generated based on the meta-path mp into the graph convolutional network (GCN) encoder to obtain the node embeddings Xmp of users based on each meta-path mp as:
[0072] {Xmp|mp∈{UUU,ULU,ULLU}}
[0073] In the formula, X mp is the node embedding of users based on the meta-path mp in the meta-path view, mp is any meta-path in the meta-path set, {UUU, ULU, ULLU} is the meta-path set, U is the user, L is the location, UUU is the user-user-user meta-path, ULU is the user-location-user meta-path, and ULLU is the user-location-location-user meta-path.
[0074] The meta-path enhanced view generates node embeddings of users based on each meta-path, that is, performs feature masking and edge masking on the one-hot code feature matrix of users input into the GCN encoder and the user adjacency matrix of the time-constrained meta-path instances generated based on each meta-path mp. The feature masking means randomly setting some elements in the feature matrix to zero, and the edge masking means randomly setting some elements in the adjacency matrix to zero, constructing the meta-path enhanced view, and obtaining the node embeddings Ymp of users based on each meta-path mp as:
[0075] {Ymp|mp∈{UUU,ULU,ULLU}};
[0076] Where Ymp is the node embedding of the user based on the meta-path mp in the meta-path enhanced view.
[0077] The node type view generates the node embedding of the user's first-order neighbors based on each meta-path, that is, the attention mechanism is used to aggregate the user's first-order neighbors based on each meta-path, construct the node type view, and generate the node embedding Xnt of the user's first-order neighbors based on each meta-path, which is:
[0078] {Xnt|nt∈{U UUU ,L ULU ,L ULLU}}
[0079] where Xnt is the node embedding of the user's first-order nt-type neighbors based on the meta-path in the node type view, nt is any type in the type set of the first-order neighbors of the meta-path, {U UUU ,L ULU ,L ULLU} is the type set of the first-order neighbors of the meta-path; U UUU is the type of the user’s first-order neighbor under the constraint of the meta-path instance UUU, L ULU is the type of the user's first-order neighbor under the ULU constraint of the meta-path instance, L ULLU is the type of the user's first-order neighbor under the ULLU constraint in the meta-path instance.
[0080] The node type enhanced view generates the user's node embedding based on the first-order neighbors of each meta-path, that is, feature masking is performed on Xnt, some elements of Xnt are randomly set to zero, and the node type enhanced view is generated. The user's node embedding Ynt based on the first-order neighbors of each meta-path is obtained as follows:
[0081] {Ynt|nt∈{U UUU ,L ULU ,L ULLU}}
[0082] where Ynt is the node embedding of the user’s first-order nt-type neighbors based on meta-path in the node type enhanced view.
[0083] Fine-grained view cross-view comparison includes:
[0084] S31. Comparison between meta-path views and comparison between a meta-path view and a meta-path enhanced view, specifically:
[0085]
[0086]
[0087] In the formula, is the contrast loss between the meta-path view and the meta-path enhanced view, log(·) is the logarithmic function, The intermediate parameters have no practical meaning. is the positive sample comparison between different meta-path views, is the negative sample comparison between different meta-path views, is the negative sample comparison within the same meta-path view, is the positive sample comparison between different meta-path views and enhanced views, is the negative sample comparison between different meta-path views and enhanced views, is the negative sample comparison between the same meta-path view and the enhanced view, Xi is the user node embedding matrix in the meta-path view corresponding to the ith meta-path, Xj is the user node embedding matrix in the meta-path view corresponding to the jth meta-path, Yi is the user node embedding matrix in the meta-path enhanced view corresponding to the ith meta-path, Yj is the user node embedding matrix in the meta-path enhanced view corresponding to the jth meta-path, u is the user, i is the ith meta-path in the meta-path set, j is the jth meta-path in the meta-path set, i≠j, cos(·) is the cosine similarity function, s + (u) is the positive sample set of user u, s - (u) is the negative sample set of user u, and v is any user in the positive sample set or negative sample set of user u.
[0088] S32. Comparison between node type views and comparison between node type views and node type enhanced views, specifically:
[0089]
[0090] In the formula, Contrastive loss for node type view and node type enhancement view, The intermediate parameters have no practical meaning. is the positive sample comparison between views of different node types, is the negative sample comparison between views of different node types, For negative sample comparison within the same node type view, is the positive sample comparison between different node type views and enhanced views, For the negative sample comparison between different node type views and enhanced views, is the negative sample comparison between the same node type view and enhanced view, Xm is the user node embedding matrix in the node type view corresponding to the m-th type, Xn is the user node embedding matrix in the node type view corresponding to the n-th type, Ym is the user node embedding matrix in the node type enhanced view corresponding to the m-th type, Yn is the user node embedding matrix in the node type enhanced view corresponding to the n-th type, m is the m-th type in the type set of the first-order neighbors of the meta-path, n is the n-th type in the type set of the first-order neighbors of the meta-path, and m≠n.
[0091] S4, perform cross-view comparison on coarse-grained views;
[0092] The coarse-grained views include the meta-path summary view and the node type summary view, as well as:
[0093] In the meta-path summary view, a weighted summation of {Xmp|mp∈{UUU,ULU,ULLU}} is performed to generate the user's node embedding representation Hsmp based on the meta-path summary view, X mp is the node embedding of the user based on the meta-path mp in the meta-path view, mp is any meta-path in the meta-path set, and {UUU,ULU,ULLU} is the meta-path set.
[0094] In the node type summary view, {Xnt|nt∈{U UUU ,L ULU ,L ULLU}} Perform weighted summation to generate the user's node embedding representation Hsnt based on the node type summary view, Xnt is the node embedding of the user's first-order nt type neighbor based on the meta-path in the node type view, nt is any type in the type set of the first-order neighbor of the meta-path, {U UUU ,L ULU ,L ULLU} is the type set of the first-order neighbors of the meta-path.
[0095] Cross-view comparison of coarse-grained views includes comparison of meta-path summary views and node type summary views, specifically:
[0096]
[0097] In the formula, LSP _ST (u) is the contrast loss between the meta-path summary view and the node type summary view, is the positive sample comparison between the meta-path summary view and the node type summary view, is the negative sample comparison between the meta-path summary view and the node type summary view, s + (u) is the positive sample set of user u, s -(u) is the negative sample set of user u, Hsmp is the node embedding representation of the user based on the meta-path summary view, Hsnt is the node embedding representation of the user based on the node type summary view, cos(·) is the cosine similarity function, u is the user, and v is any user in the positive and negative sample sets of user u.
[0098] like Figure 2 As shown, it is a schematic diagram of the process of cross-view comparison.
[0099] S5. Calculate the final contrast loss, train the contrast learning model based on the final contrast loss, and obtain the user node embedding under the optimized meta-path summary view;
[0100] The final contrast loss is:
[0101]
[0102] Where L is the final contrast loss, u is the user, and User is the user set. is the contrast loss for the meta-path view and the meta-path enhancement view, Contrastive loss for node type view and node type enhanced view, LSP _ST (u) is the contrast loss between the meta-path summary view and the node type summary view.
[0103] S6. Calculate user similarity and make friend recommendations based on the user similarity;
[0104] The present invention uses the importance λmp of each meta-path mp to measure the contribution of the meta-path. According to the meta-path importance learned during the training process and the number of meta-paths passing between user nodes, the degree of association between user nodes is calculated, and sorted and sampled to obtain the candidate positive sample set of the user, which is:
[0105] cand + (u)={(v,t)|t=∑mpλmpInd(v∈Neimp(u))>0}
[0106] In the formula, cand + (u) is the candidate positive sample set of user u, mp is any meta-path in the meta-path set {UUU, ULU, ULLU}, λmp is the importance of the meta-path mp learned during the training process, Neimp(u) is the set of neighboring user nodes connected to user node u through instances of meta-path mp, Ind(·) is an indicator function whose value is 1 if any user node v∈Neimp(u), otherwise it is 0, and t is the degree of association between user nodes u and v.
[0107] According to the degree of association t between user nodes, cand +(u) is sorted and the + (u) Select the first k user nodes v to form the positive sample set s of user u + (u), negative sample set s - (u)=User-s + (u), where User is the set of all users.
[0108] Based on the user node embedding under the optimized meta-path summary view, the similarity of the non-friend user node pairs (u, w) in the user's original relationship data is calculated, where u is the user and w is any user who is not a friend of user u, and friend recommendations are made based on user similarity.
[0109] Example 1
[0110] According to the friend recommendation method based on cross-view contrastive learning in a location social network of the present invention, friend recommendation is performed, including:
[0111] S1. Get the user's social platform data. Table 1 is the user's check-in data, and Table 2 is the user's friend relationship data:
[0112] Table 1 User's sign-in data (partial)
[0113]
[0114]
[0115] Table 2 Friendship data (partial)
[0116] user user 0 2 0 5 0 12 0 33 0 41 1 36 ... ... 2 12 ... ...
[0117] S2. According to the latitude and longitude information of the user's check-in location, the distance between the check-in locations is calculated, and the distance threshold τ=50 is set to generate the distance constraint enhanced edge between the check-in locations as shown in Table 3, and then the distance constraint instances of the meta-paths ULU and ULLU are obtained, as shown in Tables 4 and 5.
[0118] Table 3 Distance constraint enhancement edges between locations (partial)
[0119] Place Place 0 21 0 52 0 167 ... ... 1 44 ... ... 21 52 ... ...
[0120] Table 4 Distance constraint example of metapath ULU (partial)
[0121]
[0122]
[0123] Table 5 Distance constraint examples of metapath ULLU (partial)
[0124] user Sign-in time Check-in location 1 Check-in location 2 Sign-in time user 0 20:12 0 21 20:20 8 0 21:45 0 52 01:35 78 0 18:34 0 167 18:54 125 0 14:12 11 65 14:41 7 ... ... ... ... ... ... 1 11:05 50 34 15:25 86 ... ... ... ... ... ...
[0125] The distance constraint instances of meta-paths ULL and ULLU are further constrained according to the user's check-in time, that is, 24 hours a day are divided into 12 time periods {0:00-2:00, 2:00-4:00, ..., 22:00-24:00}, and the instances with check-in times in the same time period are retained, and the instances with check-in times in different time periods are deleted, and the time constraint instances of meta-paths ULU and ULLU are obtained, as shown in Tables 6 and 7. In addition, the instance of meta-path UUU obtained from Table 2 is shown in Table 8.
[0126] Table 6 Time constraint example of metapath ULU (partial)
[0127] user Sign-in time Place Sign-in time user 0 12:22 16 13:09 53 0 08:54 81 09:04 109 ... ... ... ... ... 1 17:01 8 16:31 29 ... ... ... ... ...
[0128] Table 7 Time constraint example of metapath ULLU (partial)
[0129] user Sign-in time Check-in location 1 Check-in location 2 Sign-in time user 0 20:12 0 21 20:20 8 0 18:34 0 167 18:54 125 0 14:12 11 65 14:41 7 ... ... ... ... ... ...
[0130] Table 8 Example of Metapath UUU (partial)
[0131]
[0132]
[0133] S3. Cross-view comparison of fine-grained views
[0134] Generate the user's initial feature matrix composed of one-hot codes, as shown in Table 9. According to the time constraint instances of meta-paths ULU and ULLU and the instance of meta-path UUU, construct the user adjacency matrix based on meta-paths ULU, ULLU and UUU, where the user adjacency matrix based on meta-path ULLU is shown in Table 10. Input the user's initial feature matrix and the user adjacency matrix based on each meta-path into the graph convolutional network (GCN) encoder to obtain the user node embedding {XULU, XULLU, XUUU} based on meta-paths ULU, ULLU and UUU in the meta-path view.
[0135] Table 9 Initial feature matrix of users (partial)
[0136] user 0 1 0 0 0 ... 0 0 1 0 1 0 0 ... 0 0 2 0 0 1 0 ... 0 0 3 0 0 0 1 ... 0 0 … ... ... ... ... … … … 0 0 0 0 ... 1 0 0 0 0 0 ... 0 1
[0137] Table 10 User adjacency matrix based on meta-path ULLU (partial)
[0138] user 0 ... 7 8 ... 125 ... 0 1 ... 1 1 ... 1 ... ... ... 1 ... ... ... ... ... 7 1 ... 1 0 ... 0 ... 8 1 ... 0 1 ... 0 ... ... ... ... ... ... 1 ... ... 125 1 ... 0 0 ... 1 ... ... ... ... ... ... ... ... …
[0139] The user’s initial feature matrix and some elements in the user adjacency matrix based on each meta-path are randomly set to zero and input into the graph convolutional network (GCN) encoder to obtain the user’s node embedding {YULU, YULLU, YUUU} based on meta-paths ULU, ULLU and UUU in the meta-path enhanced view.
[0140] Generate the initial feature matrix consisting of longitude and latitude of the check-in location, as shown in Table 11. According to the time constraint instances of meta-paths ULU and ULLU, the instances of meta-path UUU, and the feature matrices of users and check-in locations, use the attention mechanism to aggregate the features of the user's first-order neighbors based on each meta-path, and obtain the node embedding of the user based on the first-order neighbors of meta-paths ULU, ULLU and UUU in the node type view.
[0141] Table 11 Initial feature matrix of check-in location (partial)
[0142] Check-in location latitude longitude 0 40.09821789 116.56959598 1 40.00721934 116.31959567 2 40.76067265 116.31452362 ... ... ... 8 40.00705733 116.31778956 ... ... ... 21 40.09827235 116.56974657 ... ... ...
[0143] Randomly set some elements in the user node embedding based on the first-order neighbors of each meta-path to zero, and obtain the user node embedding based on the first-order neighbors of the meta-paths ULU, ULLU and UUU in the node type enhanced view.
[0144] Compare the meta-path view and the meta-path enhanced view, that is, compare the user node embedding XULU, XULLU, XUUU based on the meta-paths ULU, ULLU and UUU and the enhanced user node embedding YULU, YULLU, YUUU based on the meta-paths ULU, ULLU and UUU, and calculate the contrast loss Compare the node type view and the node type enhanced view, that is, the user node embedding based on the first-order neighbors of meta-paths ULU, ULLU and UUU And the enhanced user node embedding based on the first-order neighbors of meta-paths ULU, ULLU and UUU Compare and calculate the contrast loss
[0145] S4, perform cross-view comparison on coarse-grained views;
[0146] The attention mechanism is used to perform weighted summation on the user node embeddings {XULU, XULLU, XUUU} based on the meta-paths ULU, ULLU and UUU to generate the user node embedding Hsmp under the meta-path summary view.
[0147] Use attention mechanism to embed user nodes based on first-order neighbors of meta-paths ULU, ULLU and UUU Perform weighted summation to generate the user node embedding Hsnt under the node type summary view.
[0148] Compare the coarse-grained view, that is, compare the user node embedding Hsmp under the meta-path summary view with the user node embedding Hsnt under the node type summary view, and calculate the contrast loss LSP _ST (u).
[0149] S5. Comparative loss of all users LSP _ST (u) is summed to obtain the final contrast loss L. According to L, backpropagation is performed to optimize the model parameters and update the user embeddings in each view. The model is trained iteratively until convergence. After the model training is completed, the optimized user node embedding under the meta-path summary view is obtained, as shown in Table 12.
[0150] Table 12 User node embedding under the optimized meta-path summary view (partial)
[0151]
[0152] S6. Generate positive sample sets and negative sample sets for training the model, that is, based on the user adjacency matrix of meta-paths ULU, ULLU and UUU and the importance and number of instances of meta-paths, calculate the degree of association between users, select the 5 users with the largest degree of association, generate the positive sample set of users, and randomly select 100 users from the remaining users to generate the negative sample set of users, as shown in Table 13.
[0153] Table 13 User's positive and negative sample sets (partial)
[0154]
[0155] After the model training is completed, the cosine similarity between users is calculated based on the user node embedding under the optimized meta-path summary view, as shown in Table 14. Finally, the top five users who are not friends and have the greatest similarity are recommended as new friends for each user, and a partial friend recommendation list is shown in Table 15.
[0156] Table 14 Cosine similarity between users (partial)
[0157] user 0 ... 7 8 ... 30 ... 77 ... 125 ... 0 1 ... 0.8023 0.9012 ... 0.8812 ... 0.7856 ... 0.7964 ... ... ... ... ... ... ... ... ... ... ... 7 1 0.6044 ... 0.5023 ... 0.5123 ... 0.6284 ... 8 1 ... 0.7845 ... 0.5049 ... 0.6612 ... ... ... ... ... ... ... ... 30 1 ... 0.5623 ... 0.6678 ... ... ... ... ... ... 77 1 ... 0.7142 ... ... ... ... 125 1 ... ... …
[0158] Table 15 Friends Recommendation List (Part)
[0159]
[0160] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0161] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.
Claims
1. A friend recommendation method based on cross-view contrastive learning in a location social network, characterized in that: The following steps are involved: S1. Obtain the user's social platform data and build a location social network based on the social platform data; S2, generating a distance constraint meta-path instance and a time constraint meta-path instance; S3, perform cross-view comparison on fine-grained views; S4, perform cross-view comparison on coarse-grained views; S5. Calculate the final contrast loss, and train the contrastive learning model based on the final contrast loss to optimize the user node embedding; S6. Calculate user similarity and make friend recommendations based on the user similarity.
2. The friend recommendation method based on cross-view contrastive learning in a location social network according to claim 1, characterized in that: In step S1, the social platform data includes user check-in data and user friend relationship data. The user check-in data includes the user, check-in time, and check-in location. The check-in location includes the location latitude and longitude information. The friend relationship data includes the user and the user-user edge expressing the friend relationship between users. In the location social network, when a user checks in at a check-in location, an edge between the user-check-in location including the check-in time is generated and complements the user friend relationship data.
3. The friend recommendation method based on cross-view contrastive learning in a location social network according to claim 1, characterized in that: In step S2, the distance constraint meta-path instance is generated as follows: Calculate the distance between check-in locations: Distance(L) x ,L y ) Where D is the distance between check-in locations, distance(·) is the distance function, and L x For location x, L y is location y; Set the distance threshold τ, τ>0, if D≤τ, then generate a distance constraint meta-path instance, if D>τ, then do not generate; The time constraint meta-path example is: Divide the 24 hours of a day into n time periods, represented by {T1, T2, ..., T n },0 <n≤24,T n For the nth time period, if the check-in time is within a time period, the distance constraint meta-path instance is retained and recorded as the time constraint meta-path instance. If it is not within a time period, it is deleted.
4. The friend recommendation method based on cross-view contrastive learning in a location social network according to claim 1, characterized in that: In step S3, the fine-grained view includes a meta-path view, a meta-path enhanced view, a node type view, and a node type enhanced view, and further includes: The meta-path view generates user node embeddings based on each meta-path, which is: {X mp |mp∈{YUU,HEAD,HEAD}} Where, X mp is the node embedding of the user based on the meta-path mp in the meta-path view, mp is any meta-path in the meta-path set, {UUU,ULU,ULLU} is the meta-path set, U is the user, and L is the location; The meta-path enhanced view generates user node embeddings based on each meta-path, which is: {Y mp |mp∈{YUU,HEAD,HEAD}}? Where Y mp Node embedding based on meta-path mp of users in meta-path enhanced view; The node type view generates user node embeddings based on the first-order neighbors of each meta-path as: {X nt |nt∈{U UUU ,L ULU ,L ULLU }} Where, X nt is the node embedding of the user's first-order nt-type neighbors based on the meta-path in the node type view, where nt is any type of the first-order neighbor of the meta-path, {U UUU ,L ULU ,L ULLU } is the type set of the first-order neighbors of the meta-path; The node type augmented view generates user node embeddings based on the first-order neighbors of each meta-path, which is: {Y nt |nt∈{U UUU ,L ULU ,L ULLU }} Where Y nt Node embeddings of user's first-order nt-type neighbors based on meta-paths in node-type enhanced view.
5. The friend recommendation method based on cross-view contrastive learning in a location social network according to claim 1, characterized in that: In step S3, the cross-view comparison of the fine-grained views includes: S31. Comparison between meta-path views, and comparison between a meta-path view and a meta-path enhanced view, specifically: In the formula, is the contrast loss between the meta-path view and the meta-path enhanced view, log(·) is the logarithmic function, The intermediate parameters have no practical meaning. is the positive sample comparison between different meta-path views, is the negative sample comparison between different meta-path views, is the negative sample comparison within the same meta-path view, is the positive sample comparison between different meta-path views and enhanced views, is the negative sample comparison between different meta-path views and enhanced views, is the negative sample comparison between the same meta-path view and the enhanced view, X i is the user node embedding matrix in the meta-path view corresponding to the ith meta-path, X j is the user node embedding matrix in the meta-path view corresponding to the j-th meta-path, Y i The user node embedding matrix in the meta-path enhanced view corresponding to the i-th meta-path, Y j is the user node embedding matrix in the meta-path enhanced view corresponding to the j-th meta-path, u is the user, i is the i-th meta-path in the meta-path set, j is the j-th meta-path in the meta-path set, i≠j, cos(·) is the cosine similarity function, s + (u) is the positive sample set of user u, s - (u) is the negative sample set of user u, v is any user in the positive sample set or negative sample set of user u; S32. Comparison between node type views and comparison between node type views and node type enhanced views, specifically: In the formula, Contrastive loss for node type view and node type enhancement view, The intermediate parameters have no practical meaning. is the positive sample comparison between views of different node types, is the negative sample comparison between views of different node types, For negative sample comparison within the same node type view, is the positive sample comparison between different node type views and enhanced views, For the negative sample comparison between different node type views and enhanced views, is the negative sample comparison between the same node type view and the enhanced view, X m is the user node embedding matrix in the node type view corresponding to the mth type, X n is the user node embedding matrix in the node type view corresponding to the nth type, Y m is the user node embedding matrix in the node type enhanced view corresponding to the mth type, Y n is the user node embedding matrix in the node type enhancement view corresponding to the nth type, m is the mth type in the type set of the first-order neighbors of the meta-path, n is the nth type in the type set of the first-order neighbors of the meta-path, and m≠n.
6. The friend recommendation method based on cross-view contrastive learning in a location social network according to claim 1, characterized in that: In step S4, the coarse-grained view includes a meta-path summary view and a node type summary view, and further includes: Meta-path summary view for {X mp |mp∈{UUU,ULU,ULLU}} is weighted summed to generate the node embedding representation H based on the user's meta-path summary view smp , X mp is the node embedding of the user based on the meta-path mp in the meta-path view, mp is any meta-path in the meta-path set, and {UUU,ULU,ULLU} is the meta-path set; In the node type summary view, nt |nt∈{U UUU ,L ULU ,L ULLU }} Perform weighted summation to generate the node embedding representation H of the user's node type summary view snt , X nt is the node embedding of the user's first-order nt-type neighbor based on the meta-path in the node type view, nt is any type in the type set of the first-order neighbor of the meta-path, {U UUU ,L ULU ,L ULLU } is the type set of the first-order neighbors of the meta-path.
7. The friend recommendation method based on cross-view contrastive learning in a location social network according to claim 1, characterized in that: In step S4, the cross-view comparison of the coarse-grained view includes the comparison of the meta-path summary view and the node type summary view, specifically: Where, L SP_ST (u) is the contrast loss between the meta-path summary view and the node type summary view, is the positive sample comparison between the meta-path summary view and the node type summary view, is the negative sample comparison between the meta-path summary view and the node type summary view, s + (u) is the positive sample set of user u, s - (u) is the negative sample set of user u, H smp H is the node embedding representation of the user's meta-path summary view. snt is the node embedding representation of the user based on the node type summary view, cos(·) is the cosine similarity function, u is the user, and v is any user in the positive and negative sample sets of user u.
8. The friend recommendation method based on cross-view contrastive learning in a location social network according to claim 1, characterized in that: In step S5, the final contrast loss is calculated as: Where L is the final contrast loss, u is the user, and User is the user set. is the contrast loss for the meta-path view and the meta-path enhancement view, is the contrast loss for node type view and node type enhancement view, L SP_ST (u) is the contrast loss between the meta-path summary view and the node type summary view.
9. The friend recommendation method based on cross-view contrastive learning in a location social network according to claim 1, characterized in that: In step S6, the user similarity is calculated as: Calculate the similarity of non-friend user node pairs (u, w) in the user's original relationship data, where u is the user and w is any user who is not in a friend relationship with user u.
Citation Information
Patent Citations
Friend recommendation method and device, equipment and storage medium
CN114579879A
Graph neural network recommendation method and system based on social preference
CN118171738A
Community search method for friendship recommendation in dynamic social network
CN118606565A
Offline Friend Recommendation using Mobile Context and Online Friend Network Information based on Tensor Factorization
KR101859845B1