User power consumption data anomaly detection method, device and equipment

Through Fourier transform, multi-periodic features in user power consumption data are discovered, and combined with the unsupervised learning method of Transformer architecture, the problem that traditional methods are difficult to capture complex periodic features is solved, achieving higher abnormal detection accuracy and Reduced dependence on data.

CN119494067AInactive Publication Date: 2025-02-21STATE GRID SICHUAN ELECTRIC POWER CO MARKETING SERVICE CENT
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202411547250.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-01
Publication Date
2025-02-21
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The prior art is difficult to effectively capture the complex periodicity and timing characteristics of user electricity consumption data. Especially when the data volume and complexity increase, traditional methods require a lot of manual intervention and have strong dependence on the data prior distribution.

Method used

Fourier transform (FFT) adaptive discovery of multi-periodic features in data, and combined with the unsupervised learning method of Transformer architecture, we capture and model abnormal behavior in user power consumption data.

Benefits of technology

It improves the accuracy of abnormal detection, reduces the dependence on data prior knowledge, and supports the stable operation of the power system and user electricity consumption behavior analysis.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119494067A_ABST
    Figure CN119494067A_ABST
Patent Text Reader

Abstract

The invention discloses a user power consumption data anomaly detection method. The method specifically comprises the steps of collecting user power consumption data to form a data set; preprocessing the data set; performing windowing processing on the preprocessed data; inputting the obtained windowed data into a stacking encoder module, and carrying out stacking encoding output processing; the obtained stack coding output data and the preprocessed data are input into a stack decoder module for stack decoding output processing; inputting the obtained stack decoding output data into a convergence module for convergence processing; and through a loss function, carrying out loss calculation on the obtained convergence processing output data and the preprocessed data, and carrying out abnormal judgment on the power consumption data. The method comprises the following steps: finding a potential period of power utilization data by utilizing fast Fourier transform, and performing windowing processing on user data according to the potential period; the stacked Transform architecture is used for processing data in different period windows, features of power consumption data in different potential periods are found, and the detection effect of power consumption behavior abnormity is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of power grid user electricity consumption data, and specifically relates to a method, device and equipment for detecting abnormality in user electricity consumption data. Background Art

[0002] With the development of power systems and smart grids, the accuracy and reliability of power consumption data of power grid users are particularly important. Power grid user power consumption data is not only used for billing and energy consumption analysis, but also provides basic data for power system optimization and dispatching, load forecasting, energy efficiency management, and power consumption behavior analysis. Therefore, accurate and real-time monitoring of abnormal phenomena in user power consumption data is an important part of ensuring the safe and stable operation of the power system.

[0003] Traditional methods for detecting anomalies in electricity consumption data are mainly based on rules and statistical methods, or on building anomaly detection models based on historical data. These methods usually require a lot of manual intervention and have a strong dependence on the prior distribution of data. In addition, with the popularization of smart meters and sensors, the volume and complexity of user electricity consumption data have increased significantly, and the data often contains a variety of periodic features. Traditional methods are difficult to effectively capture these complex periodic and time series features.

[0004] In order to better detect anomalies in user electricity consumption data, deep learning-based methods have gradually attracted attention in recent years. Among them, the Transformer architecture is considered to be a potential technology for handling anomaly detection in electricity consumption data due to its superior performance in sequence data modeling. The Transformer architecture can effectively capture long-term and short-term dependencies and complex time series features in data sequences through the attention mechanism without relying on the fixed periodic structure of the data. In electricity consumption data, periodic features usually correspond to users' electricity consumption behavior patterns, such as daily and weekly electricity consumption habits. However, these periodic features are not always obvious or fixed, and may change over time or with changes in external factors. Therefore, how to adaptively discover these multi-periodic features and then perform anomaly detection is a difficulty in current technology. Summary of the invention

[0005] The technical problem to be solved by the present invention is to provide a method for detecting anomalies in user electricity consumption data, which adopts Fourier transform (FFT) to adaptively discover multi-periodic features in data, and combines the unsupervised learning method of Transformer architecture to effectively capture and model abnormal behaviors in user electricity consumption data; through this method, the accuracy of anomaly detection can be improved, and the dependence on prior knowledge of data can be reduced, which provides strong support for the stable operation of the power system and the analysis of user electricity consumption behavior.

[0006] In order to solve the above technical problems, the present invention is implemented in the following ways:

[0007] A method for detecting abnormality in user power consumption data, specifically comprising the following steps:

[0008] Collect daily user electricity consumption data within a certain period of time to form a data set;

[0009] The data set is preprocessed, and the preprocessing includes filling processing and normalization processing, wherein the filling processing adopts zero filling processing for the missing values ​​of the data in the data set, and its expression is as follows:

[0010]

[0011] Among them, x i represents the data of the i-th day, f(x i ) represents the data of the i-th day after processing;

[0012] All user data are normalized, and the expression is as follows:

[0013]

[0014] Among them, x max , x min Respectively represent the maximum and minimum values ​​of electricity consumption in the data set;

[0015] Windowing of preprocessed data;

[0016] The obtained windowed data is input into the stacked encoder module for stacked encoding output processing;

[0017] The obtained stack coding output data and pre-processed data are input into the stack decoder module for stack decoding output processing;

[0018] The obtained stacked decoding output data is input into the aggregation module for aggregation processing;

[0019] Through the loss function, the obtained converged processing output data and pre-processed data are used to calculate the loss and judge the abnormality of electricity consumption data.

[0020] Furthermore, the specific method of the window processing is as follows:

[0021] The self-discovery multi-period data processing module is implemented based on the fast Fourier transform. The pre-processed data X is subjected to the fast Fourier transform FFT in the time dimension to obtain the frequency components in the corresponding complex form. The amplitude Amp of the frequency variable is taken in the time dimension to obtain the amplitude of each frequency component. The obtained amplitude data is averaged in the user number dimension to obtain the frequency amplitude pair sequence A that integrates multiple user data. The specific expression is as follows:

[0022] A = Avg(Amp(FFT(X)))

[0023] Each frequency amplitude pair of sequence A consists of (f i , a i )(0 < i ≤ T), so it can be expressed as follows:

[0024] A = {(f1, a1), (f2, a2), …, (f T , a T )}

[0025] Among them, f i represents the frequency, a i represents the corresponding amplitude, and T represents the length of the sequence A of frequency amplitude pairs;

[0026] Select the frequency amplitude pairs in A that contain the largest k amplitudes, and sequence B is obtained by sorting the k frequency amplitude pairs in descending order of amplitude. Its specific expression is as follows:

[0027]

[0028] Among them,

[0029] Calculate k most significant periods through the amplitude pair sequence length T and the frequencies in the k frequency amplitude pairs in sequence B. The specific expression of the period length is as follows:

[0030]

[0031] Among them, P i represents the period length of the corresponding significant period;

[0032] Create k pieces of windowed data for the preprocessed data using a sliding window. Each piece of windowed data corresponds to a period. In the i-th piece of windowed data, the size of the sliding window is taken as P i , and using the sliding window, add the electricity consumption data of the previous P i dates to the electricity consumption data of each user's single day, so as to transform the form X num,feats of the i-th piece of windowed data into windowed data Its specific expression is as follows:

[0033]

[0034] Among them, x j represents the electricity consumption data of the user on the j-th day.

[0035] Furthermore, the stacked encoder module is composed of a position encoding module and k stacked Transformer encoder modules, the Transformer encoder module corresponds one-to-one to the k windowed data and the Transformer decoder module, the position encoding module adds the position information of the sequence to the windowed data, and adds the obtained vector with the position information to the vector of the windowed data, and its specific expression is as follows:

[0036]

[0037] Among them, j represents the window position generated on the original data position in the input data, pos,i represents the original data position in the input data, and d represents the dimension of the hidden layer. Indicates the jth window data whose original data position in the input data is (pos,i), PE (pos,2i) and PE (pos,2i+1) Respectively represent the position codes of the data at the original data position (pos, 2i) and the data at the position (pos, 2i+1) in the input data;

[0038] Each encoder module in the k Transformer encoder modules consists of a multi-head attention layer, a layer normalization layer, a residual connection layer and a forward connection layer. The i-th windowed data with position information processed by the position encoding module After passing through the multi-head attention layer and the residual connection layer, the output of the layer normalization layer is input into the layer normalization layer through the forward connection layer and the residual connection layer to obtain the output data of the i-th encoder module.

[0039] Furthermore, the stacked decoder module is composed of a position encoding module and a stack of k Transformer decoder modules. The position encoding module adds position information to the preprocessed data, and adds the obtained vector with position information to the vector of the preprocessed data. The specific expression is as follows:

[0040] X (pos,i) =X (pos,i) +PE (pos,i)

[0041]

[0042] Among them, X (pos,i) Represents the data at position (pos,i) in the preprocessed data;

[0043] The decoder module is composed of a masked multi-head attention layer, a layer normalization layer, a residual connection layer, a multi-head attention layer and a forward connection layer. The i-th pre-processed data X with position information processed by the position encoding module num,feats The output of the masked multi-head attention layer and the residual connection layer is input to the layer normalization layer, and the output of the layer normalization layer is combined with the output of the i-th encoder module. After being input into the layer normalization layer through the multi-head attention layer and the residual connection layer, and then input into the layer normalization layer through the forward connection layer and the residual connection, the output data Y of the i-th decoder module is obtained. i .

[0044] Furthermore, the specific method of the aggregation processing is as follows:

[0045] In the aggregation module, the k output data Y of the stacked decoder module are i To perform aggregation, the specific aggregation expression is as follows:

[0046]

[0047] The aggregated output data Y is passed through the forward connection layer and the Sigmoid activation function in sequence to obtain the final output O.

[0048] Furthermore, the specific method for abnormality judgment is as follows:

[0049] The loss is calculated for the final output of the aggregation module and the preprocessed data through a loss function, where the loss function is a mean square error loss function. When the loss exceeds a threshold, the user data is considered abnormal data.

[0050] A device for detecting abnormality in user power consumption data, the device comprising:

[0051] A data collection module is used to collect daily electricity consumption data of users within a certain period of time to form a data set;

[0052] The data preprocessing module is used to preprocess the data set. The preprocessing includes filling processing and normalization processing. The filling processing adopts zero filling processing for the missing values ​​of the data in the data set. Its expression is as follows:

[0053]

[0054] Among them, x i represents the data of the i-th day, f(x i ) represents the data of the i-th day after processing;

[0055] All user data are normalized, and the expression is as follows:

[0056]

[0057] Among them, x max , x min respectively represent the maximum and minimum values of the electricity consumption in the dataset;

[0058] The windowing processing module is used to perform windowing processing on the dataset;

[0059] The stacked encoding module is used to input the obtained windowed data into the stacked encoder module for stacked encoding output processing;

[0060] The stacked decoding module is used to input the obtained stacked encoding output data and the preprocessed data into the stacked decoder module for stacked decoding output processing;

[0061] The aggregation module is used to input the obtained stacked decoding output data into the aggregation module for aggregation processing;

[0062] The data judgment module is used to calculate the loss between the obtained aggregation processing output data and the preprocessed data through the loss function to judge the abnormality of the electricity consumption data.

[0063] Among them, the specific method of windowing processing in the windowing processing module is as follows:

[0064] The self-discovery multi-period data processing module is implemented based on the fast Fourier transform. The preprocessed data X is subjected to a fast Fourier transform FFT in the time dimension to obtain the corresponding complex frequency components; the amplitude Amp is taken for the frequency variable in the time dimension to obtain the amplitudes of each frequency component; the mean value is taken for the obtained amplitude data in the user number dimension to obtain the frequency amplitude pair sequence A that fuses the data of multiple users. Its specific expression is as follows:

[0065] A = Avg(Amp(FFT(X)))

[0066] Each frequency amplitude pair of the sequence A consists of (f i , a i )(0 < i ≤ T), so it can be expressed as follows:

[0067] A = {(f1, a1), (f2, a2), …, (f T , a T )}

[0068] Among them, f i represents the frequency, a i represents the corresponding amplitude, and T represents the length of the frequency-amplitude pair sequence A;

[0069] Select the frequency-amplitude pairs containing the largest k amplitudes in A, and sort the k frequency-amplitude pairs in descending order according to the amplitude. The specific expression is as follows:

[0070] in,

[0071] The k most significant cycles are calculated by the amplitude pair sequence length T and the frequencies of the k frequency amplitude pairs in the sequence B. The specific expression of the cycle length is as follows:

[0072]

[0073] Among them, P i Indicates the period length of the corresponding significant period;

[0074] Use a sliding window to create k pieces of windowed data for the preprocessed data. Each piece of windowed data corresponds to one period. In the i-th piece of windowed data, the size of the sliding window is P. i , using a sliding window, add the first P to each user's daily electricity consumption data i The electricity consumption data of a date is converted into the form of X num,feats Transform to windowed data The specific expression is as follows:

[0075]

[0076] Among them, x j Represents the user's electricity consumption data on the jth day.

[0077] The specific method of stacked coding output processing in the stacked coding module is as follows:

[0078] The stacked encoder module is composed of a position encoding module and k stacked Transformer encoder modules. The Transformer encoder module corresponds one-to-one to the k windowed data and the Transformer decoder module. The position encoding module adds the position information of the sequence to the windowed data, and adds the obtained vector with the position information to the vector of the windowed data. The specific expression is as follows:

[0079]

[0080] Among them, j represents the window position generated on the original data position in the input data, pos,i represents the original data position in the input data, and d represents the dimension of the hidden layer. Indicates the jth window data whose original data position in the input data is (pos,i), PE (pos,2i) and PE(pos,2i+1) Respectively represent the position codes of the data at the original data position (pos, 2i) and the data at the position (pos, 2i+1) in the input data;

[0081] Each encoder module in the k Transformer encoder modules consists of a multi-head attention layer, a layer normalization layer, a residual connection layer and a forward connection layer. The i-th windowed data with position information processed by the position encoding module The output of the layer normalization layer is input into the layer normalization layer through the multi-head attention layer and the residual connection layer in turn. The output of the layer normalization layer is then input into the layer normalization layer through the forward connection layer and the residual connection layer to obtain the output data of the i-th encoder module.

[0082] The specific method of stacked decoding output processing in the stacked decoding module is as follows:

[0083] The stacked decoder module is composed of a position encoding module and a stack of k Transformer decoder modules. The position encoding module adds position information to the preprocessed data and adds the obtained vector with position information to the vector of the preprocessed data. The specific expression is as follows:

[0084] X (pos,i) =X (pos,i) +PE (pos,i)

[0085]

[0086]

[0087] Among them, X (pos,i) Represents the data at position (pos,i) in the preprocessed data;

[0088] The decoder module is composed of a masked multi-head attention layer, a layer normalization layer, a residual connection layer, a multi-head attention layer and a forward connection layer. The i-th pre-processed data X with position information processed by the position encoding module num,feats The output of the masked multi-head attention layer and the residual connection layer is input to the layer normalization layer, and the output of the layer normalization layer is combined with the output of the i-th stacked encoder module. After being input into the layer normalization layer through the multi-head attention layer and the residual connection layer, and then input into the layer normalization layer through the forward connection layer and the residual connection, the output data Y of the i-th decoder module is obtained. i .

[0089] The specific method of the aggregation processing in the aggregation module is as follows:

[0090] In the aggregation module, the k output data Y of the stacked decoder module are i To perform aggregation, the specific aggregation expression is as follows:

[0091]

[0092] The aggregated output data Y is passed through the forward connection layer and the Sigmoid activation function in sequence to obtain the final output O.

[0093] The specific method of abnormality judgment in the data judgment module is as follows:

[0094] The loss is calculated for the final output of the aggregation module and the preprocessed data through a loss function, where the loss function is a mean square error loss function. When the loss exceeds a threshold, the user data is considered abnormal data.

[0095] A computer-readable storage medium contains computer-executable instructions, and the computer-executable instructions are executed by a processor to implement a method for detecting abnormalities in user electricity consumption data.

[0096] A computer device comprising a processor;

[0097] The processor is used to store one or more programs;

[0098] When the one or more programs are executed by the processor, any method described in a method for detecting abnormalities in user power consumption data is implemented.

[0099] Compared with the prior art, the present invention has the following beneficial effects:

[0100] The present invention uses fast Fourier transform to discover potential significant cycles of user electricity usage data, and performs window processing on user data according to the discovered cycles; uses the encoder-decoder architecture of stacked Transformers to process data in different cycle windows respectively, discovers the characteristics of user electricity usage data in different potential cycles, and then aggregates the detection results according to certain weights, thereby improving the detection effect of abnormal user electricity usage behavior. BRIEF DESCRIPTION OF THE DRAWINGS

[0101] Figure 1 It is a schematic diagram of the overall process of the present invention;

[0102] Figure 2 This is a schematic diagram of the data windowing module architecture of the present invention;

[0103] Figure 3 A schematic diagram of a stacked encoder architecture of the present invention;

[0104] Figure 4A schematic diagram of a stacked decoder architecture of the present invention;

[0105] Figure 5 Schematic diagram of the Transformer encoder-decoder network architecture of the present invention;

[0106] Figure 6 It is a schematic diagram of the convergence module architecture of the present invention. DETAILED DESCRIPTION

[0107] The specific implementation of the present invention is further described in detail below with reference to the accompanying drawings and specific examples.

[0108] like Figure 1 As shown, a method for detecting abnormality in user power consumption data specifically includes the following steps:

[0109] Collect daily user electricity consumption data within a certain period of time to form a data set;

[0110] The data set is preprocessed, which includes filling processing and normalization processing. The filling processing adopts zero filling processing for the missing values ​​of the data in the data set (mainly the missing values ​​of daily electricity consumption), and its expression is as follows:

[0111]

[0112] Among them, x i represents the data of the i-th day, f(x i ) represents the data of the i-th day after processing;

[0113] All user data are normalized, and the expression is as follows:

[0114]

[0115] Among them, x max , x min Respectively represent the maximum and minimum values ​​of electricity consumption in the data set;

[0116] The preprocessed data is windowed. The specific method is as follows:

[0117] The self-discovery multi-period data processing module is implemented based on the fast Fourier transform. The pre-processed data X is subjected to the fast Fourier transform FFT in the time dimension to obtain the frequency components in the corresponding complex form. The amplitude Amp of the frequency variable is taken in the time dimension to obtain the amplitude of each frequency component. The obtained amplitude data is averaged in the user number dimension to obtain the frequency amplitude pair sequence A that integrates multiple user data. The specific expression is as follows:

[0118] A=Avg(Amp(FFT(X)))

[0119] Each frequency amplitude pair of Sequence A consists of (f i , a i )(0 < i ≤ T), so it can be expressed as follows:

[0120] A = {(f1, a1), (f2, a2), …, (f T , a T )}

[0121] where f i represents the frequency, a i represents the corresponding amplitude, and T represents the length of the frequency-amplitude pair sequence A;

[0122] Select the frequency amplitude pairs in A that contain the largest k amplitudes, and sequence B is obtained by sorting the k frequency amplitude pairs in descending order of amplitude. Its specific expression is as follows:

[0123]

[0124] where

[0125] By calculating the sequence length T of the amplitude pair and the frequencies in the k frequency amplitude pairs in sequence B, k most significant periods are obtained. The specific expression of the period length is as follows:

[0126]

[0127] where P i represents the period length of the corresponding significant period; the time series has multi-periodicity. For this application, the period length corresponding to the most significant period is P1, and the length corresponding to the second most significant period is P2. Then, the user's electricity consumption data on a certain day will have the closest correlation with the data of the previous P1 - 1 days and the second closest correlation with the data of the previous P2 - 1 days. Windowing according to the significant period is beneficial for the model to capture the data characteristics within the significant period and the correlations between different significant periods.

[0128] As Figure 2 shown, k pieces of windowed data are created for the preprocessed data using a sliding window. Each piece of windowed data corresponds to a period. In the i-th piece of windowed data, the size of the sliding window is taken as P i . Using the sliding window, the electricity consumption data of the previous P i dates is added to the electricity consumption data of each user's single-day, so as to transform the form X num,feats of the i-th piece of windowed data into windowed data Its specific expression is as follows:

[0129]

[0130] Among them, x j represents the electricity consumption data of the user on the jth day, i represents the window size from the original data X num,feats The i-th data generated

[0131] The obtained windowed data is input into the stacked encoder module for stacked encoding output processing;

[0132] like Figure 3 As shown, the stacked encoder module is composed of a position encoding module and k stacked Transformer encoder modules. The Transformer encoder module corresponds one-to-one to the k windowed data and the Transformer decoder module. The position encoding module adds the position information of the sequence to the windowed data, and adds the obtained vector with the position information to the vector of the windowed data. The specific expression is as follows:

[0133]

[0134] Among them, j represents the window position generated on the original data position in the input data, pos,i represents the original data position in the input data, and d represents the dimension of the hidden layer. Indicates the jth window data whose original data position in the input data is (pos,i), PE (pos,2i) and PE (pos,2i+1) Respectively represent the position codes of the data at the original data position (pos, 2i) and the data at the position (pos, 2i+1) in the input data;

[0135] Each encoder module in the k Transformer encoder modules consists of a multi-head attention layer, a layer normalization layer, a residual connection layer and a forward connection layer. The i-th windowed data with position information processed by the position encoding module After passing through the multi-head attention layer, the residual connection layer, the layer normalization layer, and the output of the layer normalization layer, and then passing through the forward connection layer and the residual connection layer, the layer normalization layer is input to obtain the output data of the i-th encoder module.

[0136] The obtained stack coding output data and pre-processed data are input into the stack decoder module for stack decoding output processing;

[0137] like Figures 4-5As shown, the stacked decoder module is composed of a position encoding module and k stacked Transformer decoder modules. The position encoding module adds position information to the preprocessed data and adds the obtained vector with position information to the vector of the preprocessed data. The specific expression is as follows:

[0138] X (pos,i) =X (pos,i) +PE (pos,i)

[0139]

[0140] Among them, X (pos,i) Represents the data at position (pos,i) in the preprocessed data;

[0141] The decoder module is composed of a masked multi-head attention layer, a layer normalization layer, a residual connection layer, a multi-head attention layer and a forward connection layer. The i-th pre-processed data X with position information processed by the position encoding module num,feats It is input to the masked multi-head attention layer, the residual connection layer, the layer normalization layer, the output of the layer normalization layer, and then combined with the output of the i-th stacked encoder module. After being input into the layer normalization layer through the multi-head attention layer and the residual connection layer, and then input into the layer normalization layer through the forward connection layer and the residual connection, the output data Y of the i-th decoder module is obtained. i .

[0142] The obtained stacked decoding output data is input to the aggregation module for aggregation processing. The specific method is as follows:

[0143] like Figure 6 As shown, in the aggregation module, the k output data Y of the stacked decoder module are i To perform aggregation, the specific aggregation expression is as follows:

[0144]

[0145] The aggregated output data Y is passed through the forward connection layer and the Sigmoid activation function in sequence to obtain the final output O.

[0146] Through the loss function, the obtained converged processing output data and pre-processed data are used to calculate the loss, and the abnormal power consumption data is judged. The specific method is as follows:

[0147] The loss is calculated for the final output of the aggregation module and the preprocessed data through the loss function. The loss function is the mean square error loss function, which is optimized using the general Adam optimizer to make the distribution of the generated data closer to the data distribution of normal user electricity consumption. The smaller the loss function, the closer the distribution of the model is to the distribution of normal data. When the loss exceeds the threshold, the user data is regarded as abnormal data; when the loss does not exceed the threshold, the user data is regarded as normal data and has the distribution of normal data.

[0148] A device for detecting abnormality in user power consumption data, the device comprising:

[0149] A data collection module is used to collect daily electricity consumption data of users within a certain period of time to form a data set;

[0150] The data preprocessing module is used to preprocess the data set. The preprocessing includes filling processing and normalization processing. The filling processing adopts zero filling processing for the missing values ​​of the data in the data set. Its expression is as follows:

[0151]

[0152] Among them, x i represents the data of the i-th day, f(x i ) represents the data of the i-th day after processing;

[0153] All user data are normalized, and the expression is as follows:

[0154]

[0155] Among them, x max , x min Respectively represent the maximum and minimum values ​​of electricity consumption in the data set;

[0156] Window processing module, used for window processing of data sets;

[0157] A stack coding module, used for inputting the obtained windowed data into a stack encoder module for stack coding output processing;

[0158] A stack decoding module is used to input the obtained stack coding output data and pre-processed data into the stack decoder module for stack decoding output processing;

[0159] The aggregation module is used to input the obtained stacked decoding output data into the aggregation module for aggregation processing;

[0160] The data judgment module is used to calculate the loss of the obtained converged processing output data and the pre-processed data through the loss function, and judge the abnormality of the power consumption data.

[0161] Among them, the specific method of windowing processing in the windowing processing module is as follows:

[0162] The self-discovery multi-period data processing module is based on the fast Fourier transform. Perform a fast Fourier transform FFT on the preprocessed data X in the time dimension to obtain the corresponding frequency components in complex form; take the amplitude Amp of the frequency variable in the time dimension to obtain the amplitudes of each frequency component; take the mean value of the obtained amplitude data in the user number dimension to obtain the frequency amplitude pair sequence A that fuses the data of multiple users. Its specific expression is as follows:

[0163] A = Avg(Amp(FFT(X)))

[0164] Each frequency amplitude pair of sequence A consists of (f i , a i )(0 < i ≤ T), so it can be expressed as follows:

[0165] A = {(f1, a1), (f2, a2), …, (f T , a T )}

[0166] Among them, f i represents the frequency, a i represents the corresponding amplitude, and T represents the length of the frequency-amplitude pair sequence A;

[0167] Select the frequency amplitude pairs in A that contain the largest k amplitudes, and sort the k frequency amplitude pairs in descending order according to the amplitude to obtain sequence B. Its specific expression is as follows:

[0168]

[0169] Among them,

[0170] Calculate k most significant periods through the length T of the amplitude pair sequence and the frequencies in the k frequency amplitude pairs in sequence B. The specific expression of the period length is as follows:

[0171]

[0172] Among them, P i represents the period length of the corresponding significant period;

[0173] Create k pieces of windowed data for the preprocessed data using a sliding window. Each piece of windowed data corresponds to a period. In the i-th piece of windowed data, the size of the sliding window is taken as P i , and using the sliding window, add the electricity consumption data of the previous P i dates to the daily electricity consumption data of each user, so as to form the i-th piece of windowed data in the form of Xnum,feats Transform to windowed data The specific expression is as follows:

[0174]

[0175] Among them, x j Represents the user's electricity consumption data on the jth day.

[0176] The specific method of stacked coding output processing in the stacked coding module is as follows:

[0177] The stacked encoder module is composed of a position encoding module and k stacked Transformer encoder modules. The Transformer encoder module corresponds one-to-one to the k windowed data and the Transformer decoder module. The position encoding module adds the position information of the sequence to the windowed data, and adds the obtained vector with the position information to the vector of the windowed data. The specific expression is as follows:

[0178]

[0179] Among them, j represents the window position generated on the original data position in the input data, pos,i represents the original data position in the input data, and d represents the dimension of the hidden layer. Indicates the jth window data whose original data position in the input data is (pos,i), PE (pos,2i) and PE (pos,2i+1) Respectively represent the position codes of the data at the original data position (pos, 2i) and the data at the position (pos, 2i+1) in the input data;

[0180] Each encoder module in the k Transformer encoder modules consists of a multi-head attention layer, a layer normalization layer, a residual connection layer and a forward connection layer. The i-th windowed data with position information processed by the position encoding module After passing through the multi-head attention layer, the residual connection layer, the layer normalization layer, and the output of the layer normalization layer, and then passing through the forward connection layer and the residual connection layer, the layer normalization layer is input to obtain the output data of the i-th encoder module.

[0181] The specific method of stacked decoding output processing in the stacked decoding module is as follows:

[0182] The stacked decoder module is composed of a position encoding module and a stack of k Transformer decoder modules. The position encoding module adds position information to the preprocessed data and adds the obtained vector with position information to the vector of the preprocessed data. The specific expression is as follows:

[0183] X (pos,i) =X (pos,i) +PE (pos,i)

[0184]

[0185] Among them, X (pos,i) Represents the data at position (pos,i) in the preprocessed data;

[0186] The decoder module is composed of a masked multi-head attention layer, a layer normalization layer, a residual connection layer, a multi-head attention layer and a forward connection layer. The i-th pre-processed data X with position information processed by the position encoding module num,feats The output of the masked multi-head attention layer and the residual connection layer is input to the layer normalization layer, and the output of the layer normalization layer is combined with the output of the i-th stacked encoder module. After being input into the layer normalization layer through the multi-head attention layer and the residual connection layer, and then input into the layer normalization layer through the forward connection layer and the residual connection, the output data Y of the i-th decoder module is obtained. i .

[0187] The specific method of the aggregation processing in the aggregation module is as follows:

[0188] In the aggregation module, the k output data Y of the stacked decoder module are i To perform aggregation, the specific aggregation expression is as follows:

[0189]

[0190] The aggregated output data Y is passed through the forward connection layer and the Sigmoid activation function in sequence to obtain the final output O.

[0191] The specific method of abnormality judgment in the data judgment module is as follows:

[0192] The loss is calculated for the final output of the aggregation module and the preprocessed data through a loss function, where the loss function is a mean square error loss function. When the loss exceeds a threshold, the user data is considered abnormal data.

[0193] A computer-readable storage medium contains computer-executable instructions, and the computer-executable instructions are executed by a processor to implement a method for detecting abnormalities in user electricity consumption data.

[0194] A computer device comprising a processor;

[0195] The processor is used to store one or more programs;

[0196] When the one or more programs are executed by the processor, any method described in a method for detecting abnormalities in user power consumption data is implemented.

[0197] It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes. The schemes in the embodiments of the present invention may be implemented in various computer languages, for example, object-oriented programming language Java and literal scripting language JavaScript, etc.

[0198] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0199] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0200] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0201] Although the preferred embodiments of the present invention have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention.

[0202] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.

Claims

1. A method for detecting abnormality in user electricity consumption data, characterized in that: Specifically include the following: Collect daily user electricity consumption data within a certain period of time to form a data set; Preprocessing the data set, wherein the preprocessing includes filling processing and normalization processing; Windowing of preprocessed data; The obtained windowed data is input into the stacked encoder module for stacked encoding output processing; The obtained stack coding output data and pre-processed data are input into the stack decoder module for stack decoding output processing; The obtained stacked decoding output data is input into the aggregation module for aggregation processing; Through the loss function, the obtained converged processing output data and pre-processed data are used to calculate the loss and judge the abnormality of electricity consumption data.

2. A method for detecting abnormality in user power consumption data according to claim 1, characterized in that: The specific method of the window processing is as follows: Perform fast Fourier transform FFT on the preprocessed data X in the time dimension to obtain the corresponding frequency components in complex form; take the amplitude Amp of the frequency components in the time dimension to obtain the amplitude of each frequency component; take the average of the obtained amplitude data in the user number dimension to obtain the frequency amplitude pair sequence A that integrates multiple user data, and its specific expression is as follows: A=Avg(Amp(FFT(X))) Each frequency amplitude pair of sequence A consists of (f i , a i )(0 < i ≤ T), so it can be expressed as follows: <h2 style=";text-align:left;direction:ltr">A = {(f1,a1),(f2,a2),…,(f<h2 style=";text-align:left;direction:ltr"> T <h2 style=";text-align:left;direction:ltr"> ,a<h2 style=";text-align:left;direction:ltr"> T <h2 style=";text-align:left;direction:ltr"> )} Among them, f i represents the frequency, a i represents the corresponding amplitude, T represents the length of the frequency amplitude pair sequence A; Select the frequency-amplitude pairs containing the largest k amplitudes in A, and sort the k frequency-amplitude pairs in descending order according to the amplitude. The specific expression is as follows: in, The k most significant cycles are calculated by the amplitude pair sequence length T and the frequencies of the k frequency amplitude pairs in the sequence B. The specific expression of the cycle length is as follows: Among them, P i Indicates the period length of the corresponding significant period; Use a sliding window to create k pieces of windowed data for the preprocessed data. Each piece of windowed data corresponds to one period. In the i-th piece of windowed data, the size of the sliding window is P. i , using a sliding window, add the first P to each user's daily electricity consumption data i The electricity consumption data of a date is converted into the form of X num,feats Transform to windowed data The specific expression is as follows: Among them, x j Represents the user's electricity consumption data on the jth day.

3. A method for detecting abnormality in user power consumption data according to claim 1, characterized in that: The stacked encoder module is composed of a position encoding module and k stacked Transformer encoder modules. The Transformer encoder module corresponds to the k windowed data and the Transformer decoder module one by one. The position encoding module adds the position information of the sequence to the windowed data, and adds the obtained vector with the position information to the vector of the windowed data. The specific expression is as follows: Among them, j represents the window position generated on the original data position in the input data, pos,i represents the original data position in the input data, and d represents the dimension of the hidden layer. Indicates the jth window data whose original data position in the input data is (pos,i), PE (pos,2i) and PE (pos,2i+1) Respectively represent the position codes of the data at the original data position (pos, 2i) and the data at the position (pos, 2i+1) in the input data; Each encoder module in the k Transformer encoder modules consists of a multi-head attention layer, a layer normalization layer, a residual connection layer and a forward connection layer. The i-th windowed data with position information processed by the position encoding module The output of the layer normalization layer is input into the layer normalization layer through the multi-head attention layer and the residual connection layer in turn. The output of the layer normalization layer is then input into the layer normalization layer through the forward connection layer and the residual connection layer to obtain the output data of the i-th encoder module.

4. A method for detecting abnormality in user power consumption data according to claim 3, characterized in that: The stacked decoder module is composed of a position encoding module and a stack of k Transformer decoder modules. The position encoding module adds position information to the preprocessed data and adds the obtained vector with position information to the vector of the preprocessed data. The specific expression is as follows: X (pos,i) =X (pos,i) +PE (pos,i) Among them, X (pos,i) Represents the data at position (pos,i) in the preprocessed data; The decoder module is composed of a masked multi-head attention layer, a layer normalization layer, a residual connection layer, a multi-head attention layer and a forward connection layer. The i-th pre-processed data X with position information processed by the position encoding module num,feats The output of the masked multi-head attention layer and the residual connection layer is input to the layer normalization layer. The output of the layer normalization layer is then combined with the output of the i-th encoder module. After being input into the layer normalization layer through the multi-head attention layer and the residual connection layer, and then input into the layer normalization layer through the forward connection layer and the residual connection, the output data Y of the i-th decoder module is obtained. i .

5. The method for detecting abnormality in user power consumption data according to claim 1, characterized in that: The specific method of the aggregation processing is as follows: In the aggregation module, the k output data Y of the stacked decoder module are i To perform aggregation, the specific aggregation expression is as follows: The aggregated output data Y is passed through the forward connection layer and the Sigmoid activation function in sequence to obtain the final output O.

6. A method for detecting abnormality in user power consumption data according to claim 1, characterized in that: The specific method of abnormal judgment is as follows: The loss is calculated for the final output of the aggregation module and the preprocessed data through a loss function, where the loss function is a mean square error loss function. When the loss exceeds a threshold, the user data is considered abnormal data.

7. A device for detecting abnormality in user electricity consumption data, characterized in that: The detection device comprises: A data collection module is used to collect daily electricity consumption data of users within a certain period of time to form a data set; A data preprocessing module, used for preprocessing the data set, wherein the preprocessing includes padding processing and normalization processing; Window processing module, used for window processing of data sets; A stack coding module, used for inputting the obtained windowed data into a stack encoder module for stack coding output processing; A stack decoding module is used to input the obtained stack coding output data and pre-processed data into the stack decoder module for stack decoding output processing; The aggregation module is used to input the obtained stacked decoding output data into the aggregation module for aggregation processing; The data judgment module is used to calculate the loss of the obtained converged processing output data and the pre-processed data through the loss function, and judge the abnormality of the power consumption data.

8. A computer-readable storage medium, characterized in that: The storage medium contains computer executable instructions, and the computer executable instructions are executed by a processor to implement the methods of claims 1 to 6.

9. A computer device, characterized in that: including a processor; The processor is used to store one or more programs; When the one or more programs are executed by the processor, the method according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Self-attention sequence recommendation method fusing time sequence information

    CN114493755A

  • Unsupervised electricity larceny detection method based on deep twin autoregressive network

    CN117056874A

  • Inplanatable time series data anomaly detection method based on lightweight reconstruction network

    CN117668720A