Method for detecting abnormal data of electric energy meter

By constructing a multi-scale spatiotemporal graph neural network model and a self-supervised abnormal feature separation module, the problem of insufficient multi-scale temporal feature fusion capability of electricity meters is solved, high-precision electricity meter anomaly detection is achieved, and the effectiveness of power grid security early warning is improved.

CN120561747BActive Publication Date: 2025-10-10SHANXI YINHE ELECTRIC POWER INSTR CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511053901.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-07-30
Publication Date
2025-10-10
Estimated Expiration
2045-07-30

AI Technical Summary

Technical Problem

Existing electricity meter anomaly detection methods have low detection accuracy due to their insufficient ability to fuse multi-scale time features. They are unable to effectively associate the dynamic dependencies of multi-scale time features, resulting in a high missed detection rate for complex anomalies.

Method used

By constructing a multi-scale spatiotemporal graph neural network model, including a local mutation module, a device association module, and a periodic pattern module, feature vectors of time windows at the second, minute, and hour levels are extracted, and a fused feature vector is generated using a self-supervised anomaly feature separation module and a dynamic weight fusion module. Finally, the anomaly probability value is output through a pre-trained anomaly scoring classifier.

Benefits of technology

It significantly improves the detection accuracy of complex abnormal patterns of electricity meters, reduces dependence on labeled data, and realizes efficient and adaptive power grid safety early warning.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120561747B_ABST
    Figure CN120561747B_ABST
Patent Text Reader

Abstract

The application provides an electric energy meter data anomaly detection method, in particular to the electric energy meter data detection technical field based on artificial intelligence, which acquires original electric energy meter data, generates second-level, minute-level and hour-level multi-scale time series through sliding window segmentation; constructs a multi-scale space-time graph neural network model containing local mutation, device correlation and periodic pattern modules, respectively extracts feature vectors of each time window; inputs the sequence to output the feature vectors, decouples them through a self-supervised anomaly feature separation module to generate a multi-scale anomaly feature set; then, a dynamic weight fusion module fuses the multi-scale anomaly feature set based on a multi-head attention mechanism to form a fusion feature vector; finally, the fusion feature vector is input into a pre-trained anomaly score classifier to output an anomaly probability value, and a dynamic threshold determination module generates a detection result, thereby improving the complex anomaly detection accuracy, reducing the dependence on labeling and realizing power grid safety early warning.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of electric energy meter data detection based on artificial intelligence, and in particular to a method for detecting anomalies in electric energy meter data. Background Art

[0002] With the large-scale deployment of smart meters in power grids, the multi-scale time series data they generate (such as second-level instantaneous load and daily power consumption trends) have become the core basis for anomaly detection. However, complex temporal patterns (transient mutations superimposed on long-term anomalies) have significantly reduced the accuracy of existing detection models, seriously threatening the safety of power grid equipment.

[0003] Traditional methods use a single time window (such as an LSTM fixed sliding window) or independently analyze data at different scales (such as processing second-level and hour-level series separately). These methods cannot effectively correlate the dynamic dependencies of multi-scale time features (for example, the impact of a momentary overload on subsequent power consumption), resulting in a high rate of missed detection of complex anomalies.

[0004] In summary, how to solve the technical problem of low accuracy of anomaly detection in electricity meters caused by insufficient multi-scale temporal feature fusion capability is an urgent problem to be solved. Summary of the Invention

[0005] The main purpose of the present invention is to provide a method for detecting anomalies in electricity meter data, so as to at least solve the technical problem of low accuracy in detecting anomalies in electricity meters due to insufficient multi-scale temporal feature fusion capabilities, significantly improve the detection accuracy of complex anomaly patterns in electricity meters, and at the same time reduce dependence on labeled data, thereby achieving efficient and adaptive power grid safety early warning.

[0006] In order to achieve the above object, the present invention provides a method for detecting abnormality in electric energy meter data.

[0007] The present invention provides a method for detecting abnormality in electric energy meter data, the method comprising:

[0008] Obtaining raw data from an electric energy meter, and segmenting the raw data from the electric energy meter using a sliding window to generate a multi-scale time series including a second-level time window, a minute-level time window, and an hour-level time window;

[0009] Constructing a multi-scale spatiotemporal graph neural network model, which includes a local mutation module for extracting feature vectors of second-level time windows, a device association module for extracting feature vectors of minute-level time windows, and a periodic pattern module for extracting feature vectors of hour-level time windows;

[0010] Inputting the multi-scale time series into the multi-scale spatiotemporal graph neural network model, and outputting the second-level time window feature vector, the minute-level time window feature vector, and the hour-level time window feature vector respectively;

[0011] Constructing a self-supervised abnormal feature separation module, performing abnormal feature separation on the second-level time window feature vector, the minute-level time window feature vector, and the hour-level time window feature vector to generate a decoupled multi-scale abnormal feature set;

[0012] Constructing a dynamic weight fusion module, inputting the decoupled multi-scale abnormal feature set into the dynamic weight fusion module, performing weighted fusion on the decoupled multi-scale abnormal feature set based on a multi-head attention mechanism, and generating a fused feature vector;

[0013] The fused feature vector is input into a pre-trained anomaly scoring classifier, an anomaly probability value is output, and the final anomaly detection result is generated in combination with a dynamic threshold determination module.

[0014] Specifically, the method of acquiring the raw data of the electric energy meter and segmenting the raw data of the electric energy meter by a sliding window to generate a multi-scale time series including a second-level time window, a minute-level time window, and an hour-level time window includes:

[0015] Standardizing the original data of the electric energy meter to generate an original time series;

[0016] Perform sliding window segmentation on the original time series to generate the second-level time window, the minute-level time window, and the hour-level time window, wherein: the second-level time window has a second-level window length of 5-60 seconds, and the second-level sliding step is 1 / 5-1 / 2 of the second-level window length; the minute-level time window has a minute-level window length of 1-15 minutes, and the minute-level sliding step is 1 / 5-1 / 2 of the minute-level window length; the hour-level time window has an hour-level window length of 1-24 hours, and the hour-level sliding step is 1 / 5-1 / 2 of the hour-level window length;

[0017] The second-level time window, the minute-level time window, and the hour-level time window are merged into the multi-scale time series.

[0018] Specifically, the construction of a multi-scale spatiotemporal graph neural network model includes:

[0019] Constructing the local mutation module consisting of a 1D convolutional layer and a maximum pooling layer;

[0020] Constructing the device association module consisting of an adjacency matrix generation layer and a graph attention network layer;

[0021] Constructing the periodic pattern module consisting of a temporal convolutional network layer and a global average pooling layer;

[0022] The local mutation module, the device association module and the periodic pattern module are integrated into the spatiotemporal graph structure to generate the multi-scale spatiotemporal graph neural network model.

[0023] Specifically, inputting the multi-scale time series into the multi-scale spatiotemporal graph neural network model and outputting the second-level time window feature vector, the minute-level time window feature vector, and the hour-level time window feature vector respectively include:

[0024] Inputting the time series of the second-level time window into the local mutation module, extracting local mutation features through the 1D convolution layer and the maximum pooling layer, and generating the second-level time window feature vector;

[0025] Inputting the time series of the minute-level time window into the device association module, extracting inter-device association features through the adjacency matrix generation layer and the graph attention network layer, and generating the minute-level time window feature vector;

[0026] The time series of the hourly time window is input into the periodic pattern module, and the periodic energy consumption trend features are extracted through the temporal convolutional network layer and the global average pooling layer to generate the hourly time window feature vector.

[0027] Specifically, the extracting inter-device association features through the adjacency matrix generation layer and the graph attention network layer includes:

[0028] Generate a device node adjacency matrix based on the physical topological connection relationship of the electric energy meter through the adjacency matrix generation layer;

[0029] The graph attention network layer calculates the attention weights between device nodes based on the device node adjacency matrix and the time series of the minute-level time window to generate the inter-device association features.

[0030] Specifically, the self-supervised abnormal feature separation module includes:

[0031] Constructing a mask reconstruction unit, wherein the mask reconstruction unit includes a random masking layer and a decoder;

[0032] Constructing a contrastive learning unit, wherein the contrastive learning unit includes a temporal enhancement layer and a contrastive loss calculation layer;

[0033] An output feature splicing unit is constructed, and the output of the mask reconstruction unit and the output of the contrast learning unit are input into the output feature splicing unit to generate the self-supervised abnormal feature separation module.

[0034] Specifically, the self-supervised abnormal feature separation module performs abnormal feature separation on the second-level time window feature vector, the minute-level time window feature vector, and the hour-level time window feature vector to generate a decoupled multi-scale abnormal feature set, including:

[0035] Inputting the second-level time window feature vector, the minute-level time window feature vector, and the hour-level time window feature vector into the mask reconstruction unit respectively, and generating mask reconstruction features through the random masking layer and the decoder reconstruction;

[0036] Inputting the second-level time window feature vector, the minute-level time window feature vector, and the hour-level time window feature vector into the contrastive learning unit respectively, and generating contrastive decoupling features through the temporal enhancement layer and the contrastive loss calculation layer;

[0037] The mask reconstruction feature and the contrast decoupling feature are merged through the output feature splicing unit to generate the decoupled multi-scale abnormal feature set.

[0038] Specifically, the dynamic weight fusion module is constructed, the decoupled multi-scale abnormal feature set is input into the dynamic weight fusion module, and the decoupled multi-scale abnormal feature set is weightedly fused based on the multi-head attention mechanism to generate a fused feature vector, including:

[0039] Constructing a dynamic weight fusion module, wherein the dynamic weight fusion module is implemented based on the multi-head attention mechanism, and the dynamic weight fusion module includes a query vector mapping unit, a key vector mapping unit, a value vector mapping unit, and a weighted summation unit;

[0040] Inputting the decoupled multi-scale abnormal feature set into the dynamic weight fusion module, and generating a query vector, a key vector and a value vector through the query vector mapping unit, the key vector mapping unit and the value vector mapping unit respectively;

[0041] Calculating the similarity score between the query vector and the key vector based on the multi-head attention mechanism, and generating a weight coefficient by normalizing it through a Softmax function;

[0042] The weight coefficient and the value vector are input into the weighted summation unit for weighted summation to generate the fused feature vector.

[0043] The present application provides a method for detecting anomalies in electric energy meter data. The method obtains the original data of the electric energy meter and generates a multi-scale time series containing second-level, minute-level and hour-level time windows through sliding window segmentation; constructs a multi-scale spatiotemporal graph neural network model, which includes a local mutation module, a device association module and a periodic pattern module, which are used to extract feature vectors of second-level, minute-level and hour-level time windows respectively; inputs the multi-scale time series into the model and outputs the feature vectors of each time window; constructs a self-supervised abnormal feature separation module to separate the abnormal features of the feature vectors and generate a decoupled multi-scale abnormal feature set; constructs a dynamic weight fusion module to perform weighted fusion of the set based on the multi-head attention mechanism to generate a fused feature vector; inputs the fused feature vector into a pre-trained anomaly scoring classifier, outputs an abnormal probability value, and combines it with a dynamic threshold judgment module to generate the final anomaly detection result. This method can improve the detection accuracy of complex abnormal patterns, reduce labeling dependence, and achieve power grid security early warning. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] The accompanying drawings, which constitute part of this application, are intended to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are intended to explain the present invention and do not constitute an undue limitation of the present invention. In the accompanying drawings:

[0045] Figure 1 A flow chart of the method for detecting anomaly in electricity meter data provided in this application.

[0046] The above drawings illustrate specific embodiments of the present application, which will be described in more detail below. These drawings and the textual description are not intended to limit the scope of the present application in any way, but rather to illustrate the concepts of the present application to those skilled in the art by reference to specific embodiments. DETAILED DESCRIPTION

[0047] To make the purpose, technical solutions, and advantages of this application more clear, the technical solutions in this application will be clearly and completely described below in conjunction with the drawings in this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.

[0048] The terms "seconds," "minutes," "hours," "fourth," and the like (if any) in the present description and claims and in the accompanying drawings are used to distinguish between similar items and are not necessarily used to describe a particular order or sequential sequence. It should be understood that the terms used in this manner are interchangeable where appropriate, such that the embodiments of the present invention described herein can be practiced in sequences other than those illustrated or described herein.

[0049] In the present invention, words such as "exemplary" or "for example" are used to indicate examples, illustrations, or descriptions. Any embodiment or design described in this application as "exemplary" or "for example" should not be construed as being preferred or advantageous over other embodiments or designs. Rather, the use of words such as "exemplary" or "for example" is intended to present the relevant concepts in a concrete manner.

[0050] The present application provides a method for detecting anomalies in electricity meter data. The method segments the raw data of the electricity meter through a sliding window to generate multi-scale time series at the second, minute, and hour levels. A multi-scale spatiotemporal graph neural network model is constructed, integrating local mutation, device association, and periodic pattern modules to extract feature vectors of each time window respectively. The method utilizes a self-supervised anomaly feature separation module to decouple features and generate a multi-scale anomaly feature set. The method dynamically weights and fuses features based on a multi-head attention mechanism and combines a pre-trained classifier to output anomaly probability values ​​to achieve efficient and accurate power grid safety early warning.

[0051] The following specific embodiments describe in detail the technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.

[0052] Figure 1 The flowchart of the method for detecting abnormality of electric energy meter data provided by this application is as follows: Figure 1 As shown in FIG, a method for detecting abnormality in electric energy meter data provided by this embodiment includes:

[0053] S101: Obtaining raw data from an electric energy meter, and segmenting the raw data from the electric energy meter using a sliding window to generate a multi-scale time series including a second-level time window, a minute-level time window, and an hour-level time window.

[0054] Specifically, the method of acquiring the raw data of the electric energy meter and segmenting the raw data of the electric energy meter by a sliding window to generate a multi-scale time series including a second-level time window, a minute-level time window, and an hour-level time window includes:

[0055] Standardizing the original data of the electric energy meter to generate an original time series;

[0056] Perform sliding window segmentation on the original time series to generate the second-level time window, the minute-level time window, and the hour-level time window, wherein: the second-level time window has a second-level window length of 5-60 seconds, and the second-level sliding step is 1 / 5-1 / 2 of the second-level window length; the minute-level time window has a minute-level window length of 1-15 minutes, and the minute-level sliding step is 1 / 5-1 / 2 of the minute-level window length; the hour-level time window has an hour-level window length of 1-24 hours, and the hour-level sliding step is 1 / 5-1 / 2 of the hour-level window length;

[0057] The second-level time window, the minute-level time window, and the hour-level time window are merged into the multi-scale time series.

[0058] During implementation, step S101 specifically includes:

[0059] 1. Data acquisition and preprocessing

[0060] 1.1 Electricity meter raw data: Collects historical operating data of the electricity meter, including parameters such as voltage, current, active power, reactive power, etc. The data is collected once per second and stored in a time series format.

[0061] 1.2 Standardization Processing: The Z-score standardization algorithm is used on the raw data of the electric energy meter to eliminate the dimension difference. The formula is as follows:

[0062]

[0063] in, is the original data value, is the data mean, is the standard deviation. After standardization, the original time series is generated and recorded as , at each time point Contains standardized voltage, current and other characteristics.

[0064] 2. Multi-scale sliding window segmentation

[0065] 2.1-second time window generation:

[0066] Window duration: 30 seconds (adjustable from 5 to 60 seconds);

[0067] Sliding step size: 6 seconds (the range is 1 / 5 of the window length, that is, 30 seconds × 1 / 5 = 6 seconds);

[0068] Operation: Slide T with a step length of 6 seconds to intercept 30-second segments and generate a set of second-level time windows .

[0069] 2.2-minute time window generation:

[0070] Window duration: 5 minutes (adjustable from 1 to 15 minutes);

[0071] Sliding step size: 1 minute (the range is 1 / 5 of the window duration, that is, 5 minutes × 1 / 5 = 1 minute);

[0072] Operation: Slide T with a step size of 1 minute to intercept 5-minute segments and generate a set of minute-level time windows .

[0073] 2.3 hour time window generation:

[0074] Window duration: 6 hours (adjustable from 1 to 24 hours);

[0075] Sliding step size: 1.2 hours (the range is 1 / 5 of the window length, that is, 6 hours × 1 / 5 = 1.2 hours);

[0076] Operation: Slide T to extract 6-hour segments with a step length of 1.2 hours to generate a set of hourly time windows. .

[0077] 3. Multi-scale time series merging

[0078] 3.1 Alignment rules: Align the second, minute, and hour time windows by timestamp to ensure that multi-scale data at the same time point covers the same physical event.

[0079] 3.2 Data Structure: The three time window sets are merged into a multi-scale time series S with a dimension of (N×D×3), where N is the number of time steps; D is the feature dimension (voltage, current, etc.); and 3 represents the scales of seconds, minutes, and hours.

[0080] This step eliminates data dimension differences through Z-score normalization, ensuring the stability of subsequent model training. Multi-scale sliding window segmentation (second, minute, and hour levels) captures transient mutations, device associations, and cyclical trend characteristics of electricity meter data. Timestamp alignment and merging generate unified multi-scale time series, providing standardized input for subsequent spatiotemporal graph neural networks. This step addresses the limited analytical capabilities of a single time scale and lays the data foundation for multi-scale feature fusion and anomaly detection.

[0081] S102: Construct a multi-scale spatiotemporal graph neural network model, wherein the multi-scale spatiotemporal graph neural network model includes a local mutation module for extracting feature vectors of second-level time windows, a device association module for extracting feature vectors of minute-level time windows, and a periodic pattern module for extracting feature vectors of hour-level time windows;

[0082] Specifically, the construction of a multi-scale spatiotemporal graph neural network model includes:

[0083] Constructing the local mutation module consisting of a 1D convolutional layer and a maximum pooling layer;

[0084] Constructing the device association module consisting of an adjacency matrix generation layer and a graph attention network layer;

[0085] Constructing the periodic pattern module consisting of a temporal convolutional network layer and a global average pooling layer;

[0086] The local mutation module, the device association module and the periodic pattern module are integrated into the spatiotemporal graph structure to generate the multi-scale spatiotemporal graph neural network model.

[0087] During implementation, step S102 specifically includes:

[0088] 1. Constructing a local mutation module

[0089] 1.1 Module structure:

[0090] 1D convolutional layer: Use a convolution kernel with a kernel size of 3 and a stride of 1, the activation function is ReLU, the input dimension is the original feature dimension of the second-level time window (for example, 6 dimensions such as voltage and current), and the number of output channels is 64.

[0091] Max pooling layer: The pooling window size is 2 and the stride is 2, which is used to reduce the dimension and retain the local mutation features.

[0092] 1.2 Input and Output:

[0093] Input: Time series with second-level time windows (30 seconds × 6-dimensional features);

[0094] Output: Second-level time window feature vector (After pooling the time step is reduced to 15).

[0095] 2. Build device association module

[0096] 2.1 Adjacency matrix generation layer:

[0097] Physical topology connection relationship: Define the device node adjacency matrix based on the actual installation location of the energy meter and the circuit connection relationship , where N is the number of device nodes. If two devices are directly connected, , otherwise 0.

[0098] 2.2 Graph Attention Network Layer:

[0099] Attention coefficient calculation: Using Graph Attention Network (GAT), calculation node With neighboring nodes The attention weight :

[0100]

[0101] in, is the feature vector of node i, For nodes The eigenvector of , W is the learnable weight matrix, is the attention parameter vector, Represents a concatenation operation, LeakyReLU is a rectified linear unit activation function with a leakage coefficient, and T represents the transpose of a vector or matrix.

[0102] Output update: The node feature update formula is:

[0103]

[0104] in, is the updated feature vector of node i, represents the Sigmoid activation function, is the set of neighbor nodes of node i.

[0105] 2.3 Input and Output:

[0106] Input: Time series with minute-level time windows (5 minutes × 6-dimensional features);

[0107] Output: Inter-device association feature vector (N is the number of device nodes).

[0108] 3. Build a cycle mode module

[0109] 3.1 Temporal Convolutional Network Layer:

[0110] Dilated convolution: Use causal convolution with a dilation factor of 2, a kernel size of 3, 4 layers, and 64 output channels per layer.

[0111] Residual connection: The output of each layer is added to the input to avoid gradient disappearance.

[0112] 3.2 Global average pooling layer: Average pooling is performed on the time dimension, and the output dimension is 64.

[0113] 3.3 Input and Output:

[0114] Input: Time series with hourly time windows (6 hours × 6-dimensional features);

[0115] Output: Periodic energy consumption trend feature vector .

[0116] 4. Integration into the spatiotemporal graph structure

[0117] 4.1 Definition of space-time graph:

[0118] Node: Second-level, minute-level, hour-level feature vectors , , ;

[0119] Edge: Device connections are constructed based on the adjacency matrix A of the device association module, and cross-scale connections are achieved through timestamp alignment.

[0120] 4.2 Model Integration: After aligning the outputs of the three modules by timestamp, the node features are updated through graph structure propagation to generate a multi-scale spatiotemporal graph neural network model.

[0121] This step uses a local mutation module to capture second-level data mutations (such as voltage sags), a device association module to model topological relationships between devices (such as load correlation between parallel meters), and a periodic pattern module to extract hourly cyclical trends (such as daily peak electricity consumption). This model also enables cross-scale feature interaction through a spatiotemporal graph structure. This model addresses the problem of insufficient feature extraction capabilities at a single time scale and provides a multi-level, highly discriminative feature representation for subsequent anomaly detection.

[0122] S103: Input the multi-scale time series into the multi-scale spatiotemporal graph neural network model, and output the second-level time window feature vector, the minute-level time window feature vector, and the hour-level time window feature vector respectively;

[0123] Specifically, inputting the multi-scale time series into the multi-scale spatiotemporal graph neural network model and outputting the second-level time window feature vector, the minute-level time window feature vector, and the hour-level time window feature vector respectively include:

[0124] Inputting the time series of the second-level time window into the local mutation module, extracting local mutation features through the 1D convolution layer and the maximum pooling layer, and generating the second-level time window feature vector;

[0125] The time series of the minute-level time window is input into the device association module, and the device association features are extracted through the adjacency matrix generation layer and the graph attention network layer to generate the minute-level time window feature vector; wherein, the extraction of the device association features through the adjacency matrix generation layer and the graph attention network layer includes: generating a device node adjacency matrix based on the physical topological connection relationship of the electricity meter through the adjacency matrix generation layer; calculating the attention weights between device nodes according to the device node adjacency matrix and the time series of the minute-level time window through the graph attention network layer to generate the device association features.

[0126] The time series of the hourly time window is input into the periodic pattern module, and the periodic energy consumption trend features are extracted through the temporal convolutional network layer and the global average pooling layer to generate the hourly time window feature vector.

[0127] During implementation, step S103 specifically includes:

[0128] 1. Second-level time window feature extraction (local mutation module)

[0129] 1.1 Input data: time series with second-level time windows (30 seconds × 6-dimensional features, including parameters such as voltage and current).

[0130] 1.2 1D convolution layer operation:

[0131] Convolution kernel parameters: kernel size 3, stride 1, number of channels 64, activation function ReLU.

[0132] Calculation process:

[0133]

[0134] in, Represents the output feature map of the convolutional layer, represents the convolution operation, is the convolution kernel, is the bias term.

[0135] 1.3 Maximum pooling layer operation:

[0136] Pooling parameters: window size 2, step size 2.

[0137] Output: Second-level time window feature vector .

[0138] 2. Minute-level time window feature extraction (device association module)

[0139] 2.1 Input data: time series with minute-level time windows (5 minutes × 6-dimensional features).

[0140] 2.2 Adjacency matrix generation layer operation:

[0141] Physical topology rules: Generate a device node adjacency matrix based on the circuit connection relationship of the energy meter (such as parallel or series connection) , where N is the number of device nodes. If device i is directly connected to device j, then .

[0142] 2.3 Graph Attention Network Layer Operation:

[0143] Node feature initialization: Group minute-level time series by device to generate a node feature matrix .

[0144] Attention weight calculation: Graph Attention Network (GAT) is used, and the formula is as follows:

[0145] ;

[0146] in, is the learnable weight matrix, is the attention parameter vector, Represents a splicing operation.

[0147] Feature Updates:

[0148]

[0149] in, is the Sigmoid activation function.

[0150] Output result: device association feature vector .

[0151] 3. Hourly time window feature extraction (periodic pattern module)

[0152] 3.1 Input data: time series with hourly time windows (6 hours × 6 dimensional features).

[0153] 3.2 Temporal Convolutional Network Layer Operation:

[0154] Dilated causal convolution: Use 4 layers of dilated convolution with dilation coefficients of [1, 2, 4, 8], kernel size 3 per layer, 64 channels, and residual connection structure.

[0155] Calculation process:

[0156]

[0157] in, is the layer number, Indicates the The output tensor of the layer, For the The dilated convolution kernel of the layer, Indicates the The input tensor of the layer.

[0158] 3.3 Global average pooling layer operation:

[0159] Pooling method: take the average of the time dimension (360 steps) and output dimension 64.

[0160] Output result: Periodic energy consumption trend characteristic vector ;

[0161] This step uses the local mutation module to capture transient mutations (such as voltage sags) in second-level data, the device association module to model topological relationships between devices (such as load correlations between parallel meters), and the periodic pattern module to extract hourly periodic trends (such as daily peak electricity consumption). The graph attention network (GAT) dynamically assigns weights for associations between devices, and the temporal convolutional network (TCN) uses dilated convolutions to capture long-term dependencies. This step addresses the inadequacy of traditional methods in modeling multi-scale feature associations, providing highly discriminative feature representations for subsequent anomaly detection. It also reduces reliance on labeled data, improving detection accuracy and robustness.

[0162] S104: Construct a self-supervised abnormal feature separation module, and perform abnormal feature separation on the second-level time window feature vector, the minute-level time window feature vector, and the hour-level time window feature vector through the self-supervised abnormal feature separation module to generate a decoupled multi-scale abnormal feature set;

[0163] Specifically, the self-supervised abnormal feature separation module includes:

[0164] Constructing a mask reconstruction unit, wherein the mask reconstruction unit includes a random masking layer and a decoder;

[0165] Constructing a contrastive learning unit, wherein the contrastive learning unit includes a temporal enhancement layer and a contrastive loss calculation layer;

[0166] An output feature splicing unit is constructed, and the output of the mask reconstruction unit and the output of the contrast learning unit are input into the output feature splicing unit to generate the self-supervised abnormal feature separation module.

[0167] Specifically, the self-supervised abnormal feature separation module performs abnormal feature separation on the second-level time window feature vector, the minute-level time window feature vector, and the hour-level time window feature vector to generate a decoupled multi-scale abnormal feature set, including:

[0168] Inputting the second-level time window feature vector, the minute-level time window feature vector, and the hour-level time window feature vector into the mask reconstruction unit respectively, and generating mask reconstruction features through the random masking layer and the decoder reconstruction;

[0169] Inputting the second-level time window feature vector, the minute-level time window feature vector, and the hour-level time window feature vector into the contrastive learning unit respectively, and generating contrastive decoupling features through the temporal enhancement layer and the contrastive loss calculation layer;

[0170] The mask reconstruction feature and the contrast decoupling feature are merged through the output feature splicing unit to generate the decoupled multi-scale abnormal feature set.

[0171] During implementation, step S104 specifically includes:

[0172] 1. Constructing a mask reconstruction unit

[0173] 1.1 Random masking layer:

[0174] Masking method: The input second-level, minute-level, and hour-level time window feature vectors (dimensions are ) Randomly mask 15%-40% of the time steps or feature channels, and the masked positions are randomly generated by uniform distribution.

[0175] Masking mark: replace the masked part with a zero vector to generate the masked feature vector .

[0176] 1.2 Decoder:

[0177] Structure: 3-layer fully connected neural network, activation function is ReLU, input dimension is consistent with the masked feature, output dimension is the same as the original feature.

[0178] Reconstruction loss function: Use mean square error (MSE) loss, the formula is:

[0179]

[0180] in, represents the reconstruction loss value, is the number of samples, represents the original feature vector of the i-th sample, Represents the reconstructed feature vector of the i-th sample (output after random masking and decoder reconstruction).

[0181] 1.3 Output: Mask Reconstruction Features , the dimension is consistent with the input features.

[0182] 2. Construct a comparative learning unit

[0183] 2.1 Timing Enhancement Layer:

[0184] Enhancement method: Perform the following operations on normal samples (data marked as non-abnormal) to generate positive sample pairs:

[0185] Noise: Add Gaussian noise N(0,0.1);

[0186] Segment permutation: Randomly swap the order of two time segments (for example, swap the first 10 seconds and the last 10 seconds of a second-level window).

[0187] Negative sample generation: Randomly replace some time segments in normal samples with abnormal segments (such as voltage drop segments).

[0188] 2.2 Contrast loss calculation layer:

[0189] Loss function: InfoNCE loss is used, the formula is:

[0190]

[0191] in, represents the contrast loss value, is the anchor feature, is the positive sample feature, is a negative sample feature, sim( ) is the cosine similarity, =0.07 is the temperature parameter, and K represents the total number of negative samples.

[0192] 2.3 Output: Comparative Decoupling Features .

[0193] 3. Construct output feature splicing unit

[0194] 3.1 Stitching method: reconstructing features from masks Compared with decoupling features Splicing in the channel dimension to generate a decoupled multi-scale anomaly feature set , where N is the number of time steps and 2D is the feature dimension (for example, the dimension after concatenating second-level, minute-level, and hour-level features).

[0195] 3.2 Normalization: Layer Normalization of the concatenated features

[0196] This step uses a mask reconstruction unit to force the model to learn the distribution of normal data (abnormal data is difficult to reconstruct). A comparative learning unit narrows the similarities between normal samples and pushes anomalous samples away, thereby isolating anomalous features. The output feature concatenation unit fuses the two self-supervisory signals to generate a highly discriminative multi-scale anomaly feature set. This module addresses the reliance on labeled data in traditional supervised methods, significantly improving the generalization and robustness of anomaly detection. It is particularly suitable for complex anomaly scenarios in power grids, where labeled data is scarce.

[0197] S105: Construct a dynamic weight fusion module, input the decoupled multi-scale abnormal feature set into the dynamic weight fusion module, perform weighted fusion on the decoupled multi-scale abnormal feature set based on a multi-head attention mechanism, and generate a fusion feature vector;

[0198] Specifically, the dynamic weight fusion module is constructed, the decoupled multi-scale abnormal feature set is input into the dynamic weight fusion module, and the decoupled multi-scale abnormal feature set is weightedly fused based on the multi-head attention mechanism to generate a fused feature vector, including:

[0199] Constructing a dynamic weight fusion module, wherein the dynamic weight fusion module is implemented based on the multi-head attention mechanism, and the dynamic weight fusion module includes a query vector mapping unit, a key vector mapping unit, a value vector mapping unit, and a weighted summation unit;

[0200] Inputting the decoupled multi-scale abnormal feature set into the dynamic weight fusion module, and generating a query vector, a key vector and a value vector through the query vector mapping unit, the key vector mapping unit and the value vector mapping unit respectively;

[0201] Calculating the similarity score between the query vector and the key vector based on the multi-head attention mechanism, and generating a weight coefficient by normalizing it through a Softmax function;

[0202] The weight coefficient and the value vector are input into the weighted summation unit for weighted summation to generate the fused feature vector.

[0203] During implementation, step S105 specifically includes:

[0204] 1. Construction of dynamic weight fusion module

[0205] 1.1 Module structure:

[0206] Query vector mapping unit: fully connected neural network layer, the input dimension is the decoupled multi-scale anomaly feature set dimension (assuming it is 2D), and the output dimension is , the weight matrix , without bias term.

[0207] Key vector mapping unit: fully connected neural network layer, input dimension 2D, output dimension , the weight matrix .

[0208] Value vector mapping unit: fully connected neural network layer, input dimension 2D, output dimension , the weight matrix .

[0209] Weighted summation unit: linear weighted layer, input dimension , output dimension .

[0210] 2. Input data preparation

[0211] 2.1 Input data: Decoupled multi-scale anomaly feature set , where N is the number of time steps and 2D is the feature dimension (for example, the dimension after concatenating second-level, minute-level, and hour-level features).

[0212] 3. Multi-head attention mechanism calculation process

[0213] Step 1: Generate query vector, key vector, and value vector

[0214] Query vector:

[0215] .

[0216] Key vector:

[0217] .

[0218] Value vector:

[0219] .

[0220] Step 2: Calculate similarity score and weight coefficient

[0221] Similarity score: Using dot product attention, the formula is:

[0222]

[0223] in, represents the attention score, is the scaling factor to prevent gradient explosion, and T represents the matrix transpose.

[0224] Normalized weights: Normalize each row using the Softmax function:

[0225] .

[0226] Step 3: Weighted summation to generate fused feature vector

[0227] Weighted sum:

[0228] .

[0229] 4. Parameter setting example

[0230] Dimension definition: = =64, the number of multi-head attention heads is 4, and finally generated by splicing multi-head outputs ;

[0231] This step uses a dynamic weight fusion module to adaptively assign weights to second-, minute-, and hour-level anomaly features based on a multi-head attention mechanism, addressing the poor adaptability of traditional fixed-weight fusion to complex anomaly patterns. The query vector mapping unit, key vector mapping unit, and value vector mapping unit each extract correlations between features, while the weighted summation unit achieves dynamic fusion through Softmax normalization. This module significantly improves the efficiency of multi-scale feature fusion, enhancing the ability to jointly detect sudden anomalies (such as instantaneous overloads) and long-term anomalies (such as equipment aging) in the power grid, while reducing the subjective bias of manually designed weights.

[0232] S106: Input the fused feature vector into a pre-trained anomaly scoring classifier, output an anomaly probability value, and combine it with a dynamic threshold judgment module to generate a final anomaly detection result.

[0233] During implementation, step S106 specifically includes:

[0234] 1. Construction and use of pre-trained anomaly scoring classifier

[0235] 1.1 Classifier Types:

[0236] Random Forest Classifier: Contains 100 decision trees, each with a maximum depth of 10, and the splitting criterion is the Gini coefficient.

[0237] Fully connected neural network classifier (alternative solution): The structure is 3 fully connected layers, the activation function is ReLU, the input dimension is consistent with the fusion feature vector dimension (for example, 256 dimensions), and the output dimension is 2 (normal / abnormal).

[0238] 1.2 Input data: fused feature vector .

[0239] 1.3 Classification process:

[0240] Random Forest Classifier: Outputs anomaly probability values ​​through majority voting ∈[0,1], the formula is:

[0241]

[0242] Among them, T=100 is the total number of trees, is the indicator function, Indicates the t-th decision tree for the input feature prediction results.

[0243] Fully connected neural network classifier: output probability value through Softmax function:

[0244]

[0245] in, is the weight matrix, 、 is the bias term.

[0246] 2. Implementation of the dynamic threshold determination module

[0247] 2.1 Collection of historical normal data: Filter samples marked as normal from the training set and extract their abnormal probability value set { , ,..., }.

[0248] 2.2 Threshold calculation:

[0249] Mean calculation:

[0250] .

[0251] Standard deviation calculation:

[0252] .

[0253] Dynamic Threshold:

[0254] .

[0255] 2.3 Real-time judgment rules:

[0256] If the real-time abnormal probability value >θ, it is determined to be abnormal and triggers an alarm;

[0257] like ≤θ, it is judged to be normal.

[0258] 3. Output the final detection results

[0259] Alarm signal generation: Bind the abnormality judgment result with the timestamp and device ID, generate a JSON format alarm message, and push it to the power grid monitoring system through the message queue;

[0260] This step uses a pre-trained anomaly scoring classifier to map the fused feature vector into an interpretable anomaly probability value, resolving the issue of traditional threshold setting relying on experience. A dynamic threshold determination module adaptively adjusts the determination threshold based on the statistical distribution of historical normal data, significantly reducing the false alarm rate. This step combines the classification capabilities of random forests or fully connected neural networks with the dynamic adjustment mechanism of the 3σ criterion to achieve high-precision and robust detection of electricity meter anomalies. This is particularly applicable to complex scenarios where sudden and long-term anomalies coexist in power grids, providing reliable technical support for grid security early warning.

[0261] This embodiment provides a method for detecting anomalies in electricity meter data. This method obtains raw meter data and uses sliding window segmentation to generate multi-scale time series at the second, minute, and hour levels. A multi-scale spatiotemporal graph neural network model is constructed, integrating a local mutation module, a device association module, and a periodic pattern module, each used to extract feature vectors from different time windows, thereby capturing multi-scale features of the electricity meter data. After the multi-scale time series is input into the model, feature vectors for each time window are output. These vectors are then decoupled using a self-supervised anomaly feature separation module to generate a multi-scale anomaly feature set. Subsequently, a dynamic weight fusion module performs weighted fusion of the feature set based on a multi-head attention mechanism to form a fused feature vector. Finally, the fused feature vector is input into a pre-trained anomaly scoring classifier, which outputs an anomaly probability value. This fused feature vector is then combined with a dynamic threshold judgment module to generate anomaly detection results. This method effectively addresses the issue of insufficient multi-scale temporal feature fusion capabilities, significantly improving the accuracy of complex anomaly pattern detection, reducing labeling dependency, and enabling safe and efficient early warning for the power grid.

[0262] Those skilled in the art will appreciate that all or some of the steps in the methods, systems, and functional modules / units in the apparatus disclosed above may be implemented as software, firmware, hardware, or appropriate combinations thereof.

[0263] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present application that follow the general principles of the present application and include common knowledge or customary techniques in the art not disclosed herein. The description and examples are to be considered as exemplary only, and the true scope and spirit of the present application are indicated by the following claims.

[0264] It should be understood that the present application is not limited to the exact structure described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.

Claims

1. A method for detecting abnormality in electric energy meter data, characterized in that: include: Obtaining raw data from an electric energy meter, and segmenting the raw data from the electric energy meter using a sliding window to generate a multi-scale time series including a second-level time window, a minute-level time window, and an hour-level time window; Constructing a multi-scale spatiotemporal graph neural network model, which includes a local mutation module for extracting feature vectors of second-level time windows, a device association module for extracting feature vectors of minute-level time windows, and a periodic pattern module for extracting feature vectors of hour-level time windows; Inputting the multi-scale time series into the multi-scale spatiotemporal graph neural network model, and outputting the second-level time window feature vector, the minute-level time window feature vector, and the hour-level time window feature vector respectively; Constructing a self-supervised abnormal feature separation module, performing abnormal feature separation on the second-level time window feature vector, the minute-level time window feature vector, and the hour-level time window feature vector to generate a decoupled multi-scale abnormal feature set; Constructing a dynamic weight fusion module, inputting the decoupled multi-scale abnormal feature set into the dynamic weight fusion module, performing weighted fusion on the decoupled multi-scale abnormal feature set based on a multi-head attention mechanism, and generating a fused feature vector; The fused feature vector is input into a pre-trained anomaly scoring classifier, an anomaly probability value is output, and the final anomaly detection result is generated in combination with a dynamic threshold determination module.

2. The method for detecting abnormality in electric energy meter data according to claim 1, characterized in that: The method of obtaining the raw data of the electric energy meter and segmenting the raw data of the electric energy meter by a sliding window to generate a multi-scale time series including a second-level time window, a minute-level time window, and an hour-level time window includes: Standardizing the original data of the electric energy meter to generate an original time series; Perform sliding window segmentation on the original time series to generate the second-level time window, the minute-level time window, and the hour-level time window, wherein: the second-level time window has a second-level window length of 5-60 seconds, and the second-level sliding step is 1 / 5-1 / 2 of the second-level window length; the minute-level time window has a minute-level window length of 1-15 minutes, and the minute-level sliding step is 1 / 5-1 / 2 of the minute-level window length; the hour-level time window has an hour-level window length of 1-24 hours, and the hour-level sliding step is 1 / 5-1 / 2 of the hour-level window length; The second-level time window, the minute-level time window, and the hour-level time window are merged into the multi-scale time series.

3. The method for detecting abnormality in electric energy meter data according to claim 1, wherein: The multi-scale spatiotemporal graph neural network model is constructed, including: Constructing the local mutation module consisting of a 1D convolutional layer and a maximum pooling layer; Constructing the device association module consisting of an adjacency matrix generation layer and a graph attention network layer; Constructing the periodic pattern module consisting of a temporal convolutional network layer and a global average pooling layer; The local mutation module, the device association module and the periodic pattern module are integrated into the spatiotemporal graph structure to generate the multi-scale spatiotemporal graph neural network model.

4. The method for detecting abnormality in electric energy meter data according to claim 3, characterized in that: Inputting the multi-scale time series into the multi-scale spatiotemporal graph neural network model and outputting the second-level time window feature vector, the minute-level time window feature vector, and the hour-level time window feature vector respectively include: Inputting the time series of the second-level time window into the local mutation module, extracting local mutation features through the 1D convolution layer and the maximum pooling layer, and generating the second-level time window feature vector; Inputting the time series of the minute-level time window into the device association module, extracting inter-device association features through the adjacency matrix generation layer and the graph attention network layer, and generating the minute-level time window feature vector; The time series of the hourly time window is input into the periodic pattern module, and the periodic energy consumption trend features are extracted through the temporal convolutional network layer and the global average pooling layer to generate the hourly time window feature vector.

5. The method for detecting abnormality in electric energy meter data according to claim 4, characterized in that: The extracting inter-device association features through the adjacency matrix generation layer and the graph attention network layer includes: Generate a device node adjacency matrix based on the physical topological connection relationship of the electric energy meter through the adjacency matrix generation layer; The graph attention network layer calculates the attention weights between device nodes based on the device node adjacency matrix and the time series of the minute-level time window to generate the inter-device association features.

6. The method for detecting abnormality in electric energy meter data according to claim 1, wherein: The self-supervised abnormal feature separation module includes: Constructing a mask reconstruction unit, wherein the mask reconstruction unit includes a random masking layer and a decoder; Constructing a contrastive learning unit, wherein the contrastive learning unit includes a temporal enhancement layer and a contrastive loss calculation layer; An output feature splicing unit is constructed, and the output of the mask reconstruction unit and the output of the contrast learning unit are input into the output feature splicing unit to generate the self-supervised abnormal feature separation module.

7. The method for detecting abnormality in electric energy meter data according to claim 6, characterized in that: The self-supervised abnormal feature separation module performs abnormal feature separation on the second-level time window feature vector, the minute-level time window feature vector, and the hour-level time window feature vector to generate a decoupled multi-scale abnormal feature set, including: Inputting the second-level time window feature vector, the minute-level time window feature vector, and the hour-level time window feature vector into the mask reconstruction unit respectively, and generating mask reconstruction features through the random masking layer and the decoder reconstruction; Inputting the second-level time window feature vector, the minute-level time window feature vector, and the hour-level time window feature vector into the contrastive learning unit respectively, and generating contrastive decoupling features through the temporal enhancement layer and the contrastive loss calculation layer; The mask reconstruction feature and the contrast decoupling feature are merged through the output feature splicing unit to generate the decoupled multi-scale abnormal feature set.

8. The method for detecting abnormality in electric energy meter data according to claim 1, wherein: The dynamic weight fusion module is constructed, the decoupled multi-scale abnormal feature set is input into the dynamic weight fusion module, and the decoupled multi-scale abnormal feature set is weightedly fused based on the multi-head attention mechanism to generate a fused feature vector, including: Constructing a dynamic weight fusion module, wherein the dynamic weight fusion module is implemented based on the multi-head attention mechanism, and the dynamic weight fusion module includes a query vector mapping unit, a key vector mapping unit, a value vector mapping unit, and a weighted summation unit; Inputting the decoupled multi-scale abnormal feature set into the dynamic weight fusion module, and generating a query vector, a key vector and a value vector through the query vector mapping unit, the key vector mapping unit and the value vector mapping unit respectively; Calculating the similarity score between the query vector and the key vector based on the multi-head attention mechanism, and generating a weight coefficient by normalizing it through a Softmax function; The weight coefficient and the value vector are input into the weighted summation unit for weighted summation to generate the fused feature vector.

Citation Information

Patent Citations

  • Method and device for identifying relationship between power grid electricity meter and area transformer

    CN112986721A

  • Multi-disaster-type disaster internet-of-things time sequence adaptive anomaly detection method and system

    CN120277447A