Public opinion detection method for dynamic edge anomaly detection based on comparative learning

Through comparative learning and dynamic edge anomaly detection methods, the problem of insufficient learning of public opinion detection models in the existing technology in the absence of label information is solved, efficient identification of dynamic edge anomalies is achieved, and the accuracy of public opinion monitoring and risk warning capabilities are enhanced. .

CN118710982APending Publication Date: 2024-09-27GUANGXI NORMAL UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410876865.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-02
Publication Date
2024-09-27

AI Technical Summary

Technical Problem

In the existing public opinion detection methods based on abnormal edge detection, in scenarios lacking label information, the trained detection model cannot perform public opinion detection more efficiently, resulting in insufficient learning of abnormal information.

Method used

The dynamic edge anomaly detection method based on contrastive learning is used to time-slice the dynamic graph data of the social network, artificially injecting abnormal edges, and using the diffusion matrix to generate negative edges, and combine the dynamic encoder and discriminator for model training and prediction. Realize the identification of dynamic edge anomalies.

Benefits of technology

Under unsupervised conditions, it effectively learns the correct evolution pattern of dynamic graph edges, improves the ability to identify abnormal edges, enhances the accuracy of public opinion monitoring and early warning capabilities for potential risks, and can identify abnormal interaction patterns in social networks. and abnormal information dissemination.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118710982A
    Figure CN118710982A
Patent Text Reader

Abstract

The invention discloses a public opinion detection method for dynamic edge anomaly detection based on comparative learning. After an original data set is divided into a training set and a test set, dynamic edge anomaly is artificially injected into the test set; taking each timestamp as a reference to divide a time period with a predetermined length as a time window; forming a graph diffusion matrix according to the adjacent matrix, and sampling neighbor sub-graphs of positive and negative edges under each time slice by using a random restart walk method; and taking the positive and negative edges and the neighbor sub-graphs thereof in each time window as the input of the dynamic encoder, outputting the embedding of the positive and negative edges and the neighbor sub-graphs thereof, taking the positive edge-positive edge sub-graph and the positive edge-negative edge sub-graph as positive and negative pairs, inputting the positive and negative pairs into a discriminator, and outputting an abnormal score through linear transformation. According to the method, the abnormal edge at a certain moment can be rapidly detected, the problem that the effect of capturing the abnormal dynamic edge in a dynamic graph data set is poor is effectively solved, and powerful support is provided for discovery and control of public opinions.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of public opinion detection, and in particular to a public opinion detection method for dynamic edge anomaly detection based on contrastive learning. Background Art

[0002] With the popularity of the Internet and social media, public opinion detection has become particularly important. Its purpose is to monitor and analyze the public's discussions and emotional tendencies on online platforms in real time to predict and identify potential hot spots and crises. Dynamic graphs are a data structure that can capture the changes of nodes and edges over time. In public opinion monitoring, dynamic graphs are widely used to describe the interactive relationships between users in social networks that change over time. Since the nodes of dynamic graphs represent users and the edges of dynamic graphs represent the interactions between users (such as messages, forwarding, and comments), public opinion detection on online platforms can be achieved by detecting abnormal edges in dynamic graphs.

[0003] Abnormal edge detection refers to identifying edges in dynamic graphs that are significantly different from normal patterns. The appearance of these abnormal edges may indicate abnormal behavior in social networks, such as sudden surges in user interactions, manipulative behavior, or automated account activities (such as botnets). By analyzing the abnormal changes in these dynamic edges, we can effectively identify and predict abnormal patterns in the development of public opinion. For example, some unrelated users suddenly frequently like and comment. This atypical interaction pattern may indicate that these users are promoting a topic in a coordinated manner, which may be a sign of human manipulation in some cases. Therefore, dynamic graph edge anomaly detection plays an important role in public opinion monitoring. It can not only improve the accuracy of detection, but also enhance the ability to warn of potential risks. It can greatly improve the ability to process complex social network data and provide strong technical support for real-time public opinion analysis.

[0004] However, previous public opinion detection methods based on abnormal edge detection mainly focused on the dynamic encoding process of spatiotemporal information, but ignored the problem of insufficient abnormal information learning caused by the single negative sample generation method in scenarios with lack of label information, resulting in the trained detection model being unable to perform public opinion detection more efficiently. Summary of the invention

[0005] The present invention aims to solve the problem that the detection model trained by the existing public opinion detection method based on abnormal edge detection cannot perform public opinion detection more efficiently, and provides a public opinion detection method based on dynamic edge anomaly detection based on contrastive learning.

[0006] To solve the above problems, the present invention is achieved through the following technical solutions:

[0007] The public opinion detection method of dynamic edge anomaly detection based on contrastive learning includes the following steps:

[0008] Step 1: The acquired dynamic graph data of the social network is formed into an original data set, and all the dynamic graph data in the original data set are divided into a training set and a test set according to a predetermined ratio;

[0009] Step 2: Divide each dynamic graph data in the training set and the test set into a series of time slices according to a predetermined time length;

[0010] Step 3: artificially inject a predetermined proportion of abnormal edges into each time slice of the test set, where the two endpoints of the abnormal edge must be two nodes of different types, and the connected edge has never appeared in any dynamic graph data of the original data set;

[0011] Step 4: For each timestamp of the time slices in the training set and the test set, divide a time period of a predetermined length τ based on the timestamp to obtain a time window based on the current timestamp;

[0012] Step 5: For each time slice in the time window based on the current timestamp in the training set and the test set, extract all positive edges, all positive edge neighbor subgraphs, and all negative edge neighbor subgraphs of the time slice;

[0013] Step 6: Send all positive edges, all positive edge neighbor subgraphs, and all negative edge neighbor subgraphs of all time slices in the time window based on the current timestamp in the training set to the dynamic edge anomaly detection model for training, thereby obtaining a trained dynamic edge anomaly detection model;

[0014] Step 7: Send all positive edges, all positive edge neighbor subgraphs, and all negative edge neighbor subgraphs of all time slices in the time window based on the current timestamp in the test set to the trained dynamic edge anomaly detection model for testing, and obtain the final dynamic edge anomaly detection model;

[0015] Step 8: Obtain the graph data to be predicted of the social network, and use the same method as step 5 to extract all positive edges, all positive edge neighbor subgraphs, and all negative edge neighbor subgraphs of the graph data to be predicted, and send them to the final dynamic edge anomaly detection model for prediction to complete dynamic edge anomaly detection.

[0016] The specific process of step 5 above is:

[0017] Step 5.1: From the time slice G i Sample the time slice G i The adjacency matrix A i , and then form the time slice G according to the adjacency matrix i The diffusion matrix S i ; where the diffusion matrix S i for:

[0018]

[0019] In the formula, A i is the adjacency matrix, D i is the adjacency matrix A i Forming a diagonal matrix, is the n×n identity matrix, n is the number of nodes in the time slice, and α∈(0,1) is a hyperparameter;

[0020] Step 5.2: Slice G according to time i The adjacency matrix A i Sample the time slice G i The positive side Combined with the time slice G i The positive side and time slice G i The diffusion matrix S i Generate time slice G i Negative side

[0021] Step 5.3: Use the random restart walk method to sample the time slice G i The positive side The positive edge neighbor subgraph of And the time slice G i Negative side The negative neighbor subgraph of

[0022] Where i = t-τ, t-τ+1, ..., t, t is the current timestamp, τ is the time window length, r-τ ≥ 0; j = 1, 2, ..., m, m is the time slice G i The number of positive edges.

[0023] In step 5.2 above, the negative edge The generation method is: first select the positive edge One of the endpoints in As negative side An endpoint of i From the time slice G i Randomly select one of all nodes with the endpoint The correlation is within the preset correlation range and is consistent with the endpoint Nodes without edges As the other endpoint of the negative side; then connect the two negative endpoints selected above to form a negative side

[0024] The model training process of step 6 above is as follows:

[0025] Step 6.1, the dynamic encoder of the dynamic edge anomaly detection model encodes the positive edge, the positive edge neighbor subgraph, and the negative edge neighbor subgraph to obtain the positive edge embedding, the positive edge neighbor subgraph embedding, and the negative edge neighbor subgraph embedding;

[0026] Step 6.2, the discriminator of the dynamic edge anomaly detection model concatenates the positive edge embedding and its corresponding positive edge neighbor subgraph embedding to form a positive pair of the current timestamp, concatenates the positive edge embedding and its corresponding negative edge neighbor subgraph embedding to form a negative pair of the current timestamp, and performs internal feature fusion of the positive pair and the negative pair to form an anomaly prediction;

[0027] Step 6.3. Use the anomaly prediction and label to calculate the loss function, initialize the Adam optimizer, and minimize the loss value through the Adam optimizer to optimize the parameters of the dynamic encoder and discriminator to complete the model training process.

[0028] The model testing process of step 7 above is as follows:

[0029] Step 7.1, the dynamic encoder of the trained dynamic edge anomaly detection model encodes the positive edge, the positive edge neighbor subgraph, and the negative edge neighbor subgraph to obtain the positive edge embedding, the positive edge neighbor subgraph embedding, and the negative edge neighbor subgraph embedding;

[0030] Step 7.2, the discriminator of the trained dynamic edge anomaly detection model concatenates the positive edge embedding and its corresponding positive edge neighbor subgraph embedding to form a positive pair of the current timestamp, concatenates the positive edge embedding and its corresponding negative edge neighbor subgraph embedding to form a negative pair of the current timestamp, and performs internal feature fusion of the positive pair and the negative pair to form an anomaly prediction;

[0031] Step 7.3: Use anomaly prediction to calculate the anomaly score, and judge the training result of the model by comparing the predicted anomaly score with the actual anomaly score to complete the testing process.

[0032] The model prediction process of step 8 above is as follows:

[0033] Step 8.1, the dynamic encoder of the final dynamic edge anomaly detection model encodes the positive edge, the positive edge neighbor subgraph, and the negative edge neighbor subgraph to obtain the positive edge embedding, the positive edge neighbor subgraph embedding, and the negative edge neighbor subgraph embedding;

[0034] Step 8.2, the discriminator of the final dynamic edge anomaly detection model concatenates the positive edge embedding and its corresponding positive edge neighbor subgraph embedding to form a positive pair of the current timestamp, concatenates the positive edge embedding and its corresponding negative edge neighbor subgraph embedding to form a negative pair of the current timestamp, and performs internal feature fusion of the positive pair and the negative pair to form an anomaly prediction;

[0035] Step 8.3: Use anomaly prediction to calculate the predicted anomaly score and complete the prediction process.

[0036] Compared with the prior art, the present invention has the following characteristics:

[0037] 1. Aiming at the problem of lack of label information and node attributes in anomaly detection of dynamic graphs, an unsupervised training method is adopted to enrich node information according to the spatiotemporal characteristics of dynamic networks, and the evolution mode distinction of positive and abnormal edges under unsupervised conditions is achieved by annotating pseudo labels;

[0038] 2. Use edge-subgraph comparative learning to further strengthen the relationship between the edge and its neighbor structure, so that the overall positive and abnormal embeddings are far away from each other, and the same type of embeddings are close to each other. In public opinion monitoring, the interaction between users usually only occurs in groups with the same hobbies and interests. If a user frequently communicates with cross-domain users, there is a suspicion of deliberately spreading certain malicious information. It is necessary to accurately detect the interaction of such users;

[0039] 3. Regarding the generation method of negative samples in contrastive learning, previous dynamic graph anomaly detection using contrastive learning did not pay attention to the construction of negative samples. The random sampling between nodes resulted in the negative samples not being able to really help the descent of training gradients. The use of negative sampling based on the similarity matrix can generate truly effective negative samples.

[0040] 4. Better learn the correct evolution pattern of dynamic graph edges in an unsupervised manner, so as to detect abnormal edges at a certain moment, effectively solve the problem of poor effect in capturing dynamic edge anomalies (context abnormal areas) in dynamic graph datasets, and provide strong support for the discovery and control of public opinion;

[0041] 5. It can identify abnormal interaction patterns in social networks, such as abnormal user behavior, abnormal information dissemination, etc., so as to promptly discover and respond to possible public opinion crises or social impact events. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] Figure 1 It is a flowchart of the public opinion detection method based on contrastive learning and dynamic edge anomaly detection;

[0043] Figure 2 AUC score comparison chart of the present invention and the existing method on the UCI Message dataset;

[0044] Figure 3 The figure is a comparison chart of AUC scores between the present invention and the existing method on the Bitcoin-OTC dataset. DETAILED DESCRIPTION

[0045] In order to make the objectives, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with specific examples and with reference to the accompanying drawings.

[0046] Public opinion detection method based on contrastive learning for dynamic edge anomaly detection, such as Figure 1 As shown, the steps include:

[0047] Step 1: The acquired dynamic graph data of the social network is formed into an original data set, and all the dynamic graph data in the original data set are divided into a training set and a test set according to a predetermined ratio.

[0048] Graph data is a data structure that consists of nodes and edges. Nodes represent entities, and edges represent the relationship between entities. Dynamic graph data is graph data that changes over time, which can accurately capture the time correlation and evolution characteristics in these graph data. In the field of public opinion monitoring, dynamic graph data is a social network data structure that evolves over time. Its nodes represent users in the network, and edges represent the interactions between users at a certain moment. By capturing and analyzing these dynamic graph data, abnormal edges in dynamic graph data can be discovered in a timely manner. In public opinion control, abnormal edges represent the sudden interaction between two users who have never interacted and have completely different behavior patterns in the past, that is, the human manipulation phenomenon that may occur in public opinion monitoring. It can help analyze and predict public opinion trends on social media, provide deep insights into the field of public opinion monitoring, and enable relevant organizations and institutions to understand and respond to social public opinion more effectively. In order to realize the learning of dynamic edge anomaly detection models, the original data set can be obtained through actual collection, or existing public data sets can be directly used.

[0049] Step 2: Divide each dynamic graph data in the training set and the test set into a series of time slices according to a predetermined time length.

[0050] When processing dynamic graph datasets, considering that the topological structure of the graph will change over time, it is necessary to divide the data into multiple time periods according to a certain time length to form a series of time slices. Each time slice reflects the state of the social network at a specific moment, that is, the graph data including nodes and edges. Choosing the appropriate time length to divide the dynamic graph data is crucial to capturing the essential characteristics of the dynamic graph, which usually depends on the unique nature of the dataset and the actual application requirements.

[0051] Step 3: Artificially inject a predetermined proportion of abnormal edges into each time slice of the test set, where the two endpoints of the abnormal edge must be two nodes of different types, and the connected edge has never appeared in any dynamic graph data of the original data set.

[0052] In deep learning, especially in the field of anomaly detection, models usually use unsupervised or semi-supervised learning methods in the training phase, but in the testing phase, in order to effectively evaluate the performance of the model, a labeled test set is required. Considering that the real dynamic graph dataset may lack clear labels about abnormal edges, it is necessary to artificially inject abnormal edges in the time slices of the test set. The injection of abnormal edges is formed by connecting the nodes under each time slice in the test set, but the two endpoints of the abnormal edge must be two nodes of different types and the connected edge has never appeared in all dynamic graph data of the original dataset. For dynamic graph datasets without node attributes, the injection method used is often related to the structure of the graph, that is, after extracting the adjacency matrix of the time slice, the node classification is performed using spectral clustering, and a certain number of abnormal edges are generated by connecting nodes of different classes. Finally, the abnormal edges are injected into the original time slice according to the set abnormal ratio (such as 10%, 5% or 1%). These injected abnormal edges are designed to simulate abnormal connections or interactions that may occur in real-world scenarios, thereby providing the model with an opportunity to test and verify its dynamic edge anomaly detection capabilities. This allows for a more comprehensive evaluation of the model’s ability to identify and respond to edge anomalies in dynamic graphs, which is critical to accuracy and reliability in practical applications.

[0053] Step 4: For each timestamp of the time slice in the training set and the test set, a time period of a predetermined length of τ is divided based on the timestamp (current timestamp) to obtain a time window based on the current timestamp.

[0054] Generally speaking, for time slices that are adjacent in time, the correlation between them and the continuity of network evolution will be stronger, and the anomaly detection effect will be more significant. Therefore, each timestamp r is used as a benchmark to divide time periods of length τ (t-τ, t-τ+1,…, t) for model training or testing. This process of dividing time periods is called building a sliding window, where t=1,2,…,R, T is the number of timestamps of time slices in the training set and the test set, which is determined by the time length of the divided time slices; τ is a set value, and t-τ≥0.

[0055] Step 5: For each time slice in the time window based on the current timestamp in the training set and the test set, extract all positive edges, all positive edge neighbor subgraphs, and all negative edge neighbor subgraphs of each time slice.

[0056] For each time slice G in the time window (t-τ, t-τ+1,…,t) based on timestamp t in the training set and test set i Perform the encoding operation to obtain the time slice G i The positive edge embedding Positive edge neighbor subgraph embedding and negative edge neighbor subgraph embedding i∈(t-τ+1,t-τ,…,t), j∈[1,m], m represents the time slice G i The number of edges.

[0057] Step 5.1: For each time slice G in the time window of the current timestamp i , where G i ∈(G t-τ ,G t -τ+1 ,…,G t ), sample the time slice G i The topological structure of the adjacency matrix A i , where A i ∈(A t-τ ,A t-τ+1 ,…,A t ), and then sample the time slice G according to the adjacency matrix i The correlation between internal nodes is the diffusion matrix S i , where S i ∈(S t-τ ,S t -τ+1 ,…,S t ).

[0058] Diffusion matrix S i Represents the time slice G i Correlations between internal nodes:

[0059]

[0060] In the formula, A i is the adjacency matrix, D i is the adjacency matrix A i Forming a diagonal matrix, is an n×n identity matrix, n is the number of nodes in the time slice, and α∈(0,1) is a hyperparameter.

[0061] Step 5.2: For each time slice G in the time window of the current timestamp i , according to the time slice G i The adjacency matrix A i Sample the time slice G i The positive side in Combined with the time slice G i The positive side and time slice G i The diffusion matrix S i Sample the time slice G i Negative side in

[0062] In order to achieve the contrastive learning of the dynamic edge anomaly detection model, it is necessary to sample negative samples determined as abnormal data for contrastive training based on the normal data positive samples. i , its positive side It can be directly obtained through the adjacency matrix A i Sampling out, the positive edge The corresponding negative side Then we need to combine the time slice G i The correlation between internal nodes is the diffusion matrix S i Generate, that is: first select the positive edge One of the endpoints in Negative side An endpoint of i From the time slice G i Randomly select one of all nodes with the endpoint The correlation is within the preset correlation range and is consistent with the endpoint Nodes without edges As the other endpoint of the negative side; then connect the two negative endpoints selected above to form a negative side

[0063] Step 5.3: For each time slice G in the time window of the current timestamp i ,

[0064] Use the random restart walk (RWR) method to sample the time slice G i The positive side Neighborhood subgraph containing k nodes in And the time slice G i Negative side Neighborhood subgraph containing k nodes in k is the set value.

[0065] Step 6: Send all positive edges, all positive edge neighbor subgraphs, and all negative edge neighbor subgraphs of all time slices in the time window based on the current timestamp in the training set to the dynamic edge anomaly detection model for training, and obtain a trained dynamic edge anomaly detection model.

[0066] The model training process is as follows:

[0067] 1) The dynamic encoder of the dynamic edge anomaly detection model encodes the positive edge, the positive edge neighbor subgraph, and the negative edge neighbor subgraph to obtain the positive edge embedding, the positive edge neighbor subgraph embedding, and the negative edge neighbor subgraph embedding.

[0068] In order to further aggregate graph information, the dynamic edge anomaly detection model uses a dynamic encoder (DGNN) based on the transformer model to obtain relevant embedding representations containing temporal and spatial information. The goal of the dynamic encoder based on the transformer model is to aggregate the node encodings in the substructure node set into node embeddings, which uses many attention layers to exchange information from different nodes.

[0069] A single attention layer is:

[0070]

[0071] In the formula, H (l) and H (l-1) is the output embedding of the lth and (l-1)th layers, d emb is the dimension of node embedding, Q (l) , K (l) , It is the query matrix, key matrix and value matrix for feature transformation and information exchange. Specifically, Q (l) , K (l) 、V (l) for:

[0072]

[0073] In the formula, The model is the learnable parameter matrix of layer l. In the attention layer, Q (l) and K (l) Calculate the contribution of different node embeddings, while V (l) Project the input into a new feature space. The model transforms H (0) Denote each input and embed dimension d emb With input and output dimensions d,d enc Be consistent.

[0074] The dynamic encoder continuously collects information for the input data in each attention layer, and further aggregates information in time and space between layers to generate embedding as output. After aggregation by the dynamic encoder based on the transformer model, the output is the embedding of the positive and negative edges and their subgraphs containing time and space information in the time window based on timestamp t, which serves as the basis for the subsequent formation of anomaly scores.

[0075] The dynamic encoder encodes the positive edges, the positive edge neighbor subgraph, and the negative edge neighbor subgraph to obtain relevant embedding representations containing temporal and spatial information. Specifically:

[0076] All positive edges of all time slices in the time window based on timestamp t As the input of the dynamic encoder, the output of the dynamic encoder contains the positive edge embedding containing time and space information in the time window based on the timestamp t.

[0077] The positive edge neighbor subgraphs of all time slices in the time window based on timestamp t As the input of the dynamic encoder, the output of the dynamic encoder is the positive edge neighbor subgraph embedding containing time and space information in the time window based on timestamp t.

[0078] The negative edge neighbor subgraphs of all time slices in the time window based on timestamp t As the input of the dynamic encoder, the dynamic encoder outputs the negative edge neighbor subgraph embedding containing time and space information in the time window based on timestamp t.

[0079] 2) The discriminator of the dynamic edge anomaly detection model concatenates the positive edge embedding and its corresponding positive edge neighbor subgraph embedding to form a positive pair of the current timestamp, concatenates the positive edge embedding and its corresponding negative edge neighbor subgraph embedding to form a negative pair of the current timestamp, and performs internal feature fusion of the positive and negative pairs to form anomaly prediction.

[0080] Contrastive learning is a method that has gained increasing attention in the field of machine learning, especially in unsupervised or self-supervised learning environments where labeled data is limited or unavailable. The core idea of ​​this method is to train the model by comparing pairs of samples (usually including positive and negative pairs), with the goal of enabling the model to bring the representations of similar samples closer together in the feature space, while pushing the representations of dissimilar samples further apart, so that the model can learn a more discriminative representation of information. Contrastive learning is particularly suitable for feature representation learning, and can help the model learn more effective data representations in complex data sets, which is crucial to improving the performance of various machine learning tasks. Through this method, deep data insights can be more effectively obtained, thereby achieving more accurate data analysis and decision support in various applications.

[0081] First, the discriminator forms positive and negative pairs through the concatenation layer, that is, using the positive edge embedding of timestamp t and its corresponding positive edge neighbor subgraph embedding Splice to form a positive pair of the current timestamp Using positive edge embedding of timestamp t and its corresponding negative edge neighbor subgraph embedding Splice to form a positive pair of the current timestamp

[0082] Next, the discriminator performs internal feature fusion on the positive and negative pairs through a bilinear layer to form an abnormal prediction of the target edge. Right now:

[0083]

[0084] In the formula, represents the pair of edge j at timestamp t, represents the negative pair of edge j at timestamp t, and Bilinear represents the bilinear function.

[0085] 3) Use the anomaly prediction and label to calculate the loss function, initialize the Adam optimizer, and minimize the loss value through the Adam optimizer to optimize the parameters of the dynamic encoder and discriminator to complete the model training process.

[0086] The present invention completes the training of the model by minimizing the binary cross entropy loss (BCELoss), where the loss function is:

[0087]

[0088] In the formula, loss represents the loss function, Indicates the BCELoss value at timestamp t, is the anomaly prediction of edge j at timestamp t, is the label of edge j at timestamp t.

[0089] Initialize the Adam optimizer and set the learning rate α of the Adam optimizer. The Adam optimizer receives the loss value and the parameters of the dynamic encoder and discriminator as input, and continuously optimizes the parameters of the dynamic encoder and discriminator according to the loss value and α within the training iteration number epoch.

[0090] Step 7: Send all positive edges, all positive edge neighbor subgraphs, and all negative edge neighbor subgraphs of all time slices in the time window based on the current timestamp in the test set to the trained dynamic edge anomaly detection model for testing, and obtain the final dynamic edge anomaly detection model.

[0091] The model testing process is as follows:

[0092] 1) The dynamic encoder of the trained dynamic edge anomaly detection model encodes the positive edge, the positive edge neighbor subgraph, and the negative edge neighbor subgraph to obtain the positive edge embedding, the positive edge neighbor subgraph embedding, and the negative edge neighbor subgraph embedding.

[0093] 2) The discriminator of the trained dynamic edge anomaly detection model concatenates the positive edge embedding and its corresponding positive edge neighbor subgraph embedding to form a positive pair of the current timestamp, concatenates the positive edge embedding and its corresponding negative edge neighbor subgraph embedding to form a negative pair of the current timestamp, and performs internal feature fusion of the positive and negative pairs to form anomaly predictions.

[0094] 3) Use anomaly prediction to calculate the anomaly score, and judge the training result of the model by comparing the predicted anomaly score with the actual anomaly score to complete the testing process.

[0095] The present invention uses anomaly prediction to calculate the predicted anomaly score f(E t ):

[0096]

[0097] In the formula, f(E t ) is the predicted anomaly score of edge j at timestamp t, and sigmoid represents the activation function.

[0098] When the ratio of the predicted anomaly score to the actual anomaly score meets the requirement, the model parameter training is considered qualified, and the trained discriminator is the final dynamic edge anomaly detection model; otherwise, the model parameter training is considered unqualified, and the τ, k and α values ​​are adjusted, and steps 4 to 7 are repeated until the ratio of the predicted anomaly score to the actual anomaly score meets the requirement.

[0099] Step 8: Obtain the graph data to be predicted of the social network, and use the same method as step 5 to extract all positive edges, all positive edge neighbor subgraphs, and all negative edge neighbor subgraphs of the graph data to be predicted, and send them to the final dynamic edge anomaly detection model for prediction to complete dynamic edge anomaly detection.

[0100] The model prediction process is as follows:

[0101] 1) The dynamic encoder of the final dynamic edge anomaly detection model encodes the positive edge, the positive edge neighbor subgraph, and the negative edge neighbor subgraph to obtain the positive edge embedding, the positive edge neighbor subgraph embedding, and the negative edge neighbor subgraph embedding.

[0102] 2) The discriminator of the final dynamic edge anomaly detection model concatenates the positive edge embedding and its corresponding positive edge neighbor subgraph embedding to form a positive pair of the current timestamp, concatenates the positive edge embedding and its corresponding negative edge neighbor subgraph embedding to form a negative pair of the current timestamp, and performs internal feature fusion of the positive and negative pairs to form anomaly predictions.

[0103] 3) Use anomaly prediction to calculate the predicted anomaly score and complete the prediction process.

[0104] The UCI Message dataset and the Bitcoin-OTC dataset are used to compare the performance of the present invention with the prior art (StrGNN, AddGraph and TADDY). The UCI Message dataset and the Bitcoin-OTC dataset are split into their own training set and test set at a ratio of 5:5, and the dynamic abnormal edges are detected at three different abnormal injection ratios of the two test sets. The AUC score is used as an indicator to evaluate the performance of the classification model. The experimental results are shown in Figure 2. Figure 2 and 3 As shown in the figure, it can be seen that the AUC score of the present invention is significantly higher than that of StrGNN, AddGraph and TADDY. This is because the prior art does not focus on the sampling of real negative samples, while the present invention can learn an evolutionary pattern that is closer to real data, so that dynamic abnormal edges can be better detected. The present invention can quickly detect abnormal edges at a certain moment, effectively solving the problem of poor effect in capturing dynamic edge anomalies in dynamic graph data sets, and providing strong support for the discovery and control of public opinion.

[0105] It should be noted that although the embodiments of the present invention described above are illustrative, they are not intended to limit the present invention, and therefore the present invention is not limited to the above specific embodiments. Without departing from the principles of the present invention, any other embodiments obtained by those skilled in the art under the guidance of the present invention are deemed to be within the protection of the present invention.

Claims

1. A public opinion detection method based on contrastive learning and dynamic edge anomaly detection, characterized by: The steps include: Step 1: The acquired dynamic graph data of the social network is formed into an original data set, and all the dynamic graph data in the original data set are divided into a training set and a test set according to a predetermined ratio; Step 2: Divide each dynamic graph data in the training set and the test set into a series of time slices according to a predetermined time length; Step 3: artificially inject a predetermined proportion of abnormal edges into each time slice of the test set, where the two endpoints of the abnormal edge must be two nodes of different types, and the connected edge has never appeared in any dynamic graph data of the original data set; Step 4: For each timestamp of the time slices in the training set and the test set, divide a time period of a predetermined length τ based on the timestamp to obtain a time window based on the current timestamp; Step 5: For each time slice in the time window based on the current timestamp in the training set and the test set, extract all positive edges, all positive edge neighbor subgraphs, and all negative edge neighbor subgraphs of the time slice; Step 6: Send all positive edges, all positive edge neighbor subgraphs, and all negative edge neighbor subgraphs of all time slices in the time window based on the current timestamp in the training set to the dynamic edge anomaly detection model for training, thereby obtaining a trained dynamic edge anomaly detection model; Step 7: Send all positive edges, all positive edge neighbor subgraphs, and all negative edge neighbor subgraphs of all time slices in the time window based on the current timestamp in the test set to the trained dynamic edge anomaly detection model for testing, and obtain the final dynamic edge anomaly detection model; Step 8: Obtain the graph data to be predicted of the social network, and use the same method as step 5 to extract all positive edges, all positive edge neighbor subgraphs, and all negative edge neighbor subgraphs of the graph data to be predicted, and send them to the final dynamic edge anomaly detection model for prediction to complete dynamic edge anomaly detection.

2. According to claim 1, the public opinion detection method for dynamic edge anomaly detection based on contrastive learning is characterized in that: The specific process of step 5 is: Step 5.1: From the time slice G i Sample the time slice G i The adjacency matrix A i , and then form the time slice G according to the adjacency matrix i The diffusion matrix S i ; where the diffusion matrix S i for: In the formula, A i is the adjacency matrix, D i is the adjacency matrix A i Forming a diagonal matrix, is the n×n identity matrix, n is the number of nodes in the time slice, and α∈(0,1) is a hyperparameter; Step 5.2: Slice G according to time i The adjacency matrix A i Sample the time slice G i The positive side Combined with the time slice G i The positive side and time slice G i The diffusion matrix S i Generate time slice G i Negative side Step 5.3: Use the random restart walk method to sample the time slice G i The positive side The positive edge neighbor subgraph of And the time slice G i Negative side The negative neighbor subgraph of Where i = t-τ, t-τ+1, ..., t, t is the current timestamp, τ is the time window length, t-τ ≥ 0; j = 1, 2, ..., m, m is the time slice G i The number of positive edges.

3. The public opinion detection method based on contrastive learning and dynamic edge anomaly detection according to claim 2 is characterized in that: In step 5.2, the negative edge The generation method is: first select the positive edge One of the endpoints in As negative side An endpoint of Based on the diffusion matrix S i From the time slice G i Randomly select one of all nodes with the endpoint The correlation is within the preset correlation range and is consistent with the endpoint Nodes without edges As the other endpoint of the negative side; then connect the two negative endpoints selected above to form a negative side 4. The public opinion detection method based on contrastive learning and dynamic edge anomaly detection according to claim 1 is characterized in that: The model training process of step 6 is as follows: Step 6.1, the dynamic encoder of the dynamic edge anomaly detection model encodes the positive edge, the positive edge neighbor subgraph, and the negative edge neighbor subgraph to obtain the positive edge embedding, the positive edge neighbor subgraph embedding, and the negative edge neighbor subgraph embedding; Step 6.2, the discriminator of the dynamic edge anomaly detection model concatenates the positive edge embedding and its corresponding positive edge neighbor subgraph embedding to form a positive pair of the current timestamp, concatenates the positive edge embedding and its corresponding negative edge neighbor subgraph embedding to form a negative pair of the current timestamp, and performs internal feature fusion of the positive pair and the negative pair to form an anomaly prediction; Step 6.

3. Use the anomaly prediction and label to calculate the loss function, initialize the Adam optimizer, and minimize the loss value through the Adam optimizer to optimize the parameters of the dynamic encoder and discriminator to complete the model training process.

5. The public opinion detection method based on contrastive learning and dynamic edge anomaly detection according to claim 1, characterized in that: The model testing process in step 7 is as follows: Step 7.1, the dynamic encoder of the trained dynamic edge anomaly detection model encodes the positive edge, the positive edge neighbor subgraph, and the negative edge neighbor subgraph to obtain the positive edge embedding, the positive edge neighbor subgraph embedding, and the negative edge neighbor subgraph embedding; Step 7.2, the discriminator of the trained dynamic edge anomaly detection model concatenates the positive edge embedding and its corresponding positive edge neighbor subgraph embedding to form a positive pair of the current timestamp, concatenates the positive edge embedding and its corresponding negative edge neighbor subgraph embedding to form a negative pair of the current timestamp, and performs internal feature fusion of the positive pair and the negative pair to form an anomaly prediction; Step 7.3: Use anomaly prediction to calculate the anomaly score, and judge the training result of the model by comparing the predicted anomaly score with the actual anomaly score to complete the testing process.

6. The public opinion detection method based on contrastive learning and dynamic edge anomaly detection according to claim 1, characterized in that: The model prediction process in step 8 is as follows: Step 8.1, the dynamic encoder of the final dynamic edge anomaly detection model encodes the positive edge, the positive edge neighbor subgraph, and the negative edge neighbor subgraph to obtain the positive edge embedding, the positive edge neighbor subgraph embedding, and the negative edge neighbor subgraph embedding; Step 8.2, the discriminator of the final dynamic edge anomaly detection model concatenates the positive edge embedding and its corresponding positive edge neighbor subgraph embedding to form a positive pair of the current timestamp, concatenates the positive edge embedding and its corresponding negative edge neighbor subgraph embedding to form a negative pair of the current timestamp, and performs internal feature fusion of the positive pair and the negative pair to form an anomaly prediction; Step 8.3: Use anomaly prediction to calculate the predicted anomaly score and complete the prediction process.