A social network friend recommendation method based on heterogeneous graph neural network clustering
By using a heterogeneous graph neural network in social networks to combine user characteristics and interactive information, the problem of ignoring user characteristics and connections in the prior art is solved, and more accurate user vector representation and friend recommendation results are achieved.
Patent Information
- Application Number
- CN202411376289.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-30
- Publication Date
- 2025-03-04
- Estimated Expiration
- 2044-09-30
AI Technical Summary
The prior art ignores the user's own characteristic information and potential connections between users in social networks, resulting in user vector learning bias and affects the accuracy of friend recommendation results.
Using a method based on heterogeneous graph neural network, the feature propagation module and the central embedding module combine the user's own attribute information and the interaction information between users, the sub-graph learning module is used to consider the similarity between user nodes and the importance of other types of nodes, and improve the K-means algorithm to improve the accuracy of user clustering.
A more realistic and accurate user vector representation is achieved, the accuracy of friend recommendation results is improved, the problem of user vector learning bias in the prior art is solved, and the accuracy of user community recognition is improved.
Smart Images

Figure CN118939884B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data analysis, and in particular to a social network friend recommendation method based on heterogeneous graph neural network clustering. Background Art
[0002] With the rapid development of the Internet, various social networking platforms have emerged. In social networks, users' interests and hobbies as well as diversified relationships between users exist in various forms. How to effectively analyze these data and obtain useful knowledge from them in order to better understand user groups and improve user experience is of great significance to the development of social networks.
[0003] Since the network community structure can show the basic functional components of the network, community discovery has great value in social network analysis and behavioral data mining. It can cluster users and divide them into several specific user communities based on user data and corresponding behavioral records on social networks to identify user characteristics, thereby gaining a more comprehensive understanding of user interests, habits and behaviors, and is widely used in scenarios such as friend recommendation and network security.
[0004] Existing research usually models social networks as heterogeneous graph structures composed of multiple types of nodes (user entities) and edges (interaction relationships). Therefore, researchers mostly use methods based on heterogeneous graph neural networks to guide the optimization of structural and feature information in heterogeneous graphs and improve the accuracy of user representation. However, there are two defects in existing technologies: on the one hand, the user's own feature information and the potential connections between users through various interactive relationships are not fully considered (that is, they are abstracted into structural features that exist after the network); on the other hand, the attention mechanism is directly used to learn the similarity between users, and then the node information is aggregated indiscriminately to obtain the user's embedded representation, which will inevitably lead to deviations in the learned user vectors and affect the accuracy of the final friend recommendation results. Summary of the invention
[0005] The purpose of the present invention is to provide a social network friend recommendation method based on heterogeneous graph neural network clustering, which comprehensively considers the user's own characteristic information and the potential connection information between users, and can more reasonably learn the similarity between users to obtain a more realistic and accurate vector representation, thereby improving the accuracy of the friend recommendation results.
[0006] A social network friend recommendation method based on heterogeneous graph neural network clustering, comprising steps S1 to S5:
[0007] Step S1, reading user related information from a social network database, the user related information including user attribute data, user tweet content data and user group chat data, and obtaining a feature vector representation of user attributes, a feature vector representation of tweet content and a feature vector representation of group chat topics by preprocessing and feature extraction of user related information;
[0008] Step S2, based on the feature vector representation of user attributes, the feature vector representation of tweet content, and the feature vector representation of group chat topics, a social network heterogeneous graph is constructed with users, tweets, and group chats as nodes and the interaction relationships between the three as edges, and relevant meta-paths are defined to capture the semantic relationships between nodes of different types;
[0009] Step S3, inputting the constructed social network heterogeneous graph into the heterogeneous graph neural network model to obtain the final embedding vector of the user node, wherein the heterogeneous graph neural network model includes a projection conversion module, a feature propagation module, a centrality embedding module and a subgraph learning module;
[0010] Step S4, using a cluster center selection method based on the density Gini coefficient to improve the K-means algorithm, and then using the improved K-means algorithm to complete clustering of user nodes based on the final embedding vector of the user node;
[0011] Step S5, based on the clustering results, a recommendation list is obtained using a similarity model, and then the corresponding social network data is obtained based on the final embedding vector of the user in the recommendation list to complete the friend recommendation task for the target user.
[0012] According to the social network friend recommendation method based on heterogeneous graph neural network clustering provided by the present invention, in the heterogeneous graph neural network model of the present invention, the user's own attribute information and the interaction information between users are fully combined through the feature propagation module and the centrality embedding module, which solves the problem that most existing technologies ignore the potential connections between users; through the subgraph learning module, the similarity between user nodes and the importance of other types of nodes to user nodes are considered, so that more reasonable and effective learning of user nodes can be achieved to obtain a more realistic and accurate vector representation of the user in the network structure, which solves the problem of deviation in the existing technology when learning user vector representation; in addition, the present invention adopts a clustering center selection method based on the density Gini coefficient to improve the K-means algorithm, which can solve the problem of sensitivity of the initial clustering center and improve the accuracy of user clustering, thereby realizing accurate social network user community identification and solving the problem of low friend recommendation accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] Figure 1It is a schematic diagram of the process of the social network friend recommendation method based on heterogeneous graph neural network clustering of the present invention. DETAILED DESCRIPTION
[0014] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are 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.
[0015] See also Figure 1 The social network friend recommendation method based on heterogeneous graph neural network clustering provided by an embodiment of the present invention includes steps S1 to S5.
[0016] Step S1, reading user related information from a social network database, wherein the user related information includes user attribute data, user tweet content data and user group chat data, and obtaining a feature vector representation of user attributes, a feature vector representation of tweet content and a feature vector representation of group chat topics by preprocessing and feature extraction of user related information.
[0017] Wherein, step S1 specifically includes:
[0018] Step S1.1, reading user related information from a social network database, the user related information including user attribute data, tweets sent by the user and group chat topics joined by the user;
[0019] Step S1.2, converting the user attribute data in JSON format into structured data, constructing and extracting a user attribute feature vector therefrom, wherein the user attribute data includes categorical data and numerical data; the categorical data includes gender, location and occupation type; the numerical data includes account ID, age, number of fans, number of tweets sent, and number of group chats joined; for the categorical data, a categorical feature encoding method is used for processing to obtain categorical features; for the numerical data, numerical normalization is first performed, and then the numerical feature encoding method is used for encoding to obtain numerical features; the categorical features and the numerical features are horizontally spliced and fused to obtain a feature vector representation of the user attributes;
[0020] Step S1.3, based on the user's tweet content data, the user's tweet content data is processed using the term frequency-inverse document frequency method to extract a feature vector representation of the tweet content;
[0021] Wherein, step S1.3 specifically includes:
[0022] Calculate the frequency of words in tweet content data TF , the formula is:
[0023] ;
[0024] in, F Indicates the number of times a word appears in the tweet content data. M Represents the total number of words in the tweet content data;
[0025] Calculating Inverse Document Frequency IDF , the formula is:
[0026] ;
[0027] in, N Represents the total number of tweet content data, df Indicates the number of tweet content data containing the target word;
[0028] Calculate the importance of the target word in the user's tweet content data TI , the formula is:
[0029] ;
[0030] Select tweet content data TI The largest word is used as the keyword of the tweet content data, thereby obtaining a feature matrix of the user's tweet content data, wherein the feature vector of each tweet content data of the user in the feature matrix corresponds to each row vector of the feature matrix;
[0031] The dimension reduction method is used to reduce the dimension of the feature matrix of the user's tweet content data to obtain the feature vector representation of the tweet content.
[0032] Step S1.4, based on the user's group chat data, word bag embedding is used to convert the text data in the group chat data into vector form, and the feature vector representation of the group chat topic is extracted.
[0033] Step S2, based on the feature vector representation of user attributes, the feature vector representation of tweet content, and the feature vector representation of group chat topics, construct a social network heterogeneous graph with users, tweets, and group chats as nodes and the interaction relationships between the three as edges, and define relevant meta-paths to capture the semantic relationships between different types of nodes.
[0034] Wherein, step S2 specifically includes:
[0035] Step S2.1: Based on the feature vector representation of user attributes, the feature vector representation of tweet content, and the feature vector representation of group chat topics, a social network heterogeneous graph is constructed with users, tweets, and group chats as nodes and the interaction relationships between the three as edges. G ,G =( V , E ),in, V Represents a node, E Represents edge sets, heterogeneous graphs of social networks G Has a node type mapping function and an edge type mapping function , A and R Represent the predefined sets of node types and edge types respectively, where A ={ A i , A j , A k}, A i Indicates the user node type, A j Indicates the tweet node type, A k represents the group chat node type, and |A|+|R|>2, |A| represents the number of node types, and |R| represents the number of edge types;
[0036] Step S2.2, defining relevant meta-paths, including: user-tweet-user meta-path, representing that two users have forwarded the same tweet together; user-group chat-user meta-path, representing that two users have joined a group chat together.
[0037] Step S3, inputting the constructed social network heterogeneous graph into the heterogeneous graph neural network model to obtain the final embedding vector of the user node, wherein the heterogeneous graph neural network model includes a projection conversion module, a feature propagation module, a centrality embedding module and a subgraph learning module.
[0038] Wherein, step S3 specifically includes:
[0039] Step S3.1, since different node types may have unequal node feature dimensions. Therefore, after the constructed heterogeneous graph is fed into the heterogeneous graph neural network model designed by the present invention, a linear transformation specific to the node type is applied to project all node features into a latent vector with the same dimension. Specifically, in the projection transformation module, a linear transformation is used to project all node features into a latent vector with the same dimension to obtain a feature vector after node projection;
[0040] Step S3.2, in the feature propagation module, feature propagation is used to propagate the feature vector of the user node after projection to the two types of nodes, tweets and group chats, along the meta-path instance. For the node type set A Node in 1 v ,A 1={ A j , A k}, first aggregate the nodes v All meta path instances on A i The characteristics of the node type, then splice the node v The projected features are used to obtain nodes v The updated feature vector is expressed as follows:
[0041] ;
[0042] in, Is a node v The updated feature vector, Is a node v The projected eigenvector, Contains nodes v All meta path instances on A i A collection of nodes of type yes The total number of elements in , yes Midpoint u The projected eigenvector, Indicates splicing;
[0043] Step S3.3, in the centrality embedding module, based on all A i The updated feature vector of the node of the type is used to define the heterogeneous graph centrality, which is the number of times a node is covered by a meta-path instance. All covered nodes are calculated. v The number of instances of the meta path , and then calculate the node v The number of times all direct neighbors of are covered by the meta-path instance , the expression is:
[0044] ;
[0045] in, Is a node v The set of all direct neighbors of ;
[0046] They are and Assigning one-hot vectors and one-hot vector , then and Connect them and perform transformations on their respective node types to obtain the centrality embedding vector, expressed as:
[0047] ;
[0048] in, Is a node v The centrality embedding vector of is the node weighted transformation matrix;
[0049] Finally, and Combine to get the node v The final hidden vector , the expression is as follows:
[0050] ;
[0051] Step S3.4, the final hidden vectors of all nodes are sent to the subgraph learning module. Based on the definition of the local subgraph, a local subgraph based on the corresponding meta-path starting from the user node is generated, and then the importance of different neighbors is learned using the attention mechanism. v , in the local subgraph Measure the first and second order neighbor pairs of nodes respectively v The importance of
[0052] Setting Node u For Node v The first-order neighbor of node v and nodes u The importance of nodes It is expressed as:
[0053] ;
[0054] in, LeakyReLU represents the activation function, yes The parameterized attention vector of Is a node u The final hidden vector of
[0055] For nodes k , , express Previous Node v The node u The first-order neighbor set outside the node v and nodes k The importance of nodes , and then calculate the node v and nodes u The normalized weight coefficient between , the expression is:
[0056] ;
[0057] Finally, the node v exist The eigenvectors between the first-order neighbors on Through the node v The feature vectors of all first-order neighbors are aggregated according to the corresponding weight coefficients, and the expression is:
[0058] ;
[0059] in, is the Sigmoid activation function;
[0060] Setting Node w For Node v The second-order neighbors of nodes are learned using cosine similarity. w For Node v Contribution , the expression is:
[0061] ;
[0062] in, Is a node w The final hidden vector of represents the magnitude of a vector;
[0063] based on Calculate the node v and nodes w The normalized weight coefficient between , calculation principle and resemblance;
[0064] Then the node v exist The eigenvectors between the second-order neighbors of It is expressed as:
[0065] ;
[0066] In order to alleviate the differences caused by the heterogeneity of the network and stabilize the learning process, a multi-head attention mechanism is used. Specifically, the multi-head attention mechanism is used to obtain the feature vector representation of the node on the head, and the expression is:
[0067] ;
[0068] in, Indicates h Nodes on the attention head v The feature vector representation ofH represents the number of local subgraphs, Indicates parallel work, Indicates h Nodes on the attention head v and nodes x The normalized weight coefficient between Is a node x The final hidden vector of
[0069] Then use the following formula to solve the h The importance weight of each attention head :
[0070] ;
[0071] in, express The total number of nodes of the target type, The attention vector of the node representing the target type, and are the parameters to be learned, tanh represents the hyperbolic tangent function;
[0072] Use Softmax function to After normalization, the expression is as follows:
[0073] ;
[0074] in, represents the normalized importance weight, Indicates q The importance weight of each attention head;
[0075] Finally, for all nodes on the head v The feature vectors of the node are weighted summed to obtain v Heterogeneous graphs in social networks G The final embedding vector on :
[0076] .
[0077] In this embodiment, multiple loss functions are used to jointly optimize model parameters, the framework is trained using the stochastic gradient descent algorithm (SGD), and the learning rate is adjusted using ADAM. The model is trained by minimizing the cross entropy loss function and applying back propagation to optimize the parameters of all user nodes.
[0078] Specifically, the loss function of the heterogeneous graph neural network model is for:
[0079] ;
[0080] ;
[0081] ;
[0082] ;
[0083] in, is the similarity loss value within the community, is the difference loss between communities, is the regularization term, , , They are , , The weight coefficient of C represents the set of nodes in the community, is the indicator function, C v , C u Represents nodes in the community v ,node u ;when C v = C u hour, The value of is 1, otherwise it is 0; S represents the similarity measurement function, Representation Node u Heterogeneous graphs in social networks G The final embedding vector on C a express a The node collection of the community, C b express b The node collection of the community, represents the L2 norm, is the regularization coefficient.
[0084] Specifically, Used to maximize the similarity of nodes in the same community, Used to minimize the similarity between nodes in different communities, Used to improve the generalization ability of the model.
[0085] Step S4, using a cluster center selection method based on the density Gini coefficient to improve the K-means algorithm, and then based on the final embedding vector of the user node, using the improved K-means algorithm to complete the clustering of the user node.
[0086] Wherein, step S4 specifically includes:
[0087] Step S4.1, after obtaining the final embedding vectors of all user nodes, calculate The local density ,by Set the center to , The calculation method is:
[0088] ;
[0089] in, is a function of the density Gini coefficient estimate, yes arrive The Euclidean distance of Representation Node y Heterogeneous graphs in social networks G The final embedding vector on ;
[0090] in, The value of the density Gini coefficient D To determine, when D At maximum, the corresponding is the optimal radius value, D The calculation formula is expressed as:
[0091] ;
[0092] ;
[0093] in, Indicates m The local density of user nodes, Q express n The total density of user nodes;
[0094] Step S4.2, take the node with the largest local density as the first initial cluster center, calculate the distances from the remaining nodes to the first initial cluster center, select the node with the largest distance as the second initial cluster center, then calculate the sum of the distances from the remaining nodes to the first initial cluster center and the distances to the second initial cluster center, take the node with the largest sum of distances as the third initial cluster center, and iterate in sequence until the selected K Initial cluster centers;
[0095] Step S4.3, confirm K After initial clustering centers are obtained, the K-means algorithm is used to cluster all user nodes according to distance, and finally K The results of community division.
[0096] Step S5, based on the clustering results, a recommendation list is obtained using a similarity model, and then the corresponding social network data is obtained based on the final embedding vector of the user in the recommendation list to complete the friend recommendation task for the target user.
[0097] Wherein, step S5 specifically includes:
[0098] Step S5.1, analysis K The community division results are based on the characteristics and commonalities of the users in each cluster, and each community is labeled;
[0099] Step S5.2, determining the recommendation scope according to the community tag;
[0100] Step S5.3, in the recommended range, obtain the top users with the highest similarity to the target user according to the Euclidean distance similarity model. g users to form a recommendation list, and then according to the previous g The final embedding vector of each user obtains the corresponding social network data and finally completes the friend recommendation task for the target user.
[0101] In summary, according to the social network friend recommendation method based on heterogeneous graph neural network clustering provided by the present invention, in the heterogeneous graph neural network model of the present invention, the user's own attribute information and the interaction information between users are fully combined through the feature propagation module and the centrality embedding module, which solves the problem that most existing technologies ignore the potential connections between users; through the subgraph learning module, the similarity between user nodes and the importance of other types of nodes to user nodes are considered, so that more reasonable and effective learning of user nodes can be achieved to obtain a more realistic and accurate vector representation of the user in the network structure, which solves the problem of deviation in the existing technology when learning user vector representation; in addition, the present invention adopts a clustering center selection method based on the density Gini coefficient to improve the K-means algorithm, which can solve the problem of sensitivity of the initial clustering center and improve the accuracy of user clustering, thereby realizing accurate social network user community identification and solving the problem of low friend recommendation accuracy.
[0102] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner.
[0103] Although the embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the claims and their equivalents.
Claims
1. A social network friend recommendation method based on heterogeneous graph neural network clustering, characterized in that: It includes steps S1 to S5: Step S1, reading user related information from a social network database, the user related information including user attribute data, user tweet content data and user group chat data, and obtaining a feature vector representation of user attributes, a feature vector representation of tweet content and a feature vector representation of group chat topics by preprocessing and feature extraction of user related information; Step S2, based on the feature vector representation of user attributes, the feature vector representation of tweet content, and the feature vector representation of group chat topics, a social network heterogeneous graph is constructed with users, tweets, and group chats as nodes and the interaction relationships between the three as edges, and relevant meta-paths are defined to capture the semantic relationships between nodes of different types; Step S3, inputting the constructed social network heterogeneous graph into the heterogeneous graph neural network model to obtain the final embedding vector of the user node, wherein the heterogeneous graph neural network model includes a projection conversion module, a feature propagation module, a centrality embedding module and a subgraph learning module; Step S4, using a cluster center selection method based on the density Gini coefficient to improve the K-means algorithm, and then using the improved K-means algorithm to complete clustering of user nodes based on the final embedding vector of the user node; Step S5, according to the clustering result, a recommendation list is obtained using a similarity model, and then the corresponding social network data is obtained according to the final embedding vector of the user in the recommendation list to complete the friend recommendation task for the target user; Step S2 specifically includes: Step S2.1: Based on the feature vector representation of user attributes, the feature vector representation of tweet content, and the feature vector representation of group chat topics, a social network heterogeneous graph is constructed with users, tweets, and group chats as nodes and the interaction relationships between the three as edges. G , G =( V , E ),in, V Represents a node, E Represents edge sets, heterogeneous graphs of social networks G Has a node type mapping function and an edge type mapping function , A and R Represent the predefined sets of node types and edge types respectively, where A ={ A i , A j , A k }, A i Indicates the user node type, A j Indicates the tweet node type, A k represents the group chat node type, and |A|+|R|> 2, |A| represents the number of node types, and |R| represents the number of edge types; Step S2.2, defining relevant meta-paths, including: user-tweet-user meta-path, which means that two users have forwarded the same tweet together; user-group chat-user meta-path, which means that two users have joined a group chat together; Step S3 specifically includes: Step S3.1, in the projection transformation module, linear transformation is used to project all node features into a latent vector with the same dimension to obtain a feature vector of the node after projection; Step S3.2, in the feature propagation module, feature propagation is used to propagate the feature vector of the user node after projection to the two types of nodes, tweets and group chats, along the meta-path instance. For the node type set A Node in 1 v , A 1={ A j , A k }, first aggregate the nodes v All meta path instances on A i The characteristics of the node type, then splice the node v The projected features are used to obtain nodes v The updated feature vector is expressed as follows: ; in, Is a node v The updated feature vector, Is a node v The projected eigenvector, Contains nodes v All meta path instances on A i A collection of nodes of type yes The total number of elements in , yes Midpoint u The projected eigenvector, Indicates splicing; Step S3.3, in the centrality embedding module, based on all A i The updated feature vector of the node of the type is used to define the heterogeneous graph centrality, which is the number of times a node is covered by a meta-path instance. All covered nodes are calculated. v The number of instances of the meta path , and then calculate the node v The number of times all direct neighbors of are covered by the meta-path instance , the expression is: ; in, Is a node v The set of all direct neighbors of ; They are and Assigning one-hot vectors and one-hot vector , then and Connect them and perform transformations on their respective node types to obtain the centrality embedding vector, expressed as: ; in, Is a node v The centrality embedding vector of is the node weighted transformation matrix; Finally, and Combine to get the node v The final hidden vector , the expression is as follows: ; Step S3.4, the final hidden vectors of all nodes are sent to the subgraph learning module. Based on the definition of the local subgraph, a local subgraph based on the corresponding meta-path starting from the user node is generated, and then the importance of different neighbors is learned using the attention mechanism. v , in the local subgraph Measure the first and second order neighbor pairs of nodes respectively v The importance of Setting Node u For Node v The first-order neighbor of node v and nodes u The importance of nodes It is expressed as: ; in, LeakyReLU represents the activation function, yes The parameterized attention vector of Is a node u The final hidden vector of For nodes k , , express Previous Node v The node u The first-order neighbor set outside the node v and nodes k The importance of nodes , and then calculate the node v and nodes u The normalized weight coefficient between , the expression is: ; Finally, the node v exist The eigenvectors between the first-order neighbors on Through the node v The feature vectors of all first-order neighbors are aggregated according to the corresponding weight coefficients, and the expression is: ; in, is the Sigmoid activation function; Setting Node w For Node v The second-order neighbors of nodes are learned using cosine similarity. w For Node v Contribution , the expression is: ; in, Is a node w The final hidden vector of represents the magnitude of a vector; based on Calculate the node v and nodes w The normalized weight coefficient between ; Then the node v exist The eigenvectors between the second-order neighbors of It is expressed as: ; Then, the multi-head attention mechanism is used to obtain the feature vector representation of the node on the head, which is expressed as: ; in, Indicates h Nodes on the attention head v The feature vector representation of H represents the number of local subgraphs, Indicates parallel work, Indicates h Nodes on the attention head v and nodes x The normalized weight coefficient between Is a node x The final hidden vector of Then use the following formula to solve the h The importance weight of each attention head : ; in, express The total number of nodes of the target type, The attention vector of the node representing the target type, and are the parameters to be learned, tanh represents the hyperbolic tangent function; Use Softmax function to After normalization, the expression is as follows: ; in, represents the normalized importance weight, Indicates q The importance weight of each attention head; Finally, for all nodes on the head v The feature vectors of the node are weighted summed to obtain v Heterogeneous graphs in social networks G The final embedding vector on : 。 2. The social network friend recommendation method based on heterogeneous graph neural network clustering according to claim 1, characterized in that: Step S1 specifically includes: Step S1.1, reading user related information from a social network database, the user related information including user attribute data, tweets sent by the user and group chat topics joined by the user; Step S1.2, converting the user attribute data in JSON format into structured data, constructing and extracting a user attribute feature vector therefrom, wherein the user attribute data includes categorical data and numerical data; the categorical data includes gender, location and occupation type; the numerical data includes account ID, age, number of fans, number of tweets sent, and number of group chats joined; for the categorical data, a categorical feature encoding method is used for processing to obtain categorical features; for the numerical data, numerical normalization is first performed, and then the numerical feature encoding method is used for encoding to obtain numerical features; the categorical features and the numerical features are horizontally spliced and fused to obtain a feature vector representation of the user attributes; Step S1.3, based on the user's tweet content data, the user's tweet content data is processed using the term frequency-inverse document frequency method to extract a feature vector representation of the tweet content; Step S1.4, based on the user's group chat data, word bag embedding is used to convert the text data in the group chat data into vector form, and the feature vector representation of the group chat topic is extracted.
3. The social network friend recommendation method based on heterogeneous graph neural network clustering according to claim 2 is characterized in that: Step S1.3 specifically includes: Calculate the frequency of words in tweet content data TF , the formula is: ; in, F Indicates the number of times a word appears in the tweet content data. M Represents the total number of words in the tweet content data; Calculating Inverse Document Frequency IDF , the formula is: ; in, N Represents the total number of tweet content data, df Indicates the number of tweet content data containing the target word; Calculate the importance of the target word in the user's tweet content data TI , the formula is: ; Select tweet content data TI The largest word is used as the keyword of the tweet content data, thereby obtaining a feature matrix of the user's tweet content data, wherein the feature vector of each tweet content data of the user in the feature matrix corresponds to each row vector of the feature matrix; The dimension reduction method is used to reduce the dimension of the feature matrix of the user's tweet content data to obtain the feature vector representation of the tweet content.
4. The social network friend recommendation method based on heterogeneous graph neural network clustering according to claim 1, characterized in that: The loss function of the heterogeneous graph neural network model for: ; ; ; ; in, is the similarity loss value within the community, is the difference loss between communities, is the regularization term, , , They are , , The weight coefficient of C represents the set of nodes in the community, is the indicator function, C v , C u Represents nodes in the community v ,node u , S represents the similarity measurement function, Representation Node u Heterogeneous graphs in social networks G The final embedding vector on C a express a The node collection of the community, C b express b The node collection of the community, represents the L2 norm, is the regularization coefficient.
5. The social network friend recommendation method based on heterogeneous graph neural network clustering according to claim 4 is characterized in that: Step S4 specifically includes: Step S4.1, after obtaining the final embedding vectors of all user nodes, calculate The local density ,by Set the center to , The calculation method is: ; in, is a function of the density Gini coefficient estimate, yes arrive The Euclidean distance of Representation Node y Heterogeneous graphs in social networks G The final embedding vector on ; in, The value of the density Gini coefficient D To determine, when D At maximum, the corresponding is the optimal radius value, D The calculation formula is expressed as: ; ; in, Indicates m The local density of user nodes, Q express n The total density of user nodes; Step S4.2, take the node with the largest local density as the first initial cluster center, calculate the distances from the remaining nodes to the first initial cluster center, select the node with the largest distance as the second initial cluster center, then calculate the sum of the distances from the remaining nodes to the first initial cluster center and the distances to the second initial cluster center, take the node with the largest sum of distances as the third initial cluster center, and iterate in sequence until the selected K Initial cluster centers; Step S4.3, confirm K After initial clustering centers are obtained, the K-means algorithm is used to cluster all user nodes according to distance, and finally K The results of community division.
6. The social network friend recommendation method based on heterogeneous graph neural network clustering according to claim 5, characterized in that: Step S5 specifically includes: Step S5.1, analysis K The community division results are based on the characteristics and commonalities of the users in each cluster, and each community is labeled; Step S5.2, determining the recommendation scope according to the community tag; Step S5.3, in the recommended range, obtain the top users with the highest similarity to the target user according to the Euclidean distance similarity model. g users to form a recommendation list, and then according to the previous g The final embedding vector of each user obtains the corresponding social network data and finally completes the friend recommendation task for the target user.
Citation Information
Patent Citations
Reply generation technology based on user portraits and context inference
CN110457445A
Social recommendation method based on multi-feature heterogeneous graph neural network
CN113254803A