A method for detecting anomalies in power data based on graph neural network
Through the power data anomaly detection method based on graph neural network, power data graphs and prediction models are constructed, and the problem of difficult power data processing is solved in complex correlation relationships is achieved, more efficient abnormal data identification and exclusion is achieved, and the accuracy and efficiency of power system management is improved.
Patent Information
- Application Number
- CN202411803524.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-09
- Publication Date
- 2025-04-01
AI Technical Summary
The prior art is difficult to effectively process power data with complex correlations, resulting in poor exclusion of abnormal data, affecting the stable operation and management efficiency of the power system.
The power data anomaly detection method based on graph neural network is adopted, and the power data graph and normal power data prediction model is constructed, and the combined model of graph convolution layer and output layer is used to predict and compare power data, identify and eliminate abnormal data.
It improves the accuracy of power data prediction, can effectively identify and eliminate abnormal data in complex associations, and reduces the impact of abnormal data on power system management.
Smart Images

Figure CN119740162A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of power detection methods, and specifically relates to a power data anomaly detection method based on graph neural network. Background Art
[0002] With the rapid development of smart grids, the amount of power data received by data servers has increased dramatically, and its complexity has also increased. These data cover basic parameters such as real-time power, voltage, and current, and extend to multi-dimensional information such as user power consumption behavior, equipment operating status, and grid topology. However, due to factors such as equipment failure, grid instability, and external interference, abnormal data is also generated. The existence of these abnormal data poses a major challenge to the stable operation, energy efficiency evaluation, and fault diagnosis of the power system, and seriously affects the accuracy and efficiency of power system management. Therefore, how to effectively identify and process these abnormal data has become a key issue in ensuring the reliability and optimized operation of smart grids.
[0003] Existing abnormal data detection methods include statistical-based methods and machine learning methods. These methods can detect some abnormal data, but cannot effectively process the complex correlated data in power data, causing abnormal data to affect the power data analysis results. Summary of the invention
[0004] The purpose of the present invention is to provide a method for detecting anomalies in power data based on a graph neural network, so as to solve the problem that the existing method proposed in the background technology is not effective in eliminating abnormal data when processing power data with complex correlation relationships.
[0005] To achieve the above object, the present invention provides the following technical solutions:
[0006] A method for detecting anomalies in power data based on a graph neural network, the method comprising:
[0007] Constructing a normal power data sample set, each normal power data sample includes power data acquired by a user based on a sensor and normal power data selected from the power data;
[0008] Based on the power data of each user, a power data graph is constructed, including the node feature matrix X∈R N×F and the adjacency matrix A∈R N×N , where N represents the number of sensors, F represents the number of features collected by each sensor in a specific time window, and the adjacency matrix represents the physical connection relationship between sensors. i,j is 0 or 1, i, j is the sensor index;
[0009] Based on the power data graph and normal power data, a normal power data prediction model based on the graph neural network is constructed and trained;
[0010] After the current power data is constructed through the graph, it is input into the trained normal power data prediction model to obtain the predicted normal power data. The predicted value and the actual value are compared according to the preset comparison strategy to obtain the power data detection result.
[0011] Preferably, the normal power data prediction model includes a plurality of cascaded graph convolutional layers and a post-output layer.
[0012] Preferably, the construction formula of the graph convolution layer is:
[0013]
[0014] In the formula, H (l) is the node feature matrix of the lth graph convolutional layer, represents the normalized adjacency matrix, W (l) is the learnable weight matrix of the lth graph convolutional layer, σ is the activation function, is the normalized adjacency matrix.
[0015] Preferably, the output layer is constructed as follows:
[0016] Z=H (L) W out
[0017] In the formula, H (L) is the node feature matrix of the Lth graph convolutional layer, W out is the weight matrix of the output layer.
[0018] Preferably, during the training process, the mean square error is used to calculate the loss value, and the Adam algorithm is used to optimize the model parameters.
[0019] Preferably, the comparison strategy is to determine whether the relative difference between the predicted value and the actual value is less than a preset threshold value. If so, it is normal, otherwise it is abnormal.
[0020] Preferably, the calculation formula of the relative difference is:
[0021]
[0022] Preferably, the method further comprises:
[0023] Acquire abnormal power data of the power data and construct an abnormal power data set;
[0024] Perform data enhancement on abnormal power data sets and build an abnormal power database;
[0025] The current power data is matched with the abnormal power data. If the match is unsuccessful, the predicted value is compared with the actual value according to the predicted comparison strategy, otherwise there is an abnormality.
[0026] Preferably, the data enhancement uses a GAN network to generate abnormal power data.
[0027] Compared with the prior art, the present invention has the following beneficial effects:
[0028] In the present invention, the connection relationship between the sensors is used as one of the characteristics that affect the power data, and is involved in the prediction of normal power data, thereby improving the accuracy of model prediction. The prediction values of key nodes are compared with the positive power data output by the prediction model according to the comparison strategy to obtain the prediction results of each key node, thereby eliminating abnormal data one by one. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] Figure 1 It is a flow chart of the present invention. DETAILED DESCRIPTION
[0030] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work belong to the protection scope of the present invention.
[0031] Reference Figure 1 ,A power data anomaly detection method based on graph neural network includes the following 4 steps.
[0032] Step 1: Data collection and feature screening
[0033] Obtain power data from the data center, which mainly includes user ID, electricity meter ID, user type, current, voltage, power, etc. Select key data fields and normal power data based on expert experience, exclude discarded fields and abnormal data, and build a sample set that integrates normal power data samples.
[0034] Step 2: Electricity data graph construction
[0035] In the present invention, the construction of the power data graph includes the construction of a node feature matrix and the construction of an adjacency matrix.
[0036] In the present invention, since power data collection relies on various sensors such as electric energy meters, this method regards each sensor as a node in a graph. If there are N sensors that generate power data, there will be N points in the constructed graph.
[0037] In the present invention, the feature of each node is composed of the data collected by the corresponding sensor in a specific time window, such as voltage, current, power, etc., then the node feature matrix X∈R N×F , F represents the data collected by each sensor within a specific time window.
[0038] In the present invention, the edges between sensors are constructed according to the physical connection relationship between sensors. If there is no connection between two sensors, it is set to 0, otherwise it is set to 1. Then there is an adjacency matrix A∈R N×N , where A i,j is 0 or 1, i, j∈{1, 2, ..., N}.
[0039] In the present invention, due to the different connection relationships between sensors of different users, the adjacency matrix obtained based on the power data is different in different normal power data samples, but the number of elements included is the same, including N rows and N columns.
[0040] In the present invention, the power data graph includes not only a node feature matrix but also an adjacency matrix to construct a connection relationship between sensors. The connection relationship will affect the data of the associated sensors and enhance the node data characteristics.
[0041] In the present invention, in order to stabilize the training in the subsequent graph neural network, the adjacency matrix needs to be normalized. The normalization formula is as follows:
[0042]
[0043] Where D is the degree matrix, D i,j =∑ j A i,j .
[0044] In the present invention, a graph neural network model is used to capture the relationship between nodes and improve the accuracy of power data prediction.
[0045] Step 3: Prediction model construction and training
[0046] In the present invention, a graph neural network is used as the model architecture, the power data graph is used as input, and normal power data is used as the target output to construct a normal power data prediction model.
[0047] In this embodiment, the normal power data prediction model consists of L cascaded graph convolutional layers and an output layer set at the end. The cascade is connected in series in sequence. The input of the current graph convolutional layer is the output of the previous graph convolutional layer, and the input of the output layer is the output of the last graph convolutional layer.
[0048] In this embodiment, the output of the graph convolution layer is:
[0049]
[0050] In the formula, H (l) is the node feature matrix of the lth graph convolutional layer, represents the normalized adjacency matrix, W (l) is the learnable weight matrix of the lth graph convolutional layer, l = 1, 2, ..., L, σ is the activation function, is the normalized adjacency matrix;
[0051] At this time, the multi-layer structure formula composed of the cascaded graph convolutional layers can be expressed as:
[0052]
[0053] The output of this output layer is:
[0054] Z=H (L) W out
[0055] In the formula, H (L) is the node feature matrix of the Lth graph convolutional layer, W out is the weight matrix of the output layer.
[0056] In the present invention, when the sample set is used to train the model, the sample set is divided into a training set and a validation set. In this embodiment, the ratio of the sample set to the validation set is 7:3.
[0057] In the present invention, during training, the graph corresponding to the power data in the sample set is used as input, and the normal power data corresponding to the power data is used as the target output. The actual output and target output of the normal power data prediction model are used to calculate the loss value. The goal is to minimize the loss value, and the weight of the model is updated through the back propagation algorithm to optimize the model prediction accuracy.
[0058] In this embodiment, the mean squared error (MSE) is used to calculate the error. MSE measures the difference between the predicted value (actual output) and the true value (target output). The calculation formula is as follows:
[0059]
[0060] Among them, L is the loss function, yi is the true value of the i-th sample, is the model's predicted value for the i-th sample, and N is the total number of samples.
[0061] The prediction model in step 3 of the present invention is mainly used to screen the power data to obtain normal power data.
[0062] Step 4: Power data anomaly detection
[0063] In this step, the current power data is input into the trained normal power data prediction model after graph construction to obtain the key node prediction values. The key node prediction values are compared with the actual values according to the preset comparison strategy to obtain the power data detection results.
[0064] In step 4 of the present invention, the graph construction method is consistent with step 2, and the normal power data prediction model outputs predicted normal power data, which is composed of several key node prediction values. The actual value is also a specific value corresponding to the key node in the current power data.
[0065] In this embodiment, the predicted value of the key node is compared with the actual value, and whether the actual value is abnormal is obtained according to the preset threshold: when the relative difference is greater than or equal to the preset threshold, there is an abnormality, and when the relative difference is less than the preset threshold, there is no abnormality; the relative difference calculation formula is:
[0066]
[0067] In the present invention, the abnormal data are eliminated one by one through the comparison strategy, rather than directly determining that the power data is abnormal data, which can effectively process the complex related data in the power data, thereby preventing the abnormal data from affecting the power data analysis results.
[0068] This method adopts a deep learning model based on graph neural network, learns the representation of nodes by aggregating information of nodes and their neighborhoods, and processes power data with complex correlations. Compared with existing methods, it can more effectively exclude abnormal data in power data with complex correlations, reducing the impact of abnormal data on power system management.
[0069] In the present invention, further, the method of the present invention also includes the following steps:
[0070] Acquire the abnormal power data of the power data in step 1, construct an abnormal power data set, and use the GAN network to perform data enhancement on the abnormal power data set to construct an abnormal power database;
[0071] Before executing step 4, the current power data is matched with the abnormal power data. If the match is unsuccessful, the predicted value is compared with the actual value according to the predicted comparison strategy, otherwise there is an abnormality.
[0072] Here, the abnormal power data set is queried for data that is consistent with the current power data. If it exists, it means that all measured values in the measured power data are abnormal. This pre-step reduces the amount of calculation so that the result can be output quickly when the measured power data is abnormal.
[0073] It should be noted here that, since the data volume of the current power data is larger than the data volume of the abnormal power data, in this consistency comparison, as long as the current power data covers the abnormal power data, the match is considered successful.
[0074] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for detecting anomalies in power data based on graph neural network, characterized in that: The method comprises: Constructing a normal power data sample set, each normal power data sample includes power data acquired by a user based on a sensor and normal power data selected from the power data; Based on the power data of each user, a power data graph is constructed, including the node feature matrix X∈R N×F and the adjacency matrix A∈R N ×N , where N represents the number of sensors, F represents the number of features collected by each sensor in a specific time window, and the adjacency matrix represents the physical connection relationship between sensors. i,j is 0 or 1, i, j is the sensor index; Based on the power data graph and normal power data, a normal power data prediction model based on the graph neural network is constructed and trained; After the current power data is constructed through the graph, it is input into the trained normal power data prediction model to obtain the predicted normal power data. The predicted value and the actual value are compared according to the preset comparison strategy to obtain the power data detection result.
2. The method for detecting anomalies in power data based on graph neural network according to claim 1, characterized in that: The normal power data prediction model includes a plurality of cascaded graph convolutional layers and a post-output layer.
3. The method for detecting anomalies in power data based on graph neural network according to claim 2, characterized in that: The construction formula of the graph convolution layer is: In the formula, H (l) is the node feature matrix of the lth graph convolutional layer, represents the normalized adjacency matrix, W (l) is the learnable weight matrix of the lth graph convolutional layer, σ is the activation function, is the normalized adjacency matrix.
4. The method for detecting anomaly of power data based on graph neural network according to claim 2, characterized in that: The output layer is constructed as follows: Z=H (L) W out In the formula, H (L) is the node feature matrix of the Lth graph convolutional layer, W out is the weight matrix of the output layer.
5. The method for detecting anomalies in power data based on graph neural network according to claim 1, characterized in that: During the training process, the mean square error is used to calculate the loss value, and the Adam algorithm is used to optimize the model parameters.
6. The method for detecting anomalies in power data based on graph neural network according to claim 1, characterized in that: The comparison strategy is to determine whether the relative difference between the predicted value and the actual value is less than a preset threshold. If so, it is normal, otherwise it is abnormal.
7. The method for detecting anomalies in power data based on graph neural network according to claim 1, characterized in that: The calculation formula of the relative difference is:
8. The method for detecting anomalies in power data based on graph neural network according to claim 1, characterized in that: The method further comprises: Acquire abnormal power data of the power data and construct an abnormal power data set; Perform data enhancement on abnormal power data sets and build an abnormal power database; The current power data is matched with the abnormal power data. If the match is unsuccessful, the predicted value is compared with the actual value according to the predicted comparison strategy, otherwise there is an abnormality.
9. The method for detecting anomalies in power data based on graph neural network according to claim 8, characterized in that: The data enhancement uses a GAN network to generate abnormal power data.
Citation Information
Cited By
Data processing method and device of graph neural network, and storage medium
CN121580111A
A data processing method and device of a graph neural network and a storage medium
CN121580111B