Social network community discovery method and device without community base, and electronic device
By employing a community cardinality-free social network community detection method, which utilizes a social network encoder and a structural graph clustering algorithm, the problem of relying on manually setting the community cardinality in traditional methods is solved, enabling wider application and higher accuracy in community detection.
Patent Information
- Application Number
- CN202310452669.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-25
- Publication Date
- 2026-02-17
- Estimated Expiration
- 2043-04-25
AI Technical Summary
Traditional social network community discovery methods rely on a manually set community base, making them difficult to apply in practice and difficult to reproduce.
We employ a community cardinality-free approach by constructing a social network encoder, training it using an unsupervised method, mapping vertices to Euclidean space, calculating vertex similarity, constructing training samples with pseudo-labels, training a social network community relationship prediction model using a binary cross-entropy loss function, and obtaining community detection results through a structural graph clustering algorithm.
It eliminates the need for manually setting the community base, has a wide range of applications, a clear process, simplifies model reproduction and migration, and improves the accuracy of community discovery and the effectiveness of structure graph construction.
Smart Images

Figure CN116775942B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of graph data mining technology under big data, and in particular to a method, apparatus, and electronic device for discovering social network communities without a community base. Background Technology
[0002] Community detection has emerged alongside the development of social networks and has been widely applied in fields such as recommendation systems, protein discovery, and risk control. However, most traditional community detection methods can only handle simple graph structure information. In social networks, users are often accompanied by personal configuration information, including nicknames, genders, and personal signatures, which are attached to the graph structure to form vertex attributes. Traditional methods have difficulty handling high-dimensional vertex attribute information. Graph neural networks, as a special form of neural networks on graphs, can extract and discover features and patterns in social network data, and while reducing the dimensionality of vertex attributes, they can map vertices with similar patterns to nearby positions in Euclidean space. Therefore, many scholars at home and abroad have applied graph neural networks to community detection in social networks and designed a variety of representation model training methods to improve the accuracy of community detection. However, these works still have certain limitations: (1) they rely on artificially set community cardinality, which can only be accurately known after community detection is completed, so they are difficult to apply in practice; (2) some works have relatively complex overall methods and the model is difficult to reproduce. Summary of the Invention
[0003] The purpose of this application is to provide a method, apparatus, and electronic device for discovering communities in social networks without a community base, so as to solve the technical problem of relying on manually defined community bases in related technologies.
[0004] According to a first aspect of the embodiments of this application, a method for discovering communities in a social network without a community base is provided, comprising:
[0005] Collect social network data and construct a social network with users as vertices, user relationships as edges, and user personal information as vertex attributes;
[0006] Construct a social network encoder and train it using any unsupervised method;
[0007] The vertex representation matrix is obtained by mapping the vertices of the social network to Euclidean space through a trained encoder.
[0008] Calculate the similarity between each pair of vertices based on the vertex representation matrix;
[0009] Based on the similarity, construct training samples with pseudo-labels;
[0010] A social network community relationship prediction model is constructed, and the social network community relationship prediction model is trained using the binary cross-entropy loss function based on the training samples.
[0011] Based on the prediction results of the social network community relationship prediction model, a new structure graph is constructed;
[0012] The new structural graph is input into a structural graph clustering algorithm to obtain the final community detection results.
[0013] According to a second aspect of the embodiments of this application, a social network community discovery device without a community base is provided, comprising:
[0014] The data collection module is used to collect social network data and construct a social network with users as vertices, user relationships as edges, and user personal information as vertex attributes.
[0015] The first building module is used to build a social network encoder, which is trained using any unsupervised method.
[0016] The mapping module is used to map the vertices of the social network to Euclidean space through a trained encoder to obtain the vertex representation matrix.
[0017] The first calculation module is used to calculate the similarity between each pair of vertices based on the vertex representation matrix;
[0018] The second construction module is used to construct training samples with pseudo-labels based on the similarity.
[0019] The third construction module is used to construct a social network community relationship prediction model, which is trained based on the training samples using a binary cross-entropy loss function.
[0020] The fourth construction module is used to construct a new structure diagram based on the prediction results of the social network community relationship prediction model;
[0021] The second calculation module is used to input the new structure graph into the structure graph clustering algorithm to obtain the final community detection result.
[0022] According to a third aspect of the embodiments of this application, an electronic device is provided, comprising:
[0023] One or more processors;
[0024] Memory, used to store one or more programs;
[0025] When the one or more programs are executed by the one or more processors, the one or more processors perform the method as described in the first aspect.
[0026] Compared with existing technologies, the social network community discovery method without a community base in this invention has the following beneficial effects:
[0027] This method transforms the community discovery problem into a vertex-to-community relationship prediction problem, eliminating the need to manually set community cardinality parameters and enabling the model to have a wider range of applications. Furthermore, this method does not limit the representation learning method, allowing for further optimization of the structure graph construction effect and community discovery accuracy using state-of-the-art representation models. The invention process is clear and simple, facilitating model reproducibility and transferability. Attached Figure Description
[0028] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0029] Figure 1 This is a flowchart illustrating a method for discovering communities in a social network without a community base, as shown in an embodiment of the present invention.
[0030] Figure 2 This is a framework diagram illustrating a social network community discovery method without a community base, as shown in an embodiment of the present invention.
[0031] Figure 3 This is a comparison chart of the community detection performance of an embodiment of the present invention with other methods on four datasets.
[0032] Figure 4 This is a time efficiency diagram of degree-protected sampling on six datasets, as shown in an embodiment of the present invention.
[0033] Figure 5 This is a block diagram of a social network community discovery device without a community base, as shown in an embodiment of the present invention. Detailed Implementation
[0034] Embodiments of the present invention are described in detail below, examples of which are illustrated in the accompanying drawings. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and should not be construed as limiting the present invention.
[0035] Figure 1 This is a flowchart illustrating a community discovery method for social networks without a community cardinality, according to an exemplary embodiment, as shown below. Figure 1 As shown, the method may include the following steps:
[0036] S1: Collect social network data and construct a social network with users as vertices, user relationships as edges, and user personal information as vertex attributes;
[0037] S2: Construct a social network encoder and train the encoder using any unsupervised method;
[0038] S3: The vertex representation matrix of the social network is obtained by mapping the vertices of the social network to Euclidean space through the trained encoder.
[0039] S4: Calculate the similarity between each pair of vertices based on the vertex representation matrix;
[0040] S5: Based on the aforementioned similarity, construct training samples with pseudo-labels;
[0041] S6: Construct a social network community relationship prediction model, and train the social network community relationship prediction model using the binary cross-entropy loss function based on the training samples;
[0042] S7: Construct a new structure diagram based on the prediction results of the social network community relationship prediction model;
[0043] S8: Input the new structure graph into the structure graph clustering algorithm to obtain the final community detection result.
[0044] As can be seen from the above embodiments, this application transforms the community discovery problem into a vertex-to-community relationship prediction problem, eliminating the need to manually set community cardinality parameters and enabling the model to have a wider range of applications; this method does not require limiting the representation learning method, thus enabling the use of state-of-the-art representation models to further optimize the structure graph construction effect and community discovery accuracy; the invention method has a clear and simple process, which is conducive to model reproduction and transfer.
[0045] In the specific implementation of S1: collect social network data and construct a social network with users as vertices, user relationships as edges, and user personal information as vertex attributes;
[0046] Specifically, publicly available datasets were collected from literature and previous research to obtain the social network structure, where vertices represent users and edges represent the communication relationships between users. User personal information was anonymized and converted into 0 / 1 vectors using one-hot encoding for easier subsequent numerical calculations.
[0047] In the specific implementation of S2: constructing a social network encoder and training the encoder using any unsupervised method may include the following steps:
[0048] S21: Construct an encoder consisting of a two-layer graph convolutional network;
[0049] Specifically, an encoder is constructed using encapsulated graph convolutional network layers. The input of the first graph convolutional layer is the graph structure of the social network and the vertex attribute matrix, and the output is the vertex representation matrix. The input of the second graph convolutional layer is the vertex representation matrix output by the first graph convolutional layer and the graph structure of the social network, and the output is the final vertex representation matrix.
[0050] S22: Input the adjacency matrix A and vertex attribute matrix X of the social network into the encoder to obtain the vertex representation matrix Z;
[0051] Specifically, for the l-th graph convolutional layer, in This represents the adjacency matrix after adding self-loops. Depth matrix, Z (l) Z (l-1) Let represent the outputs of the l-th and (l-1)-th graph convolutional layers, respectively, and σ represent the nonlinear function.
[0052] S23: Calculate and reconstruct the adjacency matrix based on the representation matrix;
[0053] Specifically, based on the encoder output Z, the reconstructed adjacency matrix A′=σ(ZZ) is calculated. T ), where Z T Let Z denote the transpose of Z, and σ denote the nonlinear function.
[0054] S24: Calculate the loss function based on the reconstructed adjacency matrix;
[0055] Specifically, the loss function is:
[0056] Where A ij and A′ ij Let represent the values of the adjacency matrix and the reconstructed adjacency matrix in the i-th row and j-th column, respectively, and n represent the number of vertices in the social network.
[0057] S25: Use the Adam optimizer to optimize the encoder parameters using gradient descent based on the loss function;
[0058] Specifically, PyTorch's automatic differentiation mechanism and Adam optimizer are used to iteratively update the network layer parameters in the encoder and decoder.
[0059] S26: Repeat steps S22-S25 until the preset number of training generations is reached.
[0060] Specifically, a maximum number of training generations is preset, and the complete steps S22-S25 are performed for each generation to ensure that the encoder is fully updated.
[0061] In the specific implementation of S3: the similarity between each pair of vertices is calculated based on the vertex representation matrix;
[0062] Specifically, based on the vertex representation matrix Z, the similarity S between each pair of vertices is calculated:
[0063] S=(ZZ T ) / ||Z|| 2
[0064] The superscript T denotes the transpose of the matrix, and ||Z|| denotes the modulus of matrix Z. A higher similarity indicates a greater probability that two users reside in the same community, and vice versa.
[0065] In the specific implementation of S4: Based on the similarity, training samples with pseudo-labels are constructed; this step may include the following steps:
[0066] S41: Flatten the similarity scores to one dimension and sort them from largest to smallest;
[0067] Specifically, the two-dimensional similarity matrix is expanded into one dimension by rows, and then sorted from largest to smallest using an arbitrary sorting algorithm to facilitate the subsequent partitioning of the training set samples.
[0068] S42: Obtain the similarity index of each pair of vertices according to the sorting;
[0069] Specifically, the index of the vertex pair in the sorted sequence is assigned to the vertex pair.
[0070] S43: Take the vertex pairs with the first p% similarity index as positive samples and label them with pseudo-label 1;
[0071] Specifically, the top p% of vertex pairs are selected as positive samples, with p% ranging from 0.1% to 1%, to ensure that positive samples have a high probability of being located in the same community.
[0072] S44: Take the vertex pairs with the similarity index in the last q% as negative samples and label them with pseudo-label 0;
[0073] Specifically, the last q% of vertex pairs are taken as negative samples, with q% ranging from 30% to 90%, to ensure that negative samples have a high probability of being located in different communities.
[0074] S45: Extract vertex representation vectors from the vertex representation matrix Z based on the positive and negative samples; specifically, based on the indices of the positive and negative sample vertex pairs in the flattening sequence, let 'o' be... i Calculate its index in the similarity matrix, i.e. (o i / / N,o i %N) where / / represents integer division and % represents modulo operation. The vertex representation vector is extracted from the vertex representation matrix Z, i.e., Z[o i / / N,] and Z[o i %N,].
[0075] S46: Calculate the dot product between the vertex representation vectors to obtain the vertex pair representation vector;
[0076] Specifically, based on the extracted vertex representation vector Z[oi / / N,] and Z[o i %N,], calculate the vertex pair representation vector, i.e., Z[o i / / N,]·Z[o i %N,].
[0077] S47: Construct training samples based on the vertex pair representation vector and the pseudo-label. A tuple of <vertex pair representation vector, pseudo-label> constitutes a training sample.
[0078] Specifically, training samples are constructed using the vertex pair representation vectors and pseudo-labels for training the subsequent community relationship prediction model.
[0079] S48: Standardize the vertex pair representation vectors in the training samples to a data distribution with a mean of 0 and a variance of 1 to ensure stable training of the community relationship prediction model.
[0080] Specifically, assume that all the vertex pair representation vectors constitute the vertex pair representation matrix Z′. Calculate the mean ∑ and variance V of each column in Z′, then the standardized vertex pair representation matrix is (Z′-∑) / V.
[0081] In the specific implementation of S5: constructing a social network community relationship prediction model, and training the social network community relationship prediction model using the binary cross-entropy loss function based on the training samples; may include the following steps:
[0082] S51: Construct a community relationship prediction model consisting of two fully connected layers;
[0083] Specifically, a community relationship prediction model consisting of two fully connected layers is constructed, with the vertex pair representation vector as input and the probability value of belonging to the same community as output.
[0084] S52: Input the vertex pair representation vector into the community relationship prediction model to obtain the predicted probability that two users belong to the same community;
[0085] Specifically, the vertex pair representation vectors in the training samples are input into the community relationship prediction model to obtain the predicted probability that two users belong to the same community.
[0086] S53: Calculate the binary cross-entropy loss function based on the predicted probability and the pseudo-label;
[0087] Specifically, assuming the predicted probability is The pseudo-label is y i Then the binary cross-entropy loss function is
[0088] S54: Optimize the model parameters using gradient descent based on the binary cross-entropy loss function.
[0089] Specifically, the parameters of the community relationship prediction model are iteratively updated using PyTorch's automatic differentiation mechanism and Adam optimizer.
[0090] In the specific implementation of S6: based on the prediction results of the social network community relationship prediction model, a new structural graph is constructed, including the following steps:
[0091] S61: Standardize the representation vectors of all vertex pairs, including the training samples, to a data distribution with a mean of 0 and a variance of 1.
[0092] Specifically, in accordance with the standardization method for the training samples, all vertex pair representation vectors are standardized, that is, the mean and variance are calculated column by column, and then the mean is subtracted from the representation vector and the variance is divided to obtain the standardized vertex pair representation vector.
[0093] S62: Input the vertex pair representation vector into the community relationship prediction model to obtain the predicted probability;
[0094] Specifically, the standardized vertex pair representation vector is output to the community relationship prediction model to obtain the community relationship prediction probability output by the model.
[0095] S63: Construct a new structural graph whose vertex set is the same as the vertex set of the social network and whose edge set is empty;
[0096] Specifically, a new structural graph is initialized, whose vertex set is the same as that of the social network, whose edge set is empty, and which no longer contains vertex attributes.
[0097] S64: Connect the top edge of the vertex pairs whose predicted probability is greater than p0 and insert them into the structure graph.
[0098] Specifically, p0 can be 0.5, where the predicted probability of a vertex pair is greater than p0. Vertex pairs with a higher probability of being in the same community are connected to the top edge, and vice versa.
[0099] In the specific implementation of S6: inputting the new structure graph into the structure graph clustering algorithm to obtain the final community detection result may include the following steps:
[0100] S71: Set a sampling rate r, randomly delete 1-r% of the edges in the structure graph to obtain the clipped structure graph;
[0101] Specifically, the sampling rate r is determined by the actual size requirements of the control structure diagram and takes a value between 0 and 100. Assuming that the connected structure diagram has m edges, first label the m edges with an index from 1 to m, then randomly shuffle the index sequence, and finally take the edges corresponding to the first m (1-r%) indexes, which are the edges to be retained.
[0102] S72: Initialize each vertex in the structure graph into a separate community to obtain the initial community label;
[0103] Specifically, let g(v) be the community label of any vertex v, then initially g(v) = v.
[0104] S73: Calculate the current modularity based on the community tags:
[0105] Specifically, the formula for calculating the modularity Q is as follows:
[0106]
[0107] Where m represents the number of edges in the social network, g(v) and g(w) represent the community labels of vertices v and w, respectively, and A vw d represents the value of the adjacency matrix A in the v-th row and w-th column. v and d w Let v and w represent the degrees of vertex v and vertex w in the social network, respectively.
[0108] S74: For any vertex in the structure graph, calculate the modularity Q′ after modifying its community label to the labels of its neighboring vertices;
[0109] Specifically, assuming the modified community label of any vertex v is g′(v), then the new module degree
[0110] S75: For any vertex in the structure graph, modify its community label to the community label that maximizes the modularity growth Q′-Q;
[0111] Specifically, for any vertex v, examine the community labels of all its neighboring vertices, try to modify the community label of v to the community label of each neighboring vertex, and calculate the change in modularity Q′-Q for each. Finally, take the community label that makes the largest change as the new community label of v.
[0112] S76: Aggregate vertices with the same community label into a new vertex;
[0113] Specifically, after completing the operation of modifying the community label, examine all vertices with the same community label and treat their set as a new set of vertices.
[0114] S77: Aggregate the edges within the original community into self-loops on the new vertex, aggregate the edges between the original communities into edges between the new vertices, and mark the number of the original edges on the new edges as edge weights.
[0115] Specifically, the number of edges between vertices with the same community label and the number of edges between vertices with different community labels are counted. Edges within a community are treated as new self-loops connecting a vertex to itself, and the number of edges is used as the weight of the self-loop; edges between communities are treated as new edges connecting vertices, and the number of edges is used as the weight of the new edges.
[0116] S78: Repeat steps S73-S77 until the modularity increase Q′-Q is less than a specific threshold;
[0117] Specifically, a threshold for modularity growth is preset, typically set to 0.001 or a smaller decimal. Execution stops when the modularity growth caused by modifying community tags fails to exceed this threshold.
[0118] S79: Output the converged community labels as the community discovery results.
[0119] Specifically, when the above steps stop executing, the community labels of all vertices in the current state are output as the final community discovery result.
[0120] In this embodiment, parameters such as Adjusted Mutual Information (AMI) and Adjusted Rand Index (ARI) are used to evaluate the accuracy of community detection. The social network datasets used in the experiment are shown in Table 1, which include three types: citations, hyperlinks, and items.
[0121] Table 1: Experimental Dataset
[0122]
[0123] The comparison algorithms are shown in Table 2 and Figure 3As shown, this includes commonly used clustering algorithms such as K-means, spectral clustering (SC), similarity propagation algorithm (AP), hierarchical clustering algorithm (HCA), density clustering algorithm (HDBSCAN), mean shift algorithm (MS), as well as the original Louvain algorithm, Leiden algorithm, and the variant I-Louvain algorithm. It also includes structural graph construction methods such as kNN, graph autoencoders, AGE, and SUBLIME. Table 2 shows that, compared to traditional clustering algorithms that require secondary dimensionality reduction of vertex representations, which not only increases time overhead but also loses information from the original representations, the DLouvain and DLeiden algorithms proposed in this invention can directly construct structural graphs from the original representations, thus achieving higher community detection accuracy. Figure 3 In contrast to existing kNN-type methods (kNN and SUBLIME), which enforce a fixed number of edges per vertex, the algorithm proposed in this invention does not restrict the number of edges connected to each vertex, thus offering greater flexibility and accuracy. Compared to AGE's use of a cosine similarity function as a classifier, this invention employs a fully connected layer network capable of fitting any continuous function as the classifier, resulting in stronger classification performance, more accurate generated structure graphs, and consequently, higher accuracy in community detection.
[0124] Table 2: Community detection results for each method on six datasets
[0125]
[0126] In this embodiment, the generated structural diagram of the model is trimmed. The time saved by the trimmed structural diagram is as follows: Figure 4 As shown, compared to directly performing community detection (Louvain-full) on the structure graph generated by the model, the pruned structure graph (Louvain-s) significantly reduces the size of the edge set while retaining the necessary community information, thus saving approximately one order of magnitude of time. Furthermore, the overhead of the pruning process (Sampling) is almost negligible compared to the overhead of community detection. This demonstrates that pruning the structure graph is beneficial.
[0127] Corresponding to the aforementioned embodiments of the social network community discovery method without a community base, this application also provides embodiments of an information display device.
[0128] Figure 5 This is a block diagram illustrating a community discovery device for a social network without a community cardinality, according to an exemplary embodiment. (Refer to...) Figure 5 The device includes:
[0129] The data collection module 1 is used to collect social network data and construct a social network with users as vertices, user relationships as edges, and user personal information as vertex attributes.
[0130] The first building module 2 is used to build a social network encoder, which is trained using any unsupervised method.
[0131] Mapping module 3 is used to map the vertices of the social network to Euclidean space through a trained encoder to obtain the vertex representation matrix;
[0132] The first calculation module 4 is used to calculate the similarity between each pair of vertices based on the vertex representation matrix;
[0133] The second construction module 5 is used to construct training samples with pseudo-labels based on the similarity.
[0134] The third construction module 6 is used to construct a social network community relationship prediction model, and the social network community relationship prediction model is trained based on the training samples using the binary cross-entropy loss function.
[0135] The fourth construction module 7 is used to construct a new structural diagram based on the prediction results of the social network community relationship prediction model;
[0136] The second calculation module 8 is used to input the new structure graph into the structure graph clustering algorithm to obtain the final community detection result.
[0137] Regarding the apparatus in the above embodiments, the specific manner in which each module performs its operation has been described in detail in the embodiments related to the method, and will not be elaborated upon here.
[0138] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can be referred to in the description of the method embodiments. The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this application according to actual needs. Those skilled in the art can understand and implement this without creative effort.
[0139] Accordingly, this application also provides an information display device, comprising: a processor; and a memory for storing processor-executable instructions; wherein the processor is configured to:
[0140] Accordingly, this application also provides an electronic device, including: one or more processors; a memory for storing one or more programs; when the one or more programs are executed by the one or more processors, the one or more processors implement the social network community discovery method without community cardinality as described above.
[0141] Accordingly, this application also provides a computer-readable storage medium storing computer instructions that, when executed by a processor, implement the social network community discovery method without community cardinality as described above.
[0142] The above description represents the preferred embodiments of the present invention. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principles of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.
Claims
1. A method for discovering communities in social networks without a community base, characterized in that, include: Collect social network data and construct a social network with users as vertices, user relationships as edges, and user personal information as vertex attributes; Construct a social network encoder and train it using any unsupervised method; The vertex representation matrix is obtained by mapping the vertices of the social network to Euclidean space through a trained encoder. Calculate the similarity between each pair of vertices based on the vertex representation matrix; Based on the similarity, construct training samples with pseudo-labels; A social network community relationship prediction model is constructed, and the social network community relationship prediction model is trained using the binary cross-entropy loss function based on the training samples. Based on the prediction results of the social network community relationship prediction model, a new structure graph is constructed; The new structural graph is input into a structural graph clustering algorithm to obtain the final community detection result; The process of constructing training samples with pseudo-labels based on the similarity includes the following steps: Flatten the similarity scores to one dimension and sort them from largest to smallest; The similarity index of each pair of vertices is obtained based on the sorting. The vertex pairs with the highest similarity index in the first p% are taken as positive samples and labeled with pseudo-label 1; The vertex pairs with similarity indices in the last q% are taken as negative samples and labeled with pseudo-label 0, where q is much larger than p; Based on the positive and negative samples, extract the vertex representation vector from the vertex representation matrix Z; Calculate the dot product between the vertex representation vectors to obtain the vertex pair representation vector; Training samples are constructed based on the vertex pair representation vector and the pseudo-label. A tuple of <vertex pair representation vector, pseudo-label> constitutes a training sample. The vertex pair representation vectors in the training samples are standardized to a data distribution with a mean of 0 and a variance of 1 to ensure stable training of the community relationship prediction model; The process of constructing a social network community relationship prediction model, which is trained using a binary cross-entropy loss function based on the training samples, includes the following steps: Construct a community relationship prediction model consisting of two fully connected layers; Input the vertex pair representation vector into the community relationship prediction model to obtain the predicted probability that two users belong to the same community; Calculate the binary cross-entropy loss function based on the predicted probability and the pseudo-label; The model parameters are optimized using gradient descent based on the binary cross-entropy loss function.
2. The method for discovering social networks without a community base as described in claim 1, characterized in that, Construct a social network encoder and train it using any unsupervised method, including the following steps: S21: Construct an encoder consisting of a two-layer graph convolutional network; S22: Input the adjacency matrix A and vertex attribute matrix X of the social network into the encoder to obtain the vertex representation matrix Z; S23: Calculate and reconstruct the adjacency matrix based on the representation matrix; S24: Calculate the loss function based on the reconstructed adjacency matrix; S25: Use the Adam optimizer to optimize the encoder parameters using gradient descent based on the loss function; S26: Repeat steps S22-S25 until the preset number of training generations is reached.
3. The method according to claim 2, characterized in that, The loss function is: ; in and Let represent the values of the adjacency matrix and the reconstructed adjacency matrix in the i-th row and j-th column, respectively, and n represent the number of vertices in the social network.
4. The method according to claim 1, characterized in that, Based on the vertex representation matrix, the similarity between each pair of vertices is calculated, including the following steps: Based on the vertex representation matrix Z, calculate the similarity S between each pair of vertices: ; The superscript T denotes the transpose of the matrix. Let Z represent the modulus of matrix Z; the greater the similarity, the greater the probability that two users are in the same community, and vice versa.
5. The method according to claim 1, characterized in that, Based on the prediction results of the social network community relationship prediction model, a new structure graph is constructed, including the following steps: Standardize the representation vectors of all vertex pairs, including the training samples, to a data distribution with a mean of 0 and a variance of 1. The vertex pair representation vector is input into the community relationship prediction model to obtain the predicted probability; Construct a new structural graph whose vertex set is the same as that of the social network, and whose edge set is empty; Connect the vertices whose predicted probability is greater than p0 to the top edge and insert them into the structure graph.
6. The method according to claim 1, characterized in that, The new structural graph is input into a structural graph clustering algorithm to obtain the final community detection result, including the following steps: S71: Set a sampling rate r, randomly delete 1-r% of the edges in the structure graph to obtain the clipped structure graph; S72: Initialize each vertex in the structure graph into a separate community to obtain the initial community label; S73: Calculate the current modularity based on the community tags: ; Where m represents the number of edges in the social network, g(v) and g(w) represent the community labels of vertices v and w, respectively, and A vw d represents the value of the adjacency matrix A in the v-th row and w-th column. v and d w Let v and w represent the degrees of vertex v and vertex w in the social network, respectively. S74: For any vertex in the structure graph, calculate the modularity after modifying its community label to the labels of its neighboring vertices. ; S75: For any vertex in the structure graph, modify its community label to increase its modularity. The largest community tag; S76: Aggregate vertices with the same community label into a new vertex; S77: Aggregate the edges within the original community into self-loops on the new vertex, aggregate the edges between the original communities into edges between the new vertices, and mark the number of the original edges on the new edges as edge weights. S78: Repeat steps S73-S77 until the modularity increases. Less than a specific threshold; S79: Output the converged community labels as the community discovery results.
7. A social network community discovery device without a community base, characterized in that, include: The data collection module is used to collect social network data and construct a social network with users as vertices, user relationships as edges, and user personal information as vertex attributes. The first building module is used to build a social network encoder, which is trained using any unsupervised method. The mapping module is used to map the vertices of the social network to Euclidean space through a trained encoder to obtain the vertex representation matrix. The first calculation module is used to calculate the similarity between each pair of vertices based on the vertex representation matrix; The second construction module is used to construct training samples with pseudo-labels based on the similarity. The third construction module is used to construct a social network community relationship prediction model, which is trained based on the training samples using a binary cross-entropy loss function. The fourth construction module is used to construct a new structure diagram based on the prediction results of the social network community relationship prediction model; The second calculation module is used to input the new structure graph into the structure graph clustering algorithm to obtain the final community detection result; The process of constructing training samples with pseudo-labels based on the similarity includes the following steps: Flatten the similarity scores to one dimension and sort them from largest to smallest; The similarity index of each pair of vertices is obtained based on the sorting. The vertex pairs with the highest similarity index in the first p% are taken as positive samples and labeled with pseudo-label 1; The vertex pairs with similarity indices in the last q% are taken as negative samples and labeled with pseudo-label 0, where q is much larger than p; Based on the positive and negative samples, extract the vertex representation vector from the vertex representation matrix Z; Calculate the dot product between the vertex representation vectors to obtain the vertex pair representation vector; Training samples are constructed based on the vertex pair representation vector and the pseudo-label. A tuple of <vertex pair representation vector, pseudo-label> constitutes a training sample. The vertex pair representation vectors in the training samples are standardized to a data distribution with a mean of 0 and a variance of 1 to ensure stable training of the community relationship prediction model; The process of constructing a social network community relationship prediction model, which is trained using a binary cross-entropy loss function based on the training samples, includes the following steps: Construct a community relationship prediction model consisting of two fully connected layers; Input the vertex pair representation vector into the community relationship prediction model to obtain the predicted probability that two users belong to the same community; Calculate the binary cross-entropy loss function based on the predicted probability and the pseudo-label; The model parameters are optimized using gradient descent based on the binary cross-entropy loss function.
8. An electronic device, characterized in that, include: One or more processors; Memory, used to store one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the method as described in any one of claims 1-6.
Citation Information
Patent Citations
Trust correlation based microblog network community discovery method
CN105159918A
Community discovery method based on graph convolutional network node label heterogeneous graph
CN115577757A