Segment consistency-based discriminative autoencoder electric energy meter anomaly detection method and device
Patent Information
- Application Number
- CN202310990071.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-08
- Publication Date
- 2026-10-16
- Estimated Expiration
- 2043-08-08
AI Technical Summary
现有的在线异常检测方法并不直接适用于电能表数据,异常检测性能也有待进一步提高
[0046] According to another aspect of the present invention, a computer-readable storage medium is provided, the storage medium storing a computer program for performing the methods described in any of the above aspects of the present invention.
Smart Images

Figure CN117092581B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of electricity meter testing technology, and more specifically, to a method and apparatus for detecting anomalies in electricity meters based on segment consistency discrimination self-encoders. Background Technology
[0002] Smart meters can collect multivariate time series data such as current, voltage, and energy readings from households and businesses. By analyzing the periodicity and trend of single-variable time series attributes over time, and analyzing the correlation and possible causal relationships between multivariate time series attributes, the normal patterns of multivariate time series can be learned and abnormal patterns can be identified and judged, thereby comprehensively analyzing and monitoring the operation of smart meters.
[0003] In practice, most smart meter data lacks accurate positive anomaly labels. Furthermore, due to the robustness of the meter equipment, the majority of data collected from actual meters is normal, with anomalies being rare and hidden within a large amount of normal data. Collecting and manually labeling a sufficient number of anomaly data requires significant cost and time. Therefore, unsupervised multidimensional time series anomaly detection methods trained using historical monitoring data under normal operating conditions are more suitable for smart meters. Traditional unsupervised anomaly detection methods independently consider historical monitoring data, ignoring the contextual relationships between time points, thus failing to capture complex structures and nonlinear relationships in the detection data. Moreover, traditional methods require re-traversing the training data during testing, and the enormous computational cost limits their scalability to large-scale data. Therefore, the current mainstream approach uses deep learning-based methods to better mine the time dependencies and correlations between variables in multivariate time series, achieving better anomaly detection results. Deep learning-based multivariate time series anomaly detection methods utilize complex neural networks to learn patterns in normal time series and distinguish between normal and anomalous data based on this characteristic. These methods can be divided into prediction-based and reconstruction-based methods. Prediction-based methods learn from historical time-series data, extract time-series patterns, and predict data for the next time point or period. The difference between the actual and predicted values is then used as an anomaly score to distinguish positive anomalies. Reconstruction-based methods typically use an encoder to compress the original data, learning and preserving key information in the time series. A decoder then reconstructs the original time series point by point, using the reconstruction error between the original and reconstructed time series as an anomaly score to detect abnormal data. To address the overfitting problem caused by noise in the data collected from smart meters in real-world environments, leading to models based on reconstruction methods, researchers have introduced contrastive learning methods for multivariate time-series anomaly detection. However, because these methods still follow the contrastive learning practices from computer vision and natural language processing, employing inductive bias and surrogate tasks unsuitable for time-series anomaly detection for data augmentation and model learning, further performance improvements of these multivariate time-series anomaly detection methods are limited.
[0004] Based on a review of relevant domestic and international literature, current anomaly detection methods for smart meters mainly fall into two categories: simple threshold judgment methods based on a single system and analysis methods based on static offline data. Simple threshold judgment methods based on a single system have limitations. On the one hand, they have low information utilization and state evaluation accuracy for smart meters; on the other hand, they struggle to detect periodic trend anomalies and abnormal correlations between multiple variables. Furthermore, the fixed thresholds in relevant standards are difficult to adapt to the varying operating conditions of smart meters. Analysis methods based on static offline data suffer from problems such as weak integration with online smart meter operation, inability to quickly reflect the operating status of smart meters, and failure to promptly detect anomalies. While anomaly detection methods based on online time series data have achieved some success in fields such as engine maintenance and wastewater treatment, they have not been applied in the field of smart meters. Existing online anomaly detection methods are not directly applicable to smart meter data, and their anomaly detection performance needs further improvement. Summary of the Invention
[0005] To address the shortcomings of existing technologies, this invention provides a method and apparatus for detecting anomalies in energy meters based on segment consistency discrimination self-encoders.
[0006] According to one aspect of the present invention, a method for detecting anomalies in an energy meter based on a segment consistency discrimination self-encoder is provided, comprising:
[0007] Acquire multivariate long-term series data of historical measurements of the energy meter under test;
[0008] Normalize multivariate long-term series data and divide the data into multiple time windows of preset window length;
[0009] Multiple time window data are input into a pre-trained anomaly detection model, and the reconstructed data corresponding to each time window data is output.
[0010] Based on the reconstructed data and the original data of each time window, the anomaly score of each time point in that time window is determined, and based on the anomaly score, the degree of anomaly of the energy meter under test at each time point is determined.
[0011] Optionally, the multivariate long-term series data includes: phase A current, phase B current, phase C current, phase A voltage, phase B voltage, phase C voltage, forward active energy indication, reverse active energy indication, forward reactive energy indication, reverse reactive energy indication, phase A active power, phase B active power, phase C active power, total active power, phase A reactive power, phase B reactive power, phase C reactive power, total reactive power, phase A power factor, phase B power factor, phase C power factor, and total power factor.
[0012] Optionally, after acquiring the multivariate long-term series data of the historical measurements of the energy meter under test, the method further includes:
[0013] Z-Score standardization is used to ensure that all values of each variable in a multivariate long-term series data conform to a standard normal distribution.
[0014] Alternatively, the formula for Z-Score standardization is:
[0015]
[0016] In the formula, X i For multivariate long-term series data, Represents the standardized X i μ represents X i The mean of all sample data for each variable, σ represents X. i The standard deviation of all sample data for each variable.
[0017] Optionally, the training process for the anomaly detection model is as follows:
[0018] Acquire multivariate time series data samples from multiple historical energy meter readings and merge them into a single multivariate long-term data sample.
[0019] Z-Score standardization is used to ensure that all values of each variable in a multivariate long-term series data sample conform to a standard normal distribution.
[0020] Standardized multivariate long-term series data samples are windowed and divided into multiple time windows of data samples with preset windows;
[0021] A multi-resolution random downsampling data augmentation method is used to augment data samples from multiple time windows to determine positive and negative sample pairs.
[0022] An encoder composed of GRUs is used to extract features from positive and negative sample pairs to determine the features of positive and negative sample pairs.
[0023] The total loss of the model is determined by identifying and reconstructing the features of positive and negative sample pairs through a pre-defined nonlinear discriminator, encoder, and decoder.
[0024] The network and parameters are updated and optimized based on the total loss to determine the anomaly detection model.
[0025] Optionally, a multi-resolution random downsampling data augmentation method is used to augment data samples from multiple time windows to determine positive and negative sample pairs, including:
[0026] Given a time window data sample, divide the time window data sample into segments and randomly select segments from the time window;
[0027] Preserve the relative order of the selected segments within the original time window to obtain positive samples;
[0028] Disorder the selected segments to obtain negative samples;
[0029] Two positive samples are randomly combined to form a positive sample pair;
[0030] A positive sample and a negative sample are randomly combined to form a negative sample pair.
[0031] Optionally, the encoder composed of GRUs consists of an embedding layer and a predetermined number of GRU stacks, wherein the embedding layer is composed of a fully connected linear layer for encoding time series;
[0032] The discriminator is a non-linear prediction head consisting of two fully connected layers, a batch normalization layer, and an activation function.
[0033] Optionally, the formula for calculating the total loss is:
[0034] L←L Dis +L Rec
[0035]
[0036]
[0037] In the formula, L represents the total loss. Dis To compare the loss of the judgment, L Rec The decoding and reconstruction loss is given by N, which represents the total number of samples, and y true ={0,1} represents the true label of the sample, y i For the classification results, P i Input sample, Decode and reconstruct the output.
[0038] Optionally, the formula for calculating the outlier score is:
[0039]
[0040] In the formula, AS t This represents the anomaly score at time t within the preset window. This represents the original data of variable i at time t. This represents the reconstructed data of variable i at time t, and M represents the number of variables in the multivariate long-term series data of the energy meter under test.
[0041] According to another aspect of the present invention, an anomaly detection device for an energy meter based on segment consistency discrimination self-encoder is provided, comprising:
[0042] The acquisition module is used to acquire multivariate long-term series data of historical tests of the energy meter under test;
[0043] The partitioning module is used to normalize multivariate long-term series data and divide the data into multiple time windows of a preset window length.
[0044] The output module is used to input multiple time window data into a pre-trained anomaly detection model and output the reconstructed data corresponding to each time window data.
[0045] The determination module is used to determine the anomaly score of each time point in the data of each time window based on the reconstructed data and the original data, and to determine the degree of anomaly of the energy meter under test at each time point based on the anomaly score.
[0046] According to another aspect of the present invention, a computer-readable storage medium is provided, the storage medium storing a computer program for performing the methods described in any of the above aspects of the present invention.
[0047] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising: a processor; a memory for storing executable instructions of the processor; the processor being configured to read the executable instructions from the memory and execute the instructions to implement the method described in any of the preceding aspects of the present invention.
[0048] Therefore, this invention addresses the issue of noise pollution affecting smart meter monitoring data during actual collection and the unsuitability of traditional anomaly detection methods' data augmentation and proxy tasks for time series anomaly detection. It proposes a contrastive autoencoder based on multi-resolution segmented consistency discrimination for anomaly detection in multivariate time series data from smart meters. The proposed random downsampling data augmentation method constructs a large number of labeled samples without introducing noise, resolving the problem of traditional data augmentation methods potentially disrupting the temporal dependencies of time series. A sample segment consistency discrimination proxy task is proposed to learn intra-segment local trend information and inter-segment contextual information at different resolutions. Through joint training of contrastive learning and reconstruction tasks, the model can simultaneously consider pixel-level and local information in the multivariate data of smart meters, improving the model's generalization ability and anomaly detection accuracy. Attached Figure Description
[0049] Exemplary embodiments of the present invention can be more fully understood by referring to the following figures:
[0050] Figure 1 This is a flowchart illustrating an anomaly detection method for an energy meter based on a segment consistency discrimination autoencoder, provided by an exemplary embodiment of the present invention.
[0051] Figure 2 This is a schematic diagram of the framework of an anomaly detection method for an energy meter based on segment consistency discrimination autoencoder provided in an exemplary embodiment of the present invention;
[0052] Figure 3 This is a flowchart of the feature extraction, comparison and discrimination, and decoding and reconstruction module provided in an exemplary embodiment of the present invention;
[0053] Figure 4 This is a schematic diagram of the structure of an abnormality detection device for an energy meter based on a segment consistency discrimination self-encoder provided in an exemplary embodiment of the present invention;
[0054] Figure 5 This is the structure of an electronic device provided in an exemplary embodiment of the present invention. Detailed Implementation
[0055] Hereinafter, exemplary embodiments according to the present invention will be described in detail with reference to the accompanying drawings. Obviously, the described embodiments are merely some embodiments of the present invention, and not all embodiments of the present invention. It should be understood that the present invention is not limited to the exemplary embodiments described herein.
[0056] It should be noted that, unless otherwise specifically stated, the relative arrangement, numerical expressions, and values of the components and steps described in these embodiments do not limit the scope of the invention.
[0057] Those skilled in the art will understand that the terms "first," "second," etc., in the embodiments of the present invention are only used to distinguish different steps, devices, or modules, and do not represent any specific technical meaning, nor do they indicate a necessary logical order between them.
[0058] It should also be understood that in the embodiments of the present invention, "multiple" can refer to two or more, and "at least one" can refer to one, two or more.
[0059] It should also be understood that any component, data or structure mentioned in the embodiments of the present invention can generally be understood as one or more unless explicitly defined or given contrary instructions in the context.
[0060] Furthermore, the term "and / or" in this invention is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone. Additionally, the character " / " in this invention generally indicates that the preceding and following related objects have an "or" relationship.
[0061] It should also be understood that the description of the various embodiments in this invention emphasizes the differences between the various embodiments, and the similarities or similarities can be referred to each other. For the sake of brevity, they will not be described in detail.
[0062] At the same time, it should be understood that, for ease of description, the dimensions of the various parts shown in the accompanying drawings are not drawn according to actual scale.
[0063] The following description of at least one exemplary embodiment is merely illustrative and is in no way intended to limit the invention or its application or use.
[0064] Techniques, methods, and equipment known to those skilled in the art may not be discussed in detail, but where appropriate, they should be considered part of the specification.
[0065] It should be noted that similar labels and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be discussed further in subsequent figures.
[0066] The embodiments of this invention can be applied to electronic devices such as terminal devices, computer systems, and servers, and can operate together with a wide range of other general-purpose or special-purpose computing system environments or configurations. Well-known examples of terminal devices, computing systems, environments, and / or configurations suitable for use with electronic devices such as terminal devices, computer systems, and servers include, but are not limited to: personal computer systems, server computer systems, thin clients, thick clients, handheld or laptop devices, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputer systems, mainframe computer systems, and distributed cloud computing environments including any of the above systems, etc.
[0067] Electronic devices such as terminal devices, computer systems, and servers can be described in the general context of computer system executable instructions (such as program modules) executed by a computer system. Typically, program modules can include routines, programs, object programs, components, logic, data structures, etc., which perform specific tasks or implement specific abstract data types. Computer systems / servers can be implemented in distributed cloud computing environments, where tasks are executed by remote processing devices linked through communication networks. In distributed cloud computing environments, program modules can reside on local or remote computing system storage media, including storage devices.
[0068] Exemplary methods
[0069] Figure 1 This is a schematic flowchart of an anomaly detection method for an energy meter based on a segment consistency discrimination self-encoder, provided by an exemplary embodiment of the present invention. This embodiment can be applied to electronic devices, such as… Figure 1 As shown, the anomaly detection method 100 for an energy meter based on segment consistency discrimination self-encoder includes the following steps:
[0070] Step 101: Obtain multivariate long-term series data of historical tests of the electricity meter under test;
[0071] Step 102: Normalize the multivariate long-term series data and divide it into multiple time windows of a preset window length;
[0072] Step 103: Input multiple time window data into the pre-trained anomaly detection model and output the reconstructed data corresponding to each time window data.
[0073] Step 104: Determine the anomaly score for each time point of the data in each time window based on the reconstructed data and the original data, and determine the degree of anomaly of the energy meter under test at each time point based on the anomaly score.
[0074] Specifically, the anomaly detection model in this application is an autoencoder based on segment consistency judgment. Based on the inherent temporal order consistency attribute of time series data, a data augmentation method and proxy task suitable for electricity meter time series data are designed to improve the accuracy of anomaly detection, avoid huge economic losses, and maintain the safe operation of the power grid. The steps are as follows:
[0075] 1. Problem Description
[0076] Multivariate time series data from historical smart meter readings are used as training data for the model, denoted as χ={X1,X2,···X i ,···,X T},in Let M represent the smart energy meter detection data at time point i, and M represent the number of variables in the time series. In this invention, the variables in the time series are specifically: phase A current, phase B current, phase C current, phase A voltage, phase B voltage, phase C voltage, forward active energy reading, reverse active energy reading, forward reactive energy reading, reverse reactive energy reading, phase A active power, phase B active power, phase C active power, total active power, phase A reactive power, phase B reactive power, phase C reactive power, total reactive power, phase A power factor, phase B power factor, phase C power factor, and total power factor, totaling 22 sensor variables. T represents the total length of the time series. The goal of the multivariate time series anomaly detection task is to determine the anomaly of a time window W = {X1, X2, ..., X...} containing t time points. t The goal is to determine whether any time points within the time window W are abnormal. However, in practice, instead of directly predicting labels, the anomaly score (AS) for each time point within the time window W is first calculated. This score is then combined with a threshold to determine whether any time points within the time window are abnormal. If the AS score for a time point within the time window is higher than the threshold, then an anomaly has occurred at that time point.
[0077] 2. Model Structure
[0078] Figure 2 The overall architecture of a contrastive autoencoder with multi-resolution segment-consistency discrimination (MRSCD) is shown. It consists of five main parts: data preprocessing, multi-resolution random downsampling data augmentation, feature extraction, discrimination, and reconstruction. The total loss is L. Dis and L Rec The sum of, where L Dis L represents the determination of loss. Rec The reconstruction loss is represented by the following steps. First, the data is normalized, and the original data is divided into time windows of equal length. Then, each time window is randomly downsampled into positive and negative samples at different sampling rates and in different orders. Positive samples retain the consistency information of the original time series, while in negative samples, the order between segments is randomly shuffled, resulting in disordered temporal information. Then, positive and negative samples are randomly combined to generate positive and negative sample pairs with corresponding self-supervised labels. A robust feature representation is extracted using an encoder composed of GRUs. Finally, a nonlinear decoder and discriminator are designed to reconstruct and discriminate sample pairs, respectively. The discriminator can selectively learn local temporal pattern information within segments and temporal correlation information between segments under the constraint of classification loss. Through joint learning of reconstruction and discrimination tasks, the model can consider both pixel-level pointwise information constrained by reconstruction loss and local information constrained by contrastive learning loss.
[0079] 3. Data Preprocessing
[0080] For multivariate time series data from smart meters, different variables have different physical meanings, units, and scales, leading to potentially large differences in their values. This not only affects the model's ability to learn the time series but also makes it difficult for the neural network to converge. To address this issue, this paper uses Z-Score standardization to ensure that the values of each variable conform to a standard normal distribution, i.e., a mean of 0 and a standard deviation of 1. Standardization transforms data with different dimensions into dimensionless data. For multivariate data X... i The specific formula for Z-Score standardization is as follows:
[0081]
[0082] in, Represents the standardized X i μ represents X i The mean of all sample data for each variable, σ represents X. iThe standard deviation of all sample data for each variable is used. To better uncover the time dependencies before and after time points in the time series and to perform effective feature extraction, this method windowes the standardized data, dividing the original data into fixed-length time windows W. i ={X1,X2,···,X t Training and testing are then conducted based on this. Here, t represents the number of variable time points contained within a time window.
[0083] 4. Multi-resolution random downsampling data enhancement
[0084] The process of constructing a data augmentation method based on multi-resolution random downsampling sample pairs is as follows: Figure 2 As shown, the continuity and order of trends in time series are important characteristics and key indicators for distinguishing different time series. The success of large-scale models such as BERT has demonstrated that high-level semantic information about a sequence can be learned by determining its order. For time series data, the similarities and differences between two time series can also be learned by comparing the trends and order of their respective time periods. Furthermore, similar to how dates can be used to describe the same period in daily life, different levels of semantic information about the same time series can be obtained by segmenting and learning from original time series into sample segments of different sizes.
[0085] The proposed data augmentation method can be described as follows: Given a time window Where x i,i Let represent the feature value of the smart meter detection data of the i-th variable at time i. We assume the sampling block size is r, and we can divide the time window W... in Divide into n sampling blocks of size r, i.e., W in ={X 1~n+1 ,…,X i~n+i ,···,X t-n~t}, where t = n*r. Randomly select segments to construct sample pairs. Assuming the sampling rate of random downsampling is f, the number of sample segments obtained after sampling is n*f, and must be an integer. Then we use two different methods to generate positive and negative samples: one is to maintain the relative order of the segments in the original window to obtain positive samples W. ord Another method is to shuffle the order of the segments to obtain negative samples W. rdmPositive samples retain the consistency information of the original time series, while in negative samples, the order of segments is randomly combined, resulting in chaotic information. After downsampling, the length of the time window changes from t to t*f, while the number of variables remains unchanged. Finally, we randomly combine two positive samples into a positive sample pair, and randomly combine one positive sample and one negative sample into a negative sample pair. Unlike traditional time series downsampling, the "randomness" in the data augmentation proposed in this paper is reflected in two aspects. First, our method does not sample at fixed intervals, but randomly selects segments from all blocks. Downsampling is achieved through a sampling rate less than 1. The second aspect refers to the random shuffling and combination of the order of downsampled segments. In the proposed method, we do not use only one fixed sample segment size, but mix sample pairs obtained by downsampling with two different sizes. Different sample segment sizes represent different levels of semantic information within the same time window. By combining multiple sample pairs with different resolutions, the original unlabeled data can be transformed into rich labeled sample pairs. Positive sample pairs consist of two samples containing similar trends and consistent temporal order information, while negative sample pairs consist of two samples with inconsistent temporal order information. By designing an encoder to extract features from positive and negative sample pairs and using a discriminator to learn to distinguish between them, this model can learn the trend information of different local segments of the original sample and the order information between segments.
[0086] 5. Feature Extraction Module
[0087] Recurrent Neural Networks (RNNs) have strong feature extraction capabilities for sequential data, while Gate Recurrent Units (GRUs), as an improvement on RNNs, mitigate the vanishing gradient problem that occurs when processing long sequences, resulting in better performance in modeling long-term sequences compared to RNNs. The sample pair feature extraction module in this paper is designed based on GRU. Figure 3 As shown, the feature extraction module consists of an embedding layer and several GRU stacks.
[0088] The embedding layer in the feature extraction module consists of a single fully connected linear layer. The embedding layer encodes the time series, preserving its sequential information while continuously updating the weights during training. By continuously optimizing the feature weights, parameters that are beneficial for extracting feature information within a window are gradually fitted. For sample P... i After passing through the embedding layer, it becomes P with a fixed feature dimension. em i .
[0089] The output P of the embedding layer em iThen it sequentially enters several GRU layers. (P) em i The eigenvector x in i Taking the GRU computation at layer c as an example, suppose the output of the previous unit in layer c is... x i The output of the GRU at layer c-1 is Then x i The output of the GRU at layer c is in The parameter representing the update gate of the c-th layer GRU indicates how much of the previous information needs to be updated. This represents the candidate state of the c-th layer GRU, which is determined by resetting the gate. Controls the output of the previous unit The proportion. The calculations are as follows:
[0090]
[0091]
[0092]
[0093] Wherein, Sigmoid() represents the activation function sigmoid, W z W r W represents the weight matrices of the update gate, reset gate, and candidate state, respectively. After several layers of GRU, the high-level semantic information of the extracted sample pair features can be obtained, denoted by Z. i To express.
[0094] 6. Discrimination and Reconstruction Module
[0095] like Figure 3 As shown, the proposed method has two training tasks: a contrastive learning task using sample segment order consistency discrimination as a surrogate task, and a decoding and reconstruction task based on traditional anomaly detection. The contrastive discrimination task learns local trend information of sample segments and overall inter-segment order information, and uses this information to classify sample pairs. Inspired by previous research, we employ a nonlinear projection head as the discriminator. The discriminator consists of two fully connected layers, a batch normalization (BN) layer, and an activation function. The nonlinear neural network can further extract features and map them to a low-dimensional space to complete the final classification task. Furthermore, the projection head structure is simple and has fewer parameters, making the model less prone to overfitting and improving its generalizability for the extracted sample pair features Z. i We can obtain its classification prediction result y through the discriminator. i The calculation process is as follows:
[0096] y i =Sigmoid(W D2 (Tanh(BatchNorm(W D1 Z i ))))
[0097] Among them, W D1 W D2 and represent the weight parameters of the first and second linear layers in the discriminator, respectively. After obtaining the classification result y... i Then, the loss L for comparison discrimination can be obtained through the following calculation process. Dis :
[0098]
[0099] Where N represents the total number of samples, y true ={0,1} represents the true label of the sample.
[0100] The reconstruction decoding task involves compressing the features of samples using an autoencoder, preserving key, representative information from the original time series, and then reconstructing the original time series point by point using a decoder. By comparing the differences between the reconstructed samples and the original samples, the model is continuously constrained to extract more representative semantic information. Similarly, for the extracted sample pairs with feature Z... i We can obtain its reconstruction result through the decoder. The calculation process is as follows:
[0101]
[0102] Among them, W R1 W R2 Let L and represent the weight parameters of the first and second linear layers in the decoder, respectively. We define the decoding and reconstruction loss L... Rec For input sample P i and decoding reconstruction output The mean absolute error (MSE) is calculated using the following formula:
[0103]
[0104] Where N represents the total number of samples.
[0105] The overall loss L of the model is the sum of the contrastive discrimination loss and the decoding reconstruction loss, i.e., L = L Dis +L RecOur goal is to minimize the overall loss by constraining the model's encoding to simultaneously satisfy the latent variables of both the discrimination and reconstruction tasks, enabling the model to learn both pixel-level and local feature information, thus enhancing its representation learning ability. Algorithm 1 illustrates the algorithmic flow during the training phase of all methods. After the model training is complete, the test samples are no longer subjected to data augmentation and discriminator modifications; instead, they are directly encoded and then reconstructed point by point, such as... Figure 3 As shown in Table 1, the training pseudocode for the anomaly detection model in this application is also shown.
[0106] Table 1
[0107]
[0108]
[0109] 7. Anomaly Detection
[0110] Because anomalous data in multivariate time series data of smart meters are hidden within a large amount of normal data, labeled data is difficult to obtain, making it typically impossible to directly predict the anomalous label at each time point in the test data. Current mainstream methods use reconstruction-based unsupervised methods to replace direct prediction of anomalous labels for anomaly detection. This paper uses the mean squared error (MSE) between the reconstructed samples and the original samples of the test data to calculate the reconstruction error, as shown in the following formula. Then, the reconstruction error at this time point is used as an anomaly score to represent the degree of anomaly. A higher anomaly score indicates a greater difference between the observed sample and the normal data, meaning that this time point is more likely to be an anomaly.
[0111]
[0112] Among them, AS t The outlier score represents the number of outliers at time step t. This represents the original data of variable i at time t. Let represent the reconstructed data of variable i at time t, and M represent the number of variables in the multivariate data of the smart energy meter. After obtaining the anomaly score, this paper uses a fixed threshold to classify anomalies, classifying samples with anomaly scores greater than the threshold as anomalous samples and samples with anomaly scores less than or equal to the threshold as normal samples.
[0113] Furthermore, the specific steps for validating the above-mentioned anomaly detection model using a publicly available dataset are as follows:
[0114] Comparative experiments were conducted with MRSCD and 14 other advanced models on five authoritative public datasets and smart meter datasets representing the diversity of time series data distributions. These experiments confirmed the effectiveness and advancement of the proposed multi-dimensional time series anomaly detection method for electricity meters based on segment consistency discriminative autoencoders.
[0115] 1. Public Datasets: The five public datasets used represent monitoring data from various complex physical devices or large facilities. Specific information for each dataset is shown in Table 2. To reduce the randomness of the results, all results are the average of five independent runs.
[0116] Table 2 Dataset
[0117] SMD 708,405 708,420 38 4.16% Monitoring server data MSL 58,317 73,729 55 10.53% Mars rover detection data SMAP 135,183 427,617 25 12.79% Soil moisture satellite monitoring data SWAT 495,000 449,919 51 12.14% Water treatment equipment test data PSM 132,481 87,841 25 27.76% Server cluster testing equipment
[0118] 2. Comparison method: As shown in Table 3, in order to verify the effectiveness of the proposed algorithm, 14 typical unsupervised anomaly detection algorithms were used as comparison algorithms in the embodiments of this invention.
[0119] Table 3 shows the algorithms compared in specific embodiments.
[0120]
[0121]
[0122] 3. Evaluation Metric: AUC is used to measure the anomaly detection results. AUC is the area under the ROC curve, which plots the accuracy versus false alarm rate as a decision threshold changes. The minimum value of AUC is 0, and the maximum value is 1. The higher the anomaly detection accuracy, the closer the AUC value is to 1; the lower the anomaly detection accuracy, the closer the AUC value is to 0.
[0123] 4. Implementation Details: A sliding window is used to partition the original time series and obtain time window sets for training and testing. The sliding window for the training set has a fixed length of 100. The number of different resolutions, Nr, and the downsampling rate, f, are two important hyperparameters in our method; we ultimately used Nr = 2 and f = 0.6. We use the Adam optimizer for model optimization during training. The number of training epochs is set to 100, the batch size to 200, and the learning rate to 1e-4. For each dataset, we split 20% of the training set into a validation set and use an early stopping strategy. Training is stopped early when the validation loss is greater than the minimum validation loss for 10 consecutive epochs. The network parameters with the minimum validation loss are taken as the optimal training result.
[0124] 5. Experimental Results on Public Datasets: The AUC results of other comparative methods on public datasets are shown in Table 4. Bold text indicates the highest average AUC and the lowest average rank. The embodiments of this invention are represented by MRSCD in the table. It can be seen that the intelligent segment consistency-based discriminative autoencoder-based energy meter anomaly detection method proposed in this invention achieved the highest average AUC and the lowest average rank on the public dataset, indicating that the anomaly detection accuracy of the embodiments of this invention is high and the performance is good.
[0125] Table 4 shows the AUC results compared with other methods on public datasets.
[0126]
[0127]
[0128] 6. Smart Meter Dataset: The specific characteristics of the Smart Meter Dataset (ELE) are shown in Table 3. This dataset is collected from 9 physical three-phase meters in multiple distribution areas. Each meter includes 22 sensor values: current (phase A, phase B, phase C), voltage (phase A, phase B, phase C), energy reading (positive active), energy reading (reverse active), energy reading (positive reactive), energy reading (reverse reactive), active power (phase A, phase B, phase C, total), reactive power (phase A, phase B, phase C, total), and power factor (phase A, phase B, phase C, total).
[0129] Table 5 Characteristics of Actual Electricity Meter Data Sets
[0130]
[0131] 7. Experimental Results on Smart Energy Meter Dataset: Table 6 shows the AUC results of the embodiments of the present invention and other comparative methods on the smart energy meter dataset. The results in the table show that the proposed intelligent segment consistency-based discriminative autoencoder-based anomaly detection method for smart energy meters achieves the highest AUC and the lowest average ranking on the actual smart energy meter dataset, demonstrating the reliability and superiority of the proposed anomaly detection method in real-world environments.
[0132] Table 6 shows the AUC results compared with other methods on the smart energy meter dataset.
[0133]
[0134] Therefore, this invention addresses the issue of noise pollution affecting smart meter monitoring data during actual collection and the unsuitability of traditional anomaly detection methods' data augmentation and proxy tasks for time series anomaly detection. It proposes a contrastive autoencoder based on multi-resolution segmented consistency discrimination for anomaly detection in multivariate time series data from smart meters. The proposed random downsampling data augmentation method constructs a large number of labeled samples without introducing noise, resolving the problem of traditional data augmentation methods potentially disrupting the temporal dependencies of time series. A sample segment consistency discrimination proxy task is proposed to learn intra-segment local trend information and inter-segment contextual information at different resolutions. Through joint training of contrastive learning and reconstruction tasks, the model can simultaneously consider pixel-level and local information in the multivariate data of smart meters, improving the model's generalization ability and anomaly detection accuracy.
[0135] Exemplary device
[0136] Figure 4 This is a schematic diagram of the structure of an anomaly detection device for an energy meter based on a segment consistency discrimination self-encoder, provided in an exemplary embodiment of the present invention. Figure 4 As shown, the device 400 includes:
[0137] The acquisition module 410 is used to acquire multivariate long-term series data of historical detection of the energy meter under test;
[0138] The partitioning module 420 is used to normalize multivariate long-term series data and partition the data into multiple time windows of a preset window length.
[0139] The output module 430 is used to input multiple time window data into a pre-trained anomaly detection model and output the reconstructed data corresponding to each time window data.
[0140] The determination module 440 is used to determine the anomaly score of each time point of the data in each time window based on the reconstructed data and the original data of each time window, and to determine the degree of anomaly of the energy meter under test at each time point based on the anomaly score.
[0141] Optionally, the multivariate long-term series data includes: phase A current, phase B current, phase C current, phase A voltage, phase B voltage, phase C voltage, forward active energy indication, reverse active energy indication, forward reactive energy indication, reverse reactive energy indication, phase A active power, phase B active power, phase C active power, total active power, phase A reactive power, phase B reactive power, phase C reactive power, total reactive power, phase A power factor, phase B power factor, phase C power factor, and total power factor.
[0142] Optionally, after acquiring multivariate long-term series data of historical measurements of the energy meter under test, the device 400 further includes:
[0143] The standardization module is used to standardize all values of each variable in a multivariate long-term series data to conform to a standard normal distribution using Z-Score standardization.
[0144] Alternatively, the formula for Z-Score standardization is:
[0145]
[0146] In the formula, X i For multivariate long-term series data, Represents the standardized X i μ represents X i The mean of all sample data for each variable, σ represents X. i The standard deviation of all sample data for each variable.
[0147] Optionally, the training process of the anomaly detection model in output module 430 is as follows:
[0148] The acquisition submodule is used to acquire multivariate time series data samples from multiple historical energy meter readings and merge them into a single multivariate long-term data sample.
[0149] The standardization submodule is used to use Z-Score standardization to ensure that all values of each variable in a multivariate long-term series data sample conform to a standard normal distribution.
[0150] The partitioning submodule is used to window standardized multivariate long-term series data samples into multiple time window data samples with preset windows;
[0151] The first determination submodule is used to perform data augmentation on data samples from multiple time windows using a multi-resolution random downsampling data augmentation method to determine positive and negative sample pairs.
[0152] The second determination submodule is used to extract features from positive and negative sample pairs using an encoder composed of GRUs to determine the features of positive and negative sample pairs.
[0153] The third determination submodule is used to determine the total loss of the model by identifying and reconstructing the features of positive and negative sample pairs through a preset nonlinear discriminator, encoder and decoder respectively.
[0154] The fourth submodule is used to update and optimize the network and parameters based on the total loss, and to determine the anomaly detection model.
[0155] Optionally, the first determined submodule includes:
[0156] The selection unit is used to divide a time window data sample into segments and randomly select segments from the time window, given a time window data sample.
[0157] The first acquisition unit is used to maintain the relative order of the selected segments within the original time window and acquire positive samples;
[0158] The second acquisition unit is used to shuffle the order of the selected segments and acquire negative samples;
[0159] The first combination unit is used to randomly combine two positive samples into a positive sample pair;
[0160] The second combination unit is used to randomly combine a positive sample and a negative sample into a negative sample pair.
[0161] Optionally, the encoder composed of GRUs consists of an embedding layer and a predetermined number of GRU stacks, wherein the embedding layer is composed of a fully connected linear layer for encoding time series.
[0162] Optionally, the discriminator is a non-linear prediction head consisting of two fully connected layers, a batch normalization layer, and an activation function.
[0163] Optionally, the formula for calculating the total loss is:
[0164] L←L Dis +L Rec
[0165]
[0166]
[0167] In the formula, L represents the total loss. Dis To compare the loss of the judgment, L Rec The decoding and reconstruction loss is given by N, which represents the total number of samples, and y true ={0,1} represents the true label of the sample, y i For the classification results, P i Input sample, Decode and reconstruct the output.
[0168] Optionally, the formula for calculating the outlier score is:
[0169]
[0170] In the formula, AS t This represents the anomaly score at time t within the preset window. This represents the original data of variable i at time t. This represents the reconstructed data of variable i at time t, and M represents the number of variables in the multivariate long-term series data of the energy meter under test.
[0171] Exemplary electronic devices
[0172] Figure 5 This is the structure of an electronic device provided in an exemplary embodiment of the present invention. For example... Figure 5 As shown, the electronic device 50 includes one or more processors 51 and a memory 52.
[0173] The processor 51 may be a central processing unit (CPU) or other form of processing unit with data processing and / or instruction execution capabilities, and may control other components in the electronic device to perform desired functions.
[0174] The memory 52 may include one or more computer program products, which may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory may include, for example, random access memory (RAM) and / or cache memory. The non-volatile memory may include, for example, read-only memory (ROM), hard disk, flash memory, etc. One or more computer program instructions may be stored on the computer-readable storage medium, and the processor 51 may execute the program instructions to implement the methods of the software programs of the various embodiments of the present invention described above, and / or other desired functions. In one example, the electronic device may also include an input device 53 and an output device 54, these components being interconnected via a bus system and / or other forms of connection mechanisms (not shown).
[0175] In addition, the input device 53 may also include, for example, a keyboard, a mouse, etc.
[0176] The output device 54 can output various information to the outside. The output device 54 may include, for example, a display, a speaker, a printer, and a communication network and its connected remote output devices, etc.
[0177] Of course, for the sake of simplicity, Figure 5 Only some of the components of this electronic device relevant to the present invention are shown, omitting components such as buses, input / output interfaces, etc. In addition, the electronic device may include any other suitable components depending on the specific application.
[0178] Exemplary computer program products and computer-readable storage media
[0179] In addition to the methods and apparatus described above, embodiments of the present invention may also be computer program products, which include computer program instructions that, when executed by a processor, cause the processor to perform the steps in the methods according to various embodiments of the present invention described in the "Exemplary Methods" section above.
[0180] The computer program product can be written in any combination of one or more programming languages to perform the operations of the embodiments of the present invention. The programming languages include object-oriented programming languages such as Java and C++, as well as conventional procedural programming languages such as C or similar languages. The program code can be executed entirely on the user's computing device, partially on the user's computing device, as a standalone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server.
[0181] Furthermore, embodiments of the present invention may also be computer-readable storage media storing computer program instructions thereon, which, when executed by a processor, cause the processor to perform the steps of the methods according to various embodiments of the present invention described in the "Exemplary Methods" section above.
[0182] The computer-readable storage medium may be any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or any combination thereof. More specific examples (a non-exhaustive list) of readable storage media include: an electrical connection having one or more wires, a portable disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof.
[0183] The basic principles of the present invention have been described above with reference to specific embodiments. However, it should be noted that the advantages, benefits, and effects mentioned in the present invention are merely examples and not limitations, and should not be considered as essential features of each embodiment of the present invention. Furthermore, the specific details disclosed above are for illustrative and facilitative purposes only, and are not limitations. These details do not limit the present invention to the necessity of employing the aforementioned specific details.
[0184] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For system embodiments, since they largely correspond to method embodiments, the description is relatively simple; relevant parts can be referred to the descriptions in the method embodiments.
[0185] The block diagrams of devices, systems, devices, and systems involved in this invention are merely illustrative examples and are not intended to require or imply that they must be connected, arranged, or configured in the manner shown in the block diagrams. As those skilled in the art will recognize, these devices, systems, devices, and systems can be connected, arranged, and configured in any manner. Words such as “comprising,” “including,” “having,” etc., are open-ended terms meaning “including but not limited to,” and are used interchangeably with them. The terms “or” and “and” as used herein refer to the terms “and / or,” and are used interchangeably with them unless the context clearly indicates otherwise. The term “such as” as used herein refers to the phrase “such as but not limited to,” and is used interchangeably with it.
[0186] The methods and systems of the present invention may be implemented in many ways. For example, they may be implemented by software, hardware, firmware, or any combination of software, hardware, and firmware. The above-described order of steps for the methods is for illustrative purposes only, and the steps of the methods of the present invention are not limited to the order specifically described above unless otherwise specifically stated. Furthermore, in some embodiments, the present invention may also be implemented as a program recorded on a recording medium, the program comprising machine-readable instructions for implementing the methods according to the present invention. Thus, the present invention also covers recording media storing programs for performing the methods according to the present invention.
[0187] It should also be noted that in the systems, apparatus, and methods of the present invention, the components or steps can be disassembled and / or recombined. These disassemblies and / or recombinations should be considered equivalents of the present invention. The above description of the disclosed aspects is provided to enable any person skilled in the art to make or use the invention. Various modifications to these aspects will be readily apparent to those skilled in the art, and the general principles defined herein can be applied to other aspects without departing from the scope of the invention. Therefore, the invention is not intended to be limited to the aspects shown herein, but rather to be carried out within the widest scope consistent with the principles and novel features disclosed herein.
[0188] The above description has been given for purposes of illustration and description. Furthermore, this description is not intended to limit the embodiments of the invention to the forms disclosed herein. Although numerous exemplary aspects and embodiments have been discussed above, those skilled in the art will recognize certain variations, modifications, alterations, additions, and sub-combinations therein.
Claims
1. A method for detecting anomalies in an energy meter based on a segment consistency discrimination self-encoder, characterized in that, include: Acquire multivariate long-term series data of historical measurements of the energy meter under test; The multivariate long-term series data is normalized and divided into multiple time windows of a preset window length; Multiple time window data are input into a pre-trained anomaly detection model, and the reconstructed data corresponding to each time window data is output, wherein the anomaly detection model adopts a segment consistency discriminative autoencoder; The anomaly score for each time point in the time window is determined based on the reconstructed data and the original data for each time window, and the degree of anomaly of the energy meter under test is determined based on the anomaly score. The training process of the anomaly detection model is as follows: Acquire multivariate time series data samples from multiple historical energy meter readings and merge them into a single multivariate long-term data sample. Z-Score standardization was used to ensure that all values of each variable in the multivariate long-term series data sample conformed to a standard normal distribution. Standardized multivariate long-term series data samples are windowed and divided into multiple time window data samples of the preset window; A multi-resolution random downsampling data augmentation method is used to augment data samples from multiple time windows to determine positive and negative sample pairs. An encoder composed of GRUs is used to extract features from the positive and negative sample pairs to determine the features of the positive and negative sample pairs. The positive and negative sample pairs are identified and reconstructed using a pre-defined nonlinear discriminator, encoder, and decoder, respectively, to determine the total loss of the model. The anomaly detection model is determined by updating and optimizing the network and parameters based on the total loss. A multi-resolution random downsampling data augmentation method is used to augment data samples from multiple time windows, determining positive and negative sample pairs, including: Given a time window data sample, the time window data sample is segmented, and a segment is randomly selected from the time window; Preserve the relative order of the selected segments within the original time window to obtain positive samples; The order of the selected segments is shuffled to obtain negative samples; Two positive samples are randomly combined to form a positive sample pair; A positive sample and a negative sample are randomly combined to form a negative sample pair.
2. The method according to claim 1, characterized in that, The multivariate long-term series data includes: phase A current, phase B current, phase C current, phase A voltage, phase B voltage, phase C voltage, forward active energy readings, reverse active energy readings, forward reactive energy readings, reverse reactive energy readings, phase A active power, phase B active power, phase C active power, total active power, phase A reactive power, phase B reactive power, phase C reactive power, total reactive power, phase A power factor, phase B power factor, phase C power factor, and total power factor.
3. The method according to claim 1, characterized in that, After acquiring the multivariate long-term series data of the historical measurements of the energy meter under test, the process also includes: Z-Score standardization is used to ensure that all values of each variable in the multivariate long-term series data conform to a standard normal distribution.
4. The method according to claim 3, characterized in that, The formula for Z-Score standardization is: In the formula, For multivariate long-term series data, Represents the standardized , express The mean of all sample data for each variable. express The standard deviation of all sample data for each variable.
5. The method according to claim 1, characterized in that, The encoder, composed of GRUs, consists of an embedding layer and a predetermined number of GRU stacks, wherein the embedding layer is composed of a fully connected linear layer for encoding time series. The discriminator is a nonlinear prediction head, consisting of two fully connected layers, a batch normalization layer, and an activation function.
6. The method according to claim 1, characterized in that, The formula for calculating the total loss is as follows: In the formula, For the total loss, To compare and determine the loss, For decoding and reconstruction loss, Represents the total number of samples. This represents the true label of the sample. For the classification results, For the input sample, This is the output for decoding and reconstruction.
7. The method according to claim 1, characterized in that, The formula for calculating the abnormal score is: In the formula, This represents the anomaly score at time t within the preset window. This represents the original data of variable i at time t. M represents the reconstructed data of variable i at time t, and M represents the number of variables in the multivariate long-term series data of the energy meter under test.
8. An anomaly detection device for an energy meter based on a segment consistency discrimination self-encoder, used to implement the method described in claim 1, characterized in that, include: The acquisition module is used to acquire multivariate long-term series data of historical tests of the energy meter under test; The partitioning module is used to normalize the multivariate long-term series data and partition it into multiple time windows of a preset window length. The output module is used to input multiple time window data into a pre-trained anomaly detection model and output the reconstructed data corresponding to each time window data. The determination module is used to determine the anomaly score of each time point of the data in each time window based on the reconstructed data and the original data, and to determine the degree of anomaly of the energy meter under test at each time point based on the anomaly score.
Citation Information
Patent Citations
Electric energy meter abnormality diagnosis method and device
CN110888101A