Method and system for detecting local abnormal points of intelligent electric energy meter
By calculating the reconstruction error during the LSTM autoencoder model training and detection phases, the difficulty of identifying local anomalies in smart electricity meters was solved, enabling early and accurate detection of anomalies such as electricity theft and equipment failures, thereby improving the operating efficiency and reliability of the power supply system.
Patent Information
- Application Number
- CN202511249529.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-03
- Publication Date
- 2025-10-21
- Estimated Expiration
- 2045-09-03
AI Technical Summary
Existing smart electricity meter anomaly detection methods have difficulty effectively capturing local anomalies, especially in complex and changeable electricity consumption data. Traditional methods based on fixed thresholds or global statistical distributions have difficulty identifying early signals such as electricity theft and equipment failure, and cannot adapt to users' dynamic electricity consumption patterns.
An LSTM autoencoder model is used to obtain historical electricity consumption data marked as normal through the training phase. The window length and sliding step size are defined, and the sequence of sliding windows of normal electricity consumption data is extracted. The LSTM autoencoder model is trained and its deep learning of the temporal characteristics of normal electricity consumption patterns is used. In the detection phase, sliding window sampling is performed on the data to be detected, and the reconstruction error is calculated to mark the time point when the anomaly occurs.
It achieves accurate identification of local anomalies, overcomes the challenges of global pattern masking effects and dynamic power consumption patterns, and can detect key signals such as power theft and equipment failures at an early stage, thereby improving power supply reliability and operational efficiency.
Smart Images

Figure CN120822151A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of anomaly detection, and more specifically, to a method and system for detecting local anomaly points in a smart electricity meter. Background Art
[0002] Smart energy meters, as a core component of modern power systems, accurately collect massive amounts of user electricity usage data in real time. This data not only forms the basis for electricity bill settlement but also serves as a critical source of information for power companies to conduct load forecasting, monitor equipment health, and identify abnormal behavior. However, hidden within these massive data streams are often local anomalies that are short-lived and may not be extreme in magnitude, but are nonetheless crucial. These local anomalies, such as a sudden and significantly lower electricity usage during a specific period of time compared to similar periods during the summer peak air conditioning season, can be early signs of electricity theft, equipment failure, or metering errors. Promptly and accurately identifying these local anomalies would significantly improve power system efficiency, reduce economic losses, and ensure power supply reliability. Therefore, developing an efficient and accurate solution for detecting local anomalies in smart energy meters is of great practical value.
[0003] However, existing anomaly detection methods face numerous challenges when processing smart meter data. Traditional methods based on fixed thresholds or global statistical distributions often struggle to effectively capture these local anomalies. On the one hand, electricity usage data exhibits significant periodicity and trends, and the amplitude of fluctuations in these global patterns is far greater than the amplitude of local anomalies. This causes local anomalies to appear insignificant from a global perspective and easily be submerged in normal fluctuations, resulting in the so-called global pattern masking effect. On the other hand, users' normal electricity usage patterns are not static and vary significantly from user to user. A fixed or global normal standard is difficult to adapt to all users and all time periods, making local anomaly judgment based on this standard difficult. These limitations make it difficult for traditional methods to accurately identify local anomalies when faced with complex and changing electricity usage data, thus missing the opportunity to detect potential problems early.
[0004] To overcome the above challenges and achieve accurate identification of local anomalies, an intelligent detection method is needed that can fully utilize the temporal characteristics of electricity consumption data and adaptively learn normal patterns. Summary of the Invention
[0005] In view of the above limitations of the existing methods, according to one aspect of the present application, a method for detecting local abnormal points in a smart electric energy meter is provided, which includes: a training phase and a detection phase; The training phase includes: Obtain historical electricity consumption data marked as normal; defining a window length and a sliding step size, and extracting a sequence of normal power consumption data sliding windows from the historical power consumption data marked as normal; Training an LSTM autoencoder model based on a sequence of the normal electricity consumption data sliding window to obtain a trained LSTM autoencoder model; The detection phase includes: Obtaining the electricity consumption data to be tested; Performing sliding window sampling on the power consumption data to be detected using the window length and the sliding step length to obtain a sequence of sliding windows for detecting power consumption data; Inputting the sequence of the sliding window of the detected electricity consumption data into the trained LSTM autoencoder model to obtain a reconstruction error sequence; Based on the reconstructed error sequence, the time point at which the abnormality occurs is marked.
[0006] According to another aspect of the present application, a local abnormal point detection system for a smart electric energy meter is provided, comprising: Training modules include: A normal historical electricity consumption data acquisition unit, configured to acquire historical electricity consumption data marked as normal; a normal power consumption data extraction unit, configured to define a window length and a sliding step length, and extract a sequence of normal power consumption data sliding windows from the historical power consumption data marked as normal; An LSTM autoencoder training unit, configured to train an LSTM autoencoder model based on a sequence of the normal electricity consumption data sliding window to obtain a trained LSTM autoencoder model; Detection module, including: The power consumption data acquisition unit to be detected is used to acquire the power consumption data to be detected; a power consumption data sliding sampling unit for detecting power consumption data, configured to perform sliding window sampling on the power consumption data to be detected using the window length and the sliding step length to obtain a sequence of sliding windows of the power consumption data to be detected; A reconstruction error generating unit, configured to input the sequence of the sliding window of the detected electricity consumption data into the trained LSTM autoencoder model to obtain a reconstruction error sequence; The abnormal time point marking unit is used to mark the time point when the abnormality occurs based on the reconstructed error sequence.
[0007] Compared to existing technologies, the present application provides a method and system for detecting local anomalies in smart electricity meters. During the training phase, this method uses historical electricity usage data labeled as normal to define a window length and sliding step size, extracting a sequence of sliding windows of normal electricity usage data. These sliding windows cleverly capture the local temporal context of the electricity usage data, effectively addressing the global pattern masking effect and the dynamics and heterogeneity of normal patterns, as discussed in the background art. This ensures that local anomalies are not overwhelmed by macro fluctuations. Subsequently, an LSTM autoencoder is trained based on these sequences of normal sliding windows, enabling it to deeply learn and internalize the temporal characteristics and inherent laws of normal electricity usage patterns, rather than relying on fixed global standards. During the detection phase, the data to be tested is sampled using the same sliding window method and fed into the trained autoencoder. By calculating the reconstruction error, this method can accurately identify local anomalies that deviate significantly from the normal pattern. This method overcomes the limitations of traditional fixed threshold or global statistical methods, which cannot capture subtle local changes, and enables early and accurate detection of key signals such as electricity theft and equipment failure, thereby significantly improving power supply reliability and operational efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0008] The above and other purposes, features, and advantages of the present application will become more apparent through a more detailed description of the embodiments of the present application in conjunction with the accompanying drawings. The accompanying drawings are intended to provide a further understanding of the embodiments of the present application and constitute a part of the specification. Together with the embodiments of the present application, they are used to explain the present application and do not constitute a limitation of the present application. In the drawings, the same reference numerals generally represent the same components or steps.
[0009] Figure 1 4 is a flowchart of the training phase of the local abnormal point detection method for a smart electricity meter according to an embodiment of the present application.
[0010] Figure 2 Flowchart of step S130 in the method for detecting local abnormal points in a smart electricity meter according to an embodiment of the present application.
[0011] Figure 3 Flowchart of the detection phase of the local abnormal point detection method for a smart electricity meter according to an embodiment of the present application.
[0012] Figure 4 Schematic diagram of data flow in the detection phase of the local abnormal point detection method for a smart electricity meter according to an embodiment of the present application.
[0013] Figure 5 Flowchart of step S240 in the method for detecting local abnormal points in a smart electricity meter according to an embodiment of the present application.
[0014] Figure 64 is a block diagram of a local abnormal point detection system for a smart electricity meter according to an embodiment of the present application. DETAILED DESCRIPTION
[0015] The following describes embodiments of the present disclosure in more detail with reference to the accompanying drawings. While the drawings illustrate certain embodiments of the present disclosure, it should be understood that the present disclosure can be implemented in various forms and should not be construed as limited to the embodiments described herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are for illustrative purposes only and are not intended to limit the scope of protection of the present disclosure.
[0016] In response to the problems in the above background technology, the present application proposes a method for detecting local abnormal points in a smart electricity meter. Figure 1 FIG. 1 is a flow chart of the training phase of the method for detecting local abnormal points in a smart electric energy meter according to an embodiment of the present application. Figure 1 As shown, the training stage of the local abnormal point detection method of the smart electricity meter according to the embodiment of the present application includes: S110, obtaining historical electricity consumption data marked as normal; S120, defining the window length and sliding step size, and extracting a sequence of normal electricity consumption data sliding windows from the historical electricity consumption data marked as normal; S130, training the LSTM autoencoder model based on the sequence of normal electricity consumption data sliding windows to obtain a trained LSTM autoencoder model.
[0017] In step S110, historical electricity consumption data marked as normal is obtained. It should be understood that the LSTM autoencoder model adopted in this solution is intended to learn and internalize the inherent laws and temporal characteristics of normal electricity consumption patterns. If abnormal data is mixed in the training data, the model will not be able to accurately distinguish between normal and abnormal, resulting in a decrease in its ability to recognize abnormalities. By using only historical data marked as normal for training, the model can construct a pure normal pattern representation, so that in the detection stage, any data point that deviates significantly from the normal pattern can be effectively identified as an anomaly, thereby overcoming the challenges brought by the dynamics and heterogeneity of the normal pattern pointed out in the background technology, and ensuring the accuracy and robustness of anomaly detection.
[0018] Specifically, one possible implementation of step S110 is as follows: First, historical electricity usage data for a specific user or user group is obtained from a smart meter data collection system or a power data center. This data is stored in a time series format, including a timestamp and the corresponding electricity usage, for example, electricity usage every 15 minutes, every hour, or every day. Second, this raw historical electricity usage data is preliminarily cleaned, including processing missing values, such as by interpolation or forward filling, and removing obvious data collection errors or outliers, such as negative electricity usage or extreme values that far exceed physical limits.
[0019] Next, the normal labeling process begins. This process can combine a variety of methods. A common and reliable approach is to collaborate with power company operations and maintenance personnel or domain experts. Based on their experience and historical event records, such as no reports of electricity theft, no equipment failures, and no complaints about metering anomalies, they can filter out electricity usage data within a specific time period that has been confirmed to be free of anomalies. For example, a user's electricity usage data from several consecutive months over the past year, with no reports of any abnormal events, can be selected as the initial normal dataset. Another supplementary approach is to use established statistical methods or rules that are insensitive to local anomalies to pre-screen the initially cleaned data, removing obvious global anomalies. This creates a relatively clean dataset, which can then be finalized by experts. For example, a preliminary threshold based on the historical mean and standard deviation can be set. Data points outside this threshold range can be labeled as potential anomalies and excluded, ensuring that the dataset input to the LSTM autoencoder training is as representative of actual normal electricity usage as possible.
[0020] In step S120, the window length and sliding step are defined, and a sequence of sliding windows of normal electricity consumption data is extracted from the historical electricity consumption data marked as normal. It is understandable that, as a typical time series data, the judgment of local anomalies in electricity consumption data strongly depends on the context in which it is located. A single isolated data point is difficult to accurately judge as an anomaly because it may only be part of a normal fluctuation. To this end, in the technical solution of the present application, by defining the window length, the continuous electricity consumption data can be divided into segments with a specific time span. Each segment contains the data point and its immediately preceding and following data, thereby providing the necessary context information for judging whether the electricity consumption pattern in the time period is normal, effectively solving the problem of the definition of local anomalies depending on the context pointed out in the background technology. At the same time, the introduction of the sliding step allows overlap between these windows, which not only increases the diversity of the training data, but also enables the model to more carefully capture subtle changes and trends in the data sequence, avoiding the risk of missing potential anomalies due to improper window division, and further enhancing the model's ability to learn the dynamics and heterogeneity of normal patterns.
[0021] Specifically, one possible implementation method of step S120 is as follows: First, it is necessary to determine the window length and sliding step size based on the actual application scenario and the sampling frequency of the electricity consumption data. For example, if the smart electricity meter collects electricity consumption data on an hourly basis, and experience shows that local anomalies, such as electricity theft or transient equipment failures, usually last for several hours, then the window length can be set to 8 hours, that is, each sliding window contains 8 consecutive electricity consumption data points. This length is sufficient to cover the typical duration of local anomalies and provide sufficient contextual information. The sliding step size can be set to 1 hour, that is, each time a new window is generated, the data sequence slides forward one hour. This setting allows for a 7-hour overlap between adjacent windows, ensuring that any subtle changes in the data sequence can be captured by multiple windows, thereby providing richer learning samples for the LSTM autoencoder.
[0022] After determining the window length and sliding step size, we can obtain historical electricity consumption data that is marked as normal, for example, a time series containing hourly electricity consumption for several consecutive months: , ,..., ] to extract the sequence of normal power consumption data sliding window. The specific operation is: starting from the starting point of the time series, intercept the first data segment determined by the window length as the first sliding window, for example, the first window is [ , ,..., Then, according to the preset sliding step size, for example, 1 hour, the interception point is moved backward and the next data segment is intercepted as the second sliding window, that is, [ , ,..., This process is repeated until the end of the time series, that is, when the remaining data is less than the length of a window. Finally, all the intercepted sliding windows are arranged in the order in which they were generated to form a sequence of sliding windows of normal electricity consumption data.
[0023] In step S130, an LSTM autoencoder model is trained based on the sequence of the normal power consumption data sliding window to obtain a trained LSTM autoencoder model. It is worth mentioning that, as a deep learning model, the LSTM autoencoder is good at processing time series data and learning its inherent time series dependencies and patterns. To this end, the present application trains the autoencoder by inputting the sequence of the normal power consumption data sliding window into the model, so that the autoencoder can learn how to efficiently encode and decode these normal patterns. That is, by training only with historical power consumption data that is marked as normal, the autoencoder can construct an internal representation that is highly sensitive to normal patterns. When the model encounters data that is significantly different from the normal pattern seen during training, that is, abnormal data, during the detection phase, it will be difficult to accurately reconstruct, resulting in a large reconstruction error. This difference in reconstruction error is the core basis for identifying local anomalies, enabling the model to effectively distinguish normal fluctuations from true abnormal behavior, overcoming the challenge that traditional methods are difficult to adapt to complex power consumption patterns.
[0024] Specifically, in one embodiment of the present application, Figure 2 FIG. 1 is a flow chart of step S130 in the method for detecting local abnormal points in a smart electric energy meter according to an embodiment of the present application. Figure 2 As shown, step S130, training the LSTM autoencoder model based on the sequence of the normal electricity consumption data sliding window to obtain a trained LSTM autoencoder model, including: S131, inputting the sequence of the normal electricity consumption data sliding window into the encoder of the LSTM autoencoder model to obtain a sequence of normal electricity consumption data temporal context implicit coding vectors; S132, inputting the sequence of normal electricity consumption data temporal context implicit coding vectors into the decoder of the LSTM autoencoder model to obtain a sequence of reconstructed electricity consumption data sliding windows; S133, calculating the loss function value based on the sequence of the normal electricity consumption data sliding window and the sequence of the reconstructed electricity consumption data sliding window; S134, training the LSTM autoencoder model based on the loss function value and through back propagation of gradient descent.
[0025] More specifically, in one possible implementation of the present application, the encoder of the LSTM autoencoder model is one or more LSTM layers, and the decoder of the LSTM autoencoder model is one or more LSTM layers. In particular, the LSTM layer selectively memorizes, updates and outputs information through three gating mechanisms: cell state and forget gate, input gate, and output gate. It is worth mentioning that both the encoder and decoder of the LSTM autoencoder model adopt one or more LSTM layers. This design is based on the inherent advantages of LSTM in processing time series data and the powerful ability of deep learning models in feature learning. As a special recurrent neural network unit, the LSTM layer can effectively solve the gradient vanishing or gradient exploding problems that occur in traditional recurrent neural networks when processing long sequences, enabling it to capture the long-term dependencies and complex time series patterns in electricity consumption data. Specifically, the encoder is designed as one or more LSTM layers, so that it can gradually extract and compress high-dimensional, abstract time series context implicit coding vectors from the sequence of the input normal electricity consumption data sliding window. The multi-layer LSTM architecture enhances the model's representational capabilities, enabling it to learn electricity usage patterns at different levels. For example, the first layer may learn short-term intraday fluctuations, while deeper layers may capture weekly, monthly, and even seasonal patterns of electricity usage, thereby providing a more comprehensive and detailed understanding of the complexity of normal electricity usage behavior. Similarly, the decoder, employing one or more LSTM layers, can gradually reconstruct the original sliding window sequence of electricity usage data based on the latent vectors extracted by the encoder. This symmetrical structure enables the model to better understand the data generation mechanism during the learning process.
[0026] It should be understood that the encoder is the core component of the autoencoder model, which aims to learn and extract low-dimensional, efficient feature representations of the input data. For smart electricity meter data, this means that the encoder needs to extract its inherent rules and structures from the normal power consumption pattern containing the temporal context. Therefore, the present application encodes the data to remove redundant information in the data, while retaining the features that are critical to identifying normal patterns to obtain the implicit encoding vector of the normal power consumption data temporal context. This implicit encoding vector is the model's deep understanding of normal power consumption behavior. It provides a basis for the subsequent decoder to reconstruct the original data, and ensures that the model can sensitively capture any abnormal behavior that deviates from this normal pattern during the detection stage.
[0027] Specifically, one possible implementation method of step S131 is as follows: the encoder of the LSTM autoencoder model can be designed as one or more LSTM layers. Taking a two-layer LSTM encoder as an example, its architecture is as follows: the first layer LSTM receives the normal electricity consumption data point of each sliding window as input. For example, if each normal electricity consumption data point is a single variable value, the input feature dimension of the first layer LSTM is 1. This layer can be configured with, for example, 64 LSTM units, that is, the dimension of the hidden state, and is set to return a sequence output so that the hidden state of each time step is passed to the next layer. The second layer LSTM receives the sequence output of the first layer LSTM as input, and can be configured with, for example, 32 LSTM units, but is set to return only the final hidden state. This design enables the encoder to output a fixed-dimensional vector after processing the entire sliding window. This vector is the implicit encoding vector of the normal electricity consumption data temporal context of the sliding window.
[0028] The encoding process is performed independently for each sliding window of normal power consumption data extracted. For each sliding window in the sequence, for example [ , ,..., ], the encoder processes the data points one by one in chronological order. When the first layer of LSTM is input, it updates its internal hidden state and cell state; then Input, continue updating the status until Input. The output sequence of the first layer LSTM is then used as the input of the second layer LSTM, and is also processed point by point. When the second LSTM layer finishes processing the last data point in the window After that, its final hidden state, a 32-dimensional vector is extracted as the implicit encoding vector of the normal power consumption data time series context of the sliding window.
[0029] This encoding process traverses all normal power data sliding windows in the sequence of normal power data sliding windows. After processing each sliding window, a corresponding implicit encoding vector for the normal power data temporal context is obtained. Ultimately, these encoding vectors are arranged in the order of their corresponding sliding windows to form a sequence of implicit encoding vectors for the normal power data temporal context. It is worth noting that the weights and bias parameters contained in the LSTM layer in the encoder are randomly initialized at the beginning of training and iteratively optimized in step S134 using gradient descent and backpropagation algorithms to minimize reconstruction error.
[0030] Understandably, the design goal of the autoencoder model is to learn an effective, low-dimensional representation of the input data and verify the validity of this representation by reconstructing the original data. The decoder's role is to reverse-project the implicit encoding vectors extracted by the encoder from normal electricity usage data, which compress the temporal context information, back into the original data space. Through this reconstruction process, the model is forced to learn and grasp the inherent patterns and structure of normal electricity usage patterns. Only when the model can accurately reconstruct normal electricity usage data can it be said that it has successfully learned the characteristics of these normal patterns.
[0031] Specifically, one possible implementation of step S132 is as follows: The decoder of the LSTM autoencoder model is also designed as one or more LSTM layers, with a structure similar to that of the encoder. Continuing with the encoder example in step S131, if the encoder outputs a 32-dimensional implicit encoding vector of the normal electricity consumption data temporal context, the decoder will receive this vector as its input. A typical two-layer LSTM decoder architecture is as follows: The first LSTM layer of the decoder receives the 32-dimensional implicit encoding vector from the encoder. This vector can serve as the initial hidden state of the decoder LSTM layer or be repeatedly input to the decoder at each time step. This layer can be configured with, for example, 32 LSTM units and set to return a sequence output. The second LSTM layer receives the sequence output of the first LSTM layer as input and can be configured with, for example, 64 LSTM units, also set to return a sequence output. After each time step output of the second LSTM layer, a fully connected layer is connected. This fully connected layer converts the LSTM hidden state into an output that matches the dimensions of the original electricity consumption data point, for example, a single-variable electricity consumption value.
[0032] The decoding process is performed independently for each implicit coding vector of the normal electricity consumption data time series context. For each implicit coding vector, the decoder will try to generate a sequence with the same length as the original sliding window. For example, if the original sliding window length is 8 hours, the decoder will generate 8 consecutive electricity consumption data points. The decoder uses its internal LSTM layer to predict the electricity consumption value of the current time step based on the output and internal state of the previous time step at each time step. This process continues until a sequence with the same length as the original sliding window is generated. Finally, all sliding windows reconstructed by the decoder are arranged in the order of their corresponding implicit coding vectors to form a sequence of reconstructed electricity consumption data sliding windows. It is worth mentioning that, similar to the encoder, random initialization is performed at the beginning of training, and iterative optimization is performed through gradient descent and backpropagation algorithms in step S134 to minimize the reconstruction error.
[0033] In particular, here, when defining the window length and sliding step during the training process, the sliding step is usually set to be smaller than the window length. In this way, when the sequence of the sliding window of normal electricity consumption data is time-series encoded through the LSTM autoencoder model, redundant time-series precursor noise distribution will be accumulated due to the spontaneous emergence of the time-series repetitiveness of the time-series window based on the sliding step, and further manifested as time-series correlation expansion in the short-range-long-range bidirectional time-series context association, thereby constituting time-series interference to the training of the LSTM autoencoder model.
[0034] Based on this, preferably, in another possible implementation of the present application, step S132, inputting the sequence of the normal electricity consumption data temporal context implicit coding vectors into the decoder of the LSTM autoencoder model to obtain a sequence of reconstructed electricity consumption data sliding windows, includes: First, based on the window length and the sliding step size, the temporal redundancy predecessor probability is defined, that is:
[0035] in, is the window length, is the sliding step length, is the temporal redundant predecessor probability; Then, the sequence of the implicit coding vector of the normal power consumption data temporal context is locally sparsed based on the temporal redundant predecessor probability to obtain the local sparse control factor, that is, the norm representation of the discrete weight is used as the core to introduce the temporal redundant predecessor probability. Local sparsification of :
[0036] in, It is the vector of the sequence of implicit coding vectors of the normal power consumption data time series context, To calculate One-norm Power, To calculate The two-norm Power, is the local sparsification control factor, that is, the temporal redundant predecessor probability As a local sparse identifier of the norm representation of the feature set, it is used to eliminate redundant synergy; Then, the temporal redundancy predecessor probability and the local sparsification control factor are applied to the eigenvalue of each normal power data temporal context implicit coding vector in the sequence of normal power data temporal context implicit coding vectors in a negotiated elimination form to obtain a sequence of normal power data temporal context implicit coding phase difference coordination vectors, that is:
[0037] in, yes Each eigenvalue in It is the eigenvalue of each vector in the sequence of the phase difference coordination vector implicitly encoded in the timing context of normal power consumption data. In this way, the redundant synergy elimination and the timing redundant predecessor can be acted on each eigenvalue in the form of negotiation elimination. In particular, here is the coordinated Split according to the form before merging to obtain a sequence of phase difference coordination vectors implicitly encoded in the time series context of normal power consumption data; Finally, the sequence of the phase difference coordination vector implicitly encoded in the time series context of the normal power consumption data is input into the decoder of the LSTM autoencoder model to obtain the sequence of the reconstructed power consumption data sliding window, so that the time series interference in the training process can be reduced by negotiating and weighing the flexible elimination of redundant noise. That is, by interacting the local sparse identification and the time series redundant precursor noise through phase coupling, a connection is established in the form of negotiated elimination, that is, by accurately acting on the local redundant disturbance source of the eigenvalue granularity of the global phase interaction, the phase difference coordination process of the collaborative redundancy is simulated, so that the elimination decision can effectively curb the redundant noise and flexibly act on the stability requirements of the global features, thereby improving the training effect of the LSTM autoencoder model. In particular, the decoding process here is the same as the above-mentioned implementation method.
[0038] Specifically, during the training phase of the smart meter local anomaly detection method, calculating the loss function is a key step in evaluating the learning performance of the LSTM autoencoder model. This calculation quantifies the model's accuracy in reconstructing normal electricity usage data, specifically the difference between the original input and the model output. This application calculates this difference to obtain a clear optimization target, allowing the model to continuously adjust its internal parameters during subsequent training to minimize this difference, enabling the model to more accurately learn and characterize normal electricity usage patterns.
[0039] More specifically, in one possible implementation of the present application, step S133, based on the sequence of the normal electricity consumption data sliding window and the sequence of the reconstructed electricity consumption data sliding window, calculates the loss function value, including: calculating the mean square error of the sequence of the normal electricity consumption data sliding window and the sequence of the reconstructed electricity consumption data sliding window as the loss function value.
[0040] The implementation method is as follows: First, from the sequence of normal power consumption data sliding windows, take out the current original sliding window, for example, a time series containing 8 consecutive hours of power consumption data points: [ , , , , , , , ]. At the same time, from the sequence of the obtained reconstructed sliding windows of the electricity consumption data, the reconstructed sliding window corresponding to the original window is taken out, for example: [ , , , , , , , ].
[0041] Next, for each corresponding data point in the two series, calculate the square of their difference. For example, for the first data point, calculate ( - )^2; For the second data point, calculate ( - )^2, and so on, until the last data point ( - )^2. These squared differences are then accumulated and divided by the length of the sliding window (8 in this example) to obtain the mean squared error for that single sliding window. For example, if the specific electricity usage data in the original window is [10, 12, 11, 15, 14, 13, 10, 9], and the corresponding window data reconstructed by the model is [10.2, 11.9, 11.1, 15.3, 13.8, 13.1, 9.8, 9.2], then the squared differences at each point are: for the first data point, (10-10.2)^2=0.04, for the second data point, (12-11.9)^2=0.01, and so on, up to the eighth data point, (9-9.2)^2=0.04. The cumulative sum is 0.28. The mean squared error for this window is 0.28 / 8=0.035.
[0042] This mean squared error value represents the accuracy of the model's reconstruction of the current sliding window. In actual training, data is processed in batches, that is, the mean squared error of all sliding windows in a batch is calculated at once, and then these mean squared errors are averaged to obtain the loss function value of the current batch.
[0043] Accordingly, in the initial stages, the autoencoder model's internal parameters, weights, and biases are random or preset, making it unable to accurately reconstruct normal electricity usage data. The calculated loss function quantifies the gap between the model's current reconstruction ability and the true normal pattern. To narrow this gap, the model requires a mechanism to adjust its internal parameters. Gradient descent and backpropagation are precisely such mechanisms. They efficiently calculate the direction and magnitude of each parameter's impact on the loss function and iteratively update the parameters accordingly, gradually reducing the model's reconstruction error with each iteration. Through continuous training, the model eventually learns and internalizes the complex temporal patterns of normal electricity usage data, enabling it to accurately distinguish between normal and abnormal patterns during the detection phase.
[0044] Specifically, one possible implementation of step S134 is as follows: First, before training begins, the weights and bias parameters of the LSTM autoencoder model (including all LSTM layers in the encoder and decoder, and any fully connected layers) are randomly initialized. After steps S131 and S132 complete a forward propagation phase and step S133 calculates the loss function value for the current batch of data, training enters the backward propagation phase.
[0045] The backpropagation algorithm begins at the model's output layer, which is the sliding window of reconstructed electricity usage data reconstructed by the decoder. Based on the loss function, it calculates the gradient of the loss with respect to each parameter in the model. This process uses the chain rule to propagate the error signal from the output layer forward, layer by layer, calculating the contribution of each layer, neuron, or LSTM unit's weights and biases to the total loss. For example, if the loss function is mean squared error, the error signal is calculated as the difference between the reconstructed value and the true value and propagates along the reverse path of the network.
[0046] After obtaining the gradients of all parameters, the gradient descent optimizer updates the model's weights and biases based on these gradients. The update rule is: new parameters = old parameters - learning rate * gradient. The learning rate is a key hyperparameter that determines the step size of each parameter update. Setting the learning rate is crucial; for example, a setting of 0.001 is recommended. If the learning rate is too high, the model may fail to converge, and the loss value will fluctuate or even diverge. If the learning rate is too low, the model converges very slowly. In practical applications, in addition to basic gradient descent, adaptive learning rate optimization algorithms such as Adam and RMSprop are more commonly used. These algorithms dynamically adjust the learning rate based on historical gradient information, accelerating convergence and improving training stability. This cycle of forward propagation, loss calculation, backpropagation, and parameter update is repeated until the loss function converges below a preset threshold, or the maximum number of training epochs (for example, 100) is reached, or performance on the validation set stops improving. At this point, a trained LSTM autoencoder model is obtained.
[0047] After the training is completed, the detection phase begins. That is, after the LSTM autoencoder model is trained using the smart electricity meter local anomaly detection algorithm, the trained LSTM autoencoder model is used in the actual detection phase.
[0048] Figure 3 Flowchart of the detection phase of the local abnormal point detection method for a smart electricity meter according to an embodiment of the present application. Figure 4 FIG. 1 is a schematic diagram of data flow in the detection phase of the local abnormal point detection method of the smart energy meter according to an embodiment of the present application. Figure 3 and Figure 4 As shown, the detection stage of the local abnormal point detection method of the smart electricity meter according to the embodiment of the present application includes: S210, obtaining the electricity consumption data to be detected; S220, performing sliding window sampling on the electricity consumption data to be detected with the window length and the sliding step size to obtain a sequence of sliding windows of the detection electricity consumption data; S230, inputting the sequence of sliding windows of the detection electricity consumption data into the trained LSTM autoencoder model to obtain a reconstructed error sequence; S240, marking the time point when the abnormality occurred based on the reconstructed error sequence.
[0049] In step S210, the electricity usage data to be tested is obtained. It should be understood that the training phase has enabled the LSTM autoencoder model to learn and grasp the inherent patterns of normal electricity usage. To apply this learning capability to real-world scenarios and promptly detect potential local anomalies such as electricity theft, equipment failure, or metering errors, the model needs to continuously receive the latest, unseen electricity usage data from smart meters. Only by acquiring this real-time or near-real-time data can it be input into the trained model for analysis, and the reconstruction error output by the model can be used to determine whether there are any abnormal behaviors that deviate from the normal pattern. Therefore, this step is the foundation for achieving continuous monitoring of electricity usage data and anomaly warnings.
[0050] Specifically, one possible implementation of step S210 is as follows: Acquiring the power consumption data to be detected involves continuously receiving a stream of power consumption data from a smart power meter data acquisition device or a power data aggregation device. This data is collected at a preset sampling frequency, such as recording power consumption values every hour or every 15 minutes, and is accompanied by a precise timestamp. For example, a user's power consumption data on a specific date, such as October 26, 2023, may continuously flow in in the form of a time series, such as: [2023-10-26 00:00:00, 1.2 kWh], [2023-10-26 01:00:00, 1.5 kWh], [2023-10-26 02:00:00, 1.3 kWh], etc.
[0051] After acquiring the data, necessary preprocessing is required to ensure its format and characteristics are consistent with the data from the training phase. This includes: First, basic data integrity checks are performed, such as verifying the continuity of timestamps and the validity of power consumption values, such as whether they are non-negative. For any small number of missing values or obvious erroneous values, strategies such as interpolation, forward filling, or direct elimination can be used to address them, but care must be taken to avoid introducing new anomalies. After these processes, the power consumption data to be tested is obtained.
[0052] In step S220, the power consumption data to be detected is subjected to sliding window sampling with the window length and the sliding step size to obtain a sequence of sliding windows for detecting power consumption data. Accordingly, in order for the model to accurately evaluate whether the new power consumption data is normal, the data to be detected needs to be presented to the model in the same format and context as the training data. A single isolated power consumption data point cannot provide sufficient time series information to determine whether it is abnormal, because the definition of local anomalies depends on the context in which they are located. By adopting a window length and sliding step size consistent with the training phase for sliding window sampling, it can be ensured that the input data received by the model has the same time series structure and context information, so that it can use the normal pattern it has learned to effectively compare and reconstruct, and then identify local anomalies that deviate from normal behavior.
[0053] Specifically, one possible implementation of step S220 is as follows: It is worth mentioning that the window length and sliding step size are determined and fixed in the training stage. For example, if the window length is set to 8 hours and the sliding step size is set to 1 hour in the training stage, then these two parameters are strictly used in the detection stage.
[0054] First, starting from the starting point of the time series of the power consumption data to be detected, the first data segment with a length equal to the window length is intercepted. For example, if the data to be detected is a continuous hourly power consumption sequence [ , , ,..., ], and the window length is 8, then the first sliding window for detecting electricity consumption data will be [ , , , , , , , ].
[0055] Then, the interception point is moved forward according to the preset sliding step. For example, if the sliding step is 1, the interception point is moved forward by one time step to intercept the second sliding window of the power consumption data: , , , , , , , ]. This process will continue until the end of the power consumption data sequence to be detected, that is, it will stop when the remaining data is less than a complete window length.
[0056] Finally, all the sliding windows intercepted in this way are arranged in the time sequence of the original data to be detected to form a sequence of sliding windows for detecting electricity consumption data.
[0057] In step S230, the sequence of the sliding window of the detected power consumption data is input into the trained LSTM autoencoder model to obtain a reconstruction error sequence. In other words, the trained LSTM autoencoder model has learned and internalized the complex time series characteristics of the normal power consumption pattern. When new power consumption data to be detected is input into this model, if the data conforms to the normal pattern learned by the model, the model can reconstruct it with a high degree of accuracy, thereby generating a lower reconstruction error. Conversely, if the data to be detected contains abnormal behavior, that is, it deviates from the normal pattern learned by the model, then the model will find it difficult to accurately reconstruct, resulting in a significantly higher reconstruction error. Therefore, this step provides a key quantitative basis for subsequent abnormality judgment by quantifying the difference between the input data and the normal representation within the model (i.e., the reconstruction error), enabling the model to adaptively identify local abnormal points that deviate from normal behavior, overcoming the challenge that traditional methods are difficult to adapt to dynamic power consumption patterns.
[0058] Specifically, one possible implementation of step S230 is as follows: For each sliding window of detected electricity usage data in the sequence, it is first input into the encoder portion of a trained LSTM autoencoder model. The encoder compresses this original, high-dimensional sliding window of electricity usage data into a low-dimensional temporal context implicit encoding vector. This vector is a compact representation of the original window, capturing its core temporal features. For example, an 8-hour window of electricity usage data might be compressed into a 32-dimensional vector after processing by the encoder.
[0059] The temporal contextual latent encoding vector generated by the encoder is then input into the decoder of the trained LSTM autoencoder model. The decoder's task is to expand this latent encoding vector and reconstruct it back into a time series with the same length and structure as the original input window, that is, to reconstruct the sliding window of electricity usage data. For example, the decoder attempts to restore an 8-hour electricity usage data sequence from a 32-dimensional latent vector.
[0060] Finally, for each original sliding window of detected power consumption data and its corresponding sliding window of reconstructed power consumption data, the mean squared error between them is calculated according to the method described in step S133. Specifically, the difference between each corresponding data point in the two windows is squared, then summed and divided by the window length. This process traverses each window in the sequence of sliding windows of detected power consumption data. Each time a window is processed, a corresponding reconstruction error value is obtained. These reconstruction error values are arranged in chronological order according to the corresponding sliding windows, ultimately forming a reconstruction error sequence.
[0061] In step S240, based on the reconstructed error sequence, the time point at which the anomaly occurs is marked. It should be understood that step S230 has calculated the reconstruction error for each sliding window of electricity consumption data to be detected, and these error values quantify the degree of deviation between the current electricity consumption pattern and the normal pattern learned by the model. However, simply obtaining the error value cannot directly indicate the occurrence of an anomaly. In order to convert these quantified errors into actionable anomaly alarms and clarify the time when the anomaly occurs, a judgment standard is needed to distinguish normal fluctuations from real anomalies. To this end, the present application can achieve accurate identification and timely warning of local anomalies by determining the time point when the anomaly occurs, thereby providing a basis for subsequent intervention measures.
[0062] Specifically, in one embodiment of the present application, Figure 5 FIG. 1 is a flow chart of step S240 in the method for detecting local abnormal points in a smart electric energy meter according to an embodiment of the present application. Figure 5 As shown, step S240, based on the reconstruction error sequence, marks the time point when the abnormality occurs, including: S241, comparing each reconstruction error in the reconstruction error sequence with a preset reconstruction error threshold; S242, if the reconstruction error is greater than the preset reconstruction error threshold, marking the corresponding detection power consumption data sliding window as containing a local abnormality; S243, based on the corresponding detection power consumption data sliding window, determining the time point when the abnormality occurs.
[0063] Specifically, one possible implementation method of step S240 is as follows: First, execute S241. The setting of the preset reconstruction error threshold is determined after the model training is completed, using a part of the normal electricity consumption data (validation set) that did not participate in the training. A common method is to calculate the reconstruction error distribution of these normal data on the model, and then select a statistic as the threshold. For example, it can be set to the mean of the normal reconstruction error plus three times the standard deviation, or a high percentile, such as the 99.5th percentile, to ensure that the reconstruction error of the vast majority of normal data points is lower than the threshold. For example, if after statistical analysis, the threshold is determined to be 0.05. Then, for each error value in the reconstruction error sequence, it will be compared with 0.05.
[0064] Next, S242 is executed. That is, when the reconstruction error of a sliding window, for example, 0.08, exceeds the preset threshold of 0.05, the window is determined to be an abnormal window. This marking process traverses the entire reconstruction error sequence and identifies all sliding windows determined to be abnormal.
[0065] Finally, execute S243. Each sliding window of power consumption data that is marked as containing a local anomaly corresponds to a continuous period of power consumption data and its timestamp. For example, the window length is 8 hours, and the data is collected hourly. An abnormal sliding window may contain 8 consecutive hours of power consumption data starting from a certain starting time point, such as 10:00 on October 26, 2023: [10:00, 11:00, 12:00, 13:00, 14:00, 15:00, 16:00, 17:00]. Specifically, in one embodiment of the present application, based on the corresponding sliding window of power consumption data, the time point when the anomaly occurs is determined, including: marking the timestamp of the central data point of the corresponding sliding window of power consumption data as the time point when the anomaly occurs. Specifically, when a sliding window is determined to be abnormal, the abnormal behavior may occur at any time within the window. Simply selecting the start or end point of the window may not accurately reflect the core period of occurrence of the anomaly. The central data point provides a balanced and representative estimate of the time of anomalies within a window. It avoids biasing the anomaly's time point toward either extreme of the window, providing a relatively accurate time reference for subsequent analysis or alerting. This is a practical and convenient location strategy, particularly when it's impossible or unnecessary to further refine the location of the specific data point within the window that contributed the most to the anomaly. It aims to provide a representative time anchor for an anomaly event. Determining the central data point of a sliding window requires calculation based on the window's length. For a sliding window containing N data points, the central data point is the data point located in the middle of the time series. If N is an odd number, the central point is clear. If N is an even number, such as 8 in this example, one of the two middle data points is selected, or more precisely, the data point closest to the midpoint of the window's time span is selected. For example, for an 8-hour window from 10:00 to 17:00, the midpoint is 13:30. The data points closest to this midpoint are the fourth data point at 13:00 or the fifth data point at 14:00. In this embodiment, it can be agreed that one of them is selected, for example, the fourth data point, ie, the data point with a timestamp of 13:00, is selected.
[0066] Finally, the timestamp of this central data point, for example, 13:00 on October 26, 2023, is marked and output as the time of the anomaly occurrence represented by the anomaly sliding window. This marked time point is used for subsequent anomaly reporting, alarm triggering, or further analysis, thereby accurately locating local anomalies in the smart meter's electricity usage data.
[0067] In summary, a method for detecting local anomalies in smart electricity meters based on an embodiment of the present application has been described. During the training phase, the method uses historical electricity usage data labeled as normal to define a window length and sliding step size, extracting a sequence of sliding windows of normal electricity usage data. These sliding windows cleverly capture the local temporal context of the electricity usage data, effectively addressing the global pattern masking effect and the dynamics and heterogeneity of the normal pattern mentioned in the background art, ensuring that local anomalies are not overwhelmed by macro fluctuations. Subsequently, an LSTM autoencoder is trained based on these sequences of normal sliding windows, enabling it to deeply learn and internalize the temporal characteristics and inherent laws of normal electricity usage patterns, rather than relying on fixed global standards. During the detection phase, the data to be detected is sampled using the same sliding window method and input into the trained autoencoder. By calculating the reconstruction error, the method can accurately identify local anomalies that deviate significantly from the normal pattern. This method overcomes the shortcomings of traditional fixed thresholds or global statistical methods, which cannot capture subtle local changes, and enables early and accurate detection of key signals such as electricity theft and equipment failure, thereby significantly improving power supply reliability and operational efficiency.
[0068] Figure 6 FIG is a block diagram of a local abnormal point detection system for a smart electric energy meter according to an embodiment of the present application. Figure 6As shown, the local abnormal point detection system 100 of the smart energy meter according to the embodiment of the present application includes: a training module 110, including: a normal historical electricity consumption data acquisition unit 111, used to obtain historical electricity consumption data marked as normal; a normal electricity consumption data extraction unit 112, used to define the window length and the sliding step size, and extract a sequence of normal electricity consumption data sliding windows from the historical electricity consumption data marked as normal; an LSTM autoencoder training unit 113, used to train the LSTM autoencoder model based on the sequence of the normal electricity consumption data sliding windows to obtain a trained LSTM autoencoder Model; a detection module 120, comprising: an electricity consumption data acquisition unit 121 to be detected, for acquiring the electricity consumption data to be detected; a detection electricity consumption data sliding sampling unit 122, for performing sliding window sampling on the electricity consumption data to be detected with the window length and the sliding step to obtain a sequence of sliding windows of the detection electricity consumption data; a reconstruction error generation unit 123, for inputting the sequence of sliding windows of the detection electricity consumption data into the trained LSTM autoencoder model to obtain a reconstruction error sequence; an abnormal time point marking unit 124, for marking the time point when the abnormality occurs based on the reconstruction error sequence.
[0069] Here, those skilled in the art will appreciate that the specific operations of each step in the above-mentioned smart energy meter local abnormal point detection system have been described in detail in the above reference. Figures 1 to 5 The description of the local abnormal point detection method of the smart electric energy meter has been described in detail, and therefore, its repeated description will be omitted.
Claims
1. A method for detecting local abnormal points in a smart electric energy meter, characterized in that: include: Training phase and testing phase; The training phase includes: Obtain historical electricity consumption data marked as normal; defining a window length and a sliding step size, and extracting a sequence of normal power consumption data sliding windows from the historical power consumption data marked as normal; Training an LSTM autoencoder model based on a sequence of the normal electricity consumption data sliding window to obtain a trained LSTM autoencoder model; The detection phase includes: Obtaining the electricity consumption data to be tested; Performing sliding window sampling on the power consumption data to be detected using the window length and the sliding step length to obtain a sequence of sliding windows for detecting power consumption data; Inputting the sequence of the sliding window of the detected electricity consumption data into the trained LSTM autoencoder model to obtain a reconstruction error sequence; Based on the reconstructed error sequence, the time point at which the abnormality occurs is marked.
2. The method for detecting local abnormal points in a smart electric energy meter according to claim 1, wherein: Training an LSTM autoencoder model based on the sequence of the normal electricity consumption data sliding window to obtain a trained LSTM autoencoder model includes: Inputting the sequence of the normal power consumption data sliding window into the encoder of the LSTM autoencoder model to obtain a sequence of normal power consumption data time series context implicit coding vectors; Inputting the sequence of the normal electricity consumption data time series context implicit coding vectors into the decoder of the LSTM autoencoder model to obtain a sequence of reconstructed electricity consumption data sliding windows; Calculating a loss function value based on the sequence of the normal power consumption data sliding window and the sequence of the reconstructed power consumption data sliding window; The LSTM autoencoder model is trained based on the loss function value and through back propagation of gradient descent.
3. The method for detecting local abnormal points in a smart electric energy meter according to claim 2, wherein: The encoder of the LSTM autoencoder model is one or more LSTM layers, and the decoder of the LSTM autoencoder model is one or more LSTM layers.
4. The method for detecting local abnormal points in a smart electric energy meter according to claim 3, characterized in that: Inputting the sequence of the normal power consumption data time series context implicit coding vectors into the decoder of the LSTM autoencoder model to obtain a sequence of reconstructed power consumption data sliding windows, including: Defining a temporal redundancy predecessor probability based on the window length and the sliding step size; Performing local sparsification on the sequence of the temporal context implicit coding vectors of the normal power consumption data based on temporal redundancy predecessor probability to obtain a local sparsification control factor; Applying the temporal redundancy predecessor probability and the local sparsification control factor to the eigenvalue of each normal power consumption data temporal context implicit coding vector in the sequence of normal power consumption data temporal context implicit coding vectors in a negotiated elimination form to obtain a sequence of normal power consumption data temporal context implicit coding phase difference coordination vectors; The sequence of the phase difference coordination vector implicitly encoded in the context of the normal power consumption data time series is input into the decoder of the LSTM autoencoder model to obtain the sequence of the reconstructed power consumption data sliding window.
5. The method for detecting local abnormal points in a smart electric energy meter according to claim 3, characterized in that: Based on the sequence of the normal power consumption data sliding window and the sequence of the reconstructed power consumption data sliding window, a loss function value is calculated, including: calculating the mean square error of the sequence of the normal power consumption data sliding window and the sequence of the reconstructed power consumption data sliding window as the loss function value.
6. The method for detecting local abnormal points in a smart electric energy meter according to claim 1, wherein: Based on the reconstructed error sequence, marking the time point when the abnormality occurs includes: comparing each reconstruction error in the reconstruction error sequence with a preset reconstruction error threshold; If the reconstruction error is greater than the preset reconstruction error threshold, marking the corresponding sliding window of the detected power consumption data as containing a local anomaly; Based on the corresponding sliding window of detected power usage data, the time point when the abnormality occurs is determined.
7. The method for detecting local abnormal points in a smart electric energy meter according to claim 6, characterized in that: Determining a time point at which an anomaly occurs based on the corresponding sliding window of the detected power consumption data includes marking a timestamp of a central data point of the corresponding sliding window of the detected power consumption data as the time point at which the anomaly occurs.
8. A local abnormal point detection system for smart electric energy meters, characterized in that: include: Training modules include: A normal historical electricity consumption data acquisition unit, configured to acquire historical electricity consumption data marked as normal; a normal power consumption data extraction unit, configured to define a window length and a sliding step length, and extract a sequence of normal power consumption data sliding windows from the historical power consumption data marked as normal; An LSTM autoencoder training unit, configured to train an LSTM autoencoder model based on a sequence of the normal electricity consumption data sliding window to obtain a trained LSTM autoencoder model; Detection module, including: The power consumption data acquisition unit to be detected is used to acquire the power consumption data to be detected; a power consumption data sliding sampling unit for detecting power consumption data, configured to perform sliding window sampling on the power consumption data to be detected using the window length and the sliding step length to obtain a sequence of sliding windows of the power consumption data to be detected; A reconstruction error generating unit, configured to input the sequence of the sliding window of the detected electricity consumption data into the trained LSTM autoencoder model to obtain a reconstruction error sequence; The abnormal time point marking unit is used to mark the time point when the abnormality occurs based on the reconstructed error sequence.
Citation Information
Patent Citations
Mobile node monitoring data sequence compression method based on sparse processing
CN108810553A
An abnormal data screening method based on a long-term and short-term memory network
CN109345408A
Sound scene classification method based on width and depth neural network
CN111723874A
Process anomaly detection method based on time sequence shielding auto-encoder
CN119312237A
Satellite time series data anomaly detection method and system
CN119646533A