Electricity stealing behavior detection method based on optimized GRU-LR model
By optimizing the GRU-LR model and logistic regression classifier, combining feature selection and deep learning training, the problems of high false alarm rate and insufficient accuracy in the power theft detection method are solved, and more efficient and accurate recognition of power theft behavior is achieved.
Patent Information
- Application Number
- CN202411498384.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-25
- Publication Date
- 2025-03-18
AI Technical Summary
The existing power theft detection methods have challenges in the case of high false alarm rate, insufficient accuracy and misjudgment of normal users, making it difficult to effectively identify power theft behavior.
The feature selection method is used to extract instantaneous active power and current as deep learning input indicators, combined with the gated cyclic unit (GRU) and the backpropagation neural network (BP), deep learning training is performed by optimizing the GRU-LR model, and finally, the logistic regression classifier is used to quickly identify power theft events.
It improves the accuracy and efficiency of power theft detection, reduces the false alarm rate, reduces the misjudgment of normal users, and enhances the detection ability of power theft behavior.
Smart Images

Figure CN119646598A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of power electronic control, and in particular to a method for detecting electricity theft based on an optimized GRU-LR model. Background Art
[0002] There is a problem of electricity theft in the power system, which not only damages the economic interests of power companies, but also creates unfair competition for normal users. Through in-depth analysis of user electricity usage behavior, the characteristics of electricity theft can be discovered, and corresponding detection models can be established to improve the recognition rate of electricity theft. This helps power companies take timely measures to ensure fair and just operation of the power system.
[0003] At present, the research methods of electricity theft mainly include game theory methods, hardware detection methods, data analysis methods and state estimation methods. Among these methods, data analysis methods have been widely used, especially the in-depth analysis of electricity data through neural network algorithms. This method has shown significant application potential in the detection and identification of electricity theft problems. This method can identify the subtle differences between normal and abnormal electricity usage patterns by learning a large amount of electricity usage data. In addition, by constructing feature engineering, extracting key features in electricity data, and combining machine learning algorithms, electricity theft can be effectively identified.
[0004] However, the electricity theft detection method still faces some challenges in practical applications, such as the diversity and concealment of electricity theft behaviors, as well as the similarity between normal electricity usage behaviors and electricity theft behaviors, which often leads to a high false alarm rate in electricity theft detection. How to reduce the false alarm rate and improve the accuracy of electricity theft detection through neural network algorithms, while reducing the misjudgment of normal users, still needs further research. Summary of the invention
[0005] In view of the shortcomings of the prior art, the present invention first adopts a feature selection method to extract instantaneous active power and current as input indicators for deep learning. Subsequently, a model combining a gated recurrent unit (GRU) and a back propagation neural network (BP) is established for deep learning training to improve accuracy. Finally, the trained model is used for electricity theft detection of users to further enhance the efficiency and accuracy of electricity theft detection. This method is a method for detecting electricity theft based on an optimized GRU-LR model that can be used by power companies to screen whether electricity users have stolen electricity.
[0006] A method for detecting electricity theft based on an optimized GRU-LR model includes the following steps:
[0007] Step 1: Data preprocessing: collectionUser electricity consumption data, including multiple characteristic values such as power consumption, instantaneous active power, instantaneous reactive power, voltage, current, power factor, etc. Data preprocessing, including data cleaning, processing missing values, standardization, etc., to ensure data quality and consistency;
[0008] Step 2: Feature selection: L1 regularization is used as the feature selection method. By sparsely processing the features in the data set, feature indicators with a high correlation with electricity theft events are found;
[0009] Step 3: Train the GRU model: Build a GRU deep learning model from the selected feature indicators. Use the Adam algorithm to train the model to learn the temporal information and potential patterns in the data;
[0010] Step 4: Logistic regression classification: Combined with the logistic regression classifier, the output of the GRU model is classified to achieve rapid identification of electricity theft events;
[0011] Step 5: Model evaluation: Through the above steps, we can finally get the evaluation indicators of the model and conduct a comprehensive evaluation of the model;
[0012] Step 6: Electricity theft detection: Use the trained model to detect electricity theft incidents by users.
[0013] As a preference, step 1 data preprocessing process:
[0014] Step 1: Missing value processing: due to data Time point not The missing values formed by the collected data were filled using the mean method, and the monthly mean method was introduced to fill the missing data at a specific time. When there are more than 3 missing points in a day, this distortion may have an adverse effect on the overall analysis, so the data of that day was removed from the data set;
[0015] Step 2: Standardization: In the data standardization process, the maximum and minimum normalization method is selected. The core idea of this method is to find the maximum and minimum values in the data set, and then use a simple formula to scale all values to the range of 0 to 1. The advantage of maximum and minimum normalization is that it retains the distribution of the original data and is suitable for situations where data needs to be mapped to a specific range. In the study, maximum and minimum normalization was selected to ensure the consistency and comparability of the data in subsequent analysis and modeling. The calculation formula for maximum and minimum normalization is:
[0016]
[0017] Among them: x represents the original data; x max and x min Represent the maximum and minimum values in the data set respectively;
[0018] As a preference, step 2 feature selection process:
[0019] In order to select feature indicators for multiple eigenvalues in the data set, L1 regularization is used to select feature indicators for all eigenvalues. L1 regularization is a technique for introducing sparsity in model training. In linear regression, L1 regularization is achieved by adding the sum of the absolute values of the coefficients to the loss function. For specific features, L1 regularization makes the coefficients of some of these features tend to zero, thereby excluding them from the final model. In L1 regularization, the loss function usually consists of two parts: the prediction error term and the regularization term. The total loss function can be expressed as:
[0020] J(θ)=L(θ)+λ·R(θ) (2)
[0021] Where: J(θ) is the total loss function; L(θ) is the prediction error term, which measures the difference between the model's prediction and the actual value; R(θ) is the regularization term, which is used to penalize the model parameters; λ is the regularization parameter, which is used to control the strength of the regularization term;
[0022] During the training process, the total loss function is minimized, which not only takes into account the accuracy of the fitted data, but also realizes the selection of features through the regularization term, which makes the model more sparse when selecting features. Due to the existence of the regularization term, the model is more inclined to select features that have a significant impact on the target variable during the learning process, and gives smaller weights to other unimportant features. Therefore, L1 regularization can be regarded as a feature selection method, which helps to screen out features that are relevant to the target prediction, while reducing irrelevant or redundant features;
[0023] As a preference, step 3 is to train the GRU model:
[0024] The GRU algorithm is a variant of a recurrent neural network used to process and learn sequence data. GRU introduces the concepts of update gate and reset gate, which regulate the flow of information and help the network selectively remember and forget information, so that it can better handle long-term dependencies in the sequence. GRU also has the advantage of a relatively simple structure, which can reduce training time and model complexity. Its mathematical expression is:
[0025]
[0026] Where: r t 、z t 、h t ′、h t Respectively represent the reset gate, update gate, candidate hidden state at the current moment, and hidden state at the current moment; σ is the sigmoid function; W r , Wz , W h are the corresponding weight matrices; [x t ,h t-1 ] is the hidden state h of the previous moment t-1 and the current input x t connected vectors; tanh is the hyperbolic tangent function; b r 、b z 、b h is the bias value of the input parameter;
[0027] The update gate of the GRU unit controls the degree of retention of the previous hidden state to the current information, while the reset gate determines the influence of the previous hidden state on the candidate hidden state at the current moment. In this way, GRU combines historical data with the input data at each moment through the gating mechanism, which helps to process dependencies in long sequences;
[0028] Select the Adam algorithm to train the GRU model. The Adam algorithm is a commonly used gradient descent algorithm that combines the characteristics of the momentum method and the adaptive learning rate. It can effectively update the model parameters and accelerate the convergence of the model. Use the Adam algorithm to update the parameters of the GRU model, including weight values and bias values. The correction formula is:
[0029]
[0030] Where: α is the learning rate; is the gradient of the loss function with respect to the model parameters; β1 and β2 are attenuation coefficients, usually close to 1; ε is a small value added for numerical stability. The loss function g uses the Mean Absolute Error (MAE);
[0031] As a preference, step 4 is the logistic regression classification process:
[0032] After using the Adam algorithm to train the GRU model, a classifier was introduced to map the output of the GRU model trained by the Adam algorithm to a binary classification result, i.e., electricity theft and non-electricity theft. The role of the classifier is to integrate the features learned by the GRU model and finally come to a judgment result;
[0033] The logistic regression classifier has the advantages of being simple and effective, and is particularly suitable for binary classification problems. The probability of the logistic regression output can be intuitively interpreted as the model's confidence in the electricity theft event. At the same time, the model structure is relatively simple, with fewer parameters, and is easy to train and understand. By introducing the logistic regression classifier, the overall model structure can be simplified, the interpretability of the model can be improved, and the complexity of the model can be reduced while maintaining good performance. The mathematical expression of logistic regression is as follows: Given an input feature vector X = (X1, X2, X3, ..., Xn ), the output y of logistic regression can be expressed as:
[0034]
[0035] Where: b is the intercept term, which means that when all input features X i The output when both are zero; w i It is feature X i The corresponding weights;
[0036] Logistic regression adapts to the training data by learning the values of these weights and intercepts and minimizing the loss function. The loss function is cross entropy loss, which is used to measure the difference between the model's predicted probability and the actual label. The expression of cross entropy loss is:
[0037]
[0038] Where: N is the number of samples; y i is the actual label (0 or 1); is the predicted probability of the model;
[0039] Logistic regression minimizes the loss function through optimization algorithms such as gradient descent to obtain the best weights and intercepts, so that the model's predictions on the training data are close to the actual labels. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] Figure 1 This is a flow chart of a method for detecting electricity theft based on an optimized GRU-LR model. DETAILED DESCRIPTION
[0041] The technical solutions in the embodiments of the present invention will be clearly and completely described below in combination with the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments.
[0042] Embodiment 1: A method for detecting electricity theft based on an optimized GRU-LR model, comprising the following steps:
[0043] Step 1: Data preprocessing: collection User electricity consumption data, including power consumption, instantaneous active power, instantaneous reactive power, voltage, current, and power factor characteristic values. Perform data preprocessing, including data cleaning, processing missing values, and standardization, to ensure data quality and consistency;
[0044] Step 2: Feature selection: L1 regularization is used as the feature selection method. By sparsely processing the features in the data set, feature indicators with a high correlation with electricity theft events are found;
[0045] Step 3: Train the GRU model: Build a GRU deep learning model from the selected feature indicators. Use the Adam algorithm to train the model to learn the temporal information and potential patterns in the data.
[0046] Step 4: Logistic regression classification: Combined with the logistic regression classifier, the output of the GRU model is classified to achieve rapid identification of electricity theft events;
[0047] Step 5: Model evaluation: Through the above steps, we can finally get the evaluation indicators of the model and conduct a comprehensive evaluation of the model;
[0048] Step 6: Power theft detection: Use the trained model to detect power theft incidents by users;
[0049] Specific steps:
[0050] (I) Data processing:
[0051] 1) Missing value processing: due to data Time point not The missing values formed by the collected data were filled using the mean method, and the monthly mean method was introduced to fill the missing data at a specific time. When there are more than 3 missing points in a day, this distortion may have an adverse effect on the overall analysis, so the data of that day was removed from the data set;
[0052] 2) Standardization: In the data standardization process, the maximum and minimum normalization method is selected. The core idea of this method is to find the maximum and minimum values in the data set, and then use a simple formula to scale all values to the range of 0 to 1. The advantage of maximum and minimum normalization is that it retains the distribution of the original data and is suitable for situations where data needs to be mapped to a specific range. In the study, maximum and minimum normalization was selected to ensure the consistency and comparability of the data in subsequent analysis and modeling. The calculation formula for maximum and minimum normalization is:
[0053]
[0054] Among them: x represents the original data; x max and x min Represents the maximum and minimum values in the data set respectively.
[0055] (II) Feature selection:
[0056] In order to select feature indicators for multiple eigenvalues in the data set, L1 regularization is used to select feature indicators for all eigenvalues. L1 regularization is a technique for introducing sparsity in model training. In linear regression, L1 regularization is achieved by adding the sum of the absolute values of the coefficients to the loss function. For specific features, L1 regularization makes the coefficients of some of these features tend to zero, thereby excluding them from the final model. In L1 regularization, the loss function usually consists of two parts: the prediction error term and the regularization term. The total loss function can be expressed as:
[0057] J(θ)=L(θ)+λ·R(θ) (8)
[0058] Where: J(θ) is the total loss function; L(θ) is the prediction error term, which measures the difference between the model's prediction and the actual value; R(θ) is the regularization term, which is used to penalize the model parameters; λ is the regularization parameter, which is used to control the strength of the regularization term;
[0059] During the training process, the total loss function is minimized, which not only takes into account the accuracy of the fitted data, but also realizes the selection of features through the regularization term, which makes the model more sparse when selecting features. Due to the existence of the regularization term, the model is more inclined to select features that have a significant impact on the target variable during the learning process, while giving smaller weights to other unimportant features. Therefore, L1 regularization can be regarded as a feature selection method, which helps to screen out features that are relevant to the target prediction while reducing irrelevant or redundant features.
[0060] (III) Establishment of Neural Network:
[0061] The GRU algorithm is a variant of a recurrent neural network used to process and learn sequence data. GRU introduces the concepts of update gate and reset gate, which regulate the flow of information and help the network selectively remember and forget information, so that it can better handle long-term dependencies in the sequence. GRU also has the advantage of a relatively simple structure, which can reduce training time and model complexity. Its mathematical expression is:
[0062]
[0063] Where: r t 、z t 、h t ′、h t Respectively represent the reset gate, update gate, candidate hidden state at the current moment, and hidden state at the current moment; σ is the sigmoid function; W r , W z , W h are the corresponding weight matrices; [xt ,h t-1 ] is the hidden state h of the previous moment t-1 and the current input x t connected vectors; tanh is the hyperbolic tangent function; b r 、b z 、b h is the bias value of the input parameter;
[0064] The update gate of the GRU unit controls the degree of retention of the previous hidden state to the current information, while the reset gate determines the influence of the previous hidden state on the candidate hidden state at the current moment. In this way, GRU combines historical data with the input data at each moment through the gating mechanism, which helps to process dependencies in long sequences;
[0065] Select the Adam algorithm to train the GRU model. The Adam algorithm is a commonly used gradient descent algorithm that combines the characteristics of the momentum method and the adaptive learning rate. It can effectively update the model parameters and accelerate the convergence of the model. Use the Adam algorithm to update the parameters of the GRU model, including weight values and bias values. The correction formula is:
[0066]
[0067] Where: α is the learning rate; is the gradient of the loss function with respect to the model parameters; β1 and β2 are attenuation coefficients, usually close to 1; ε is a small value added for numerical stability. The loss function g uses the Mean Absolute Error (MAE);
[0068] After using the Adam algorithm to train the GRU model, a classifier was introduced to map the output of the GRU model trained by the Adam algorithm to a binary classification result, i.e., electricity theft and non-electricity theft. The role of the classifier is to integrate the features learned by the GRU model and finally come to a judgment result;
[0069] The logistic regression classifier has the advantages of being simple and effective, and is particularly suitable for binary classification problems. The probability of the logistic regression output can be intuitively interpreted as the model's confidence in the electricity theft event. At the same time, the model structure is relatively simple, with fewer parameters, and is easy to train and understand. By introducing the logistic regression classifier, the overall model structure can be simplified, the interpretability of the model can be improved, and the complexity of the model can be reduced while maintaining good performance. Given an input feature vector X = (X1, X2, X3, ..., X n ), the output y of logistic regression can be expressed as:
[0070]
[0071] Where: b is the intercept term, which means that when all input features X i The output when both are zero; w i It is feature X i The corresponding weights;
[0072] Logistic regression adapts to the training data by learning the values of these weights and intercepts and minimizing the loss function. The loss function is cross entropy loss, which is used to measure the difference between the model's predicted probability and the actual label. The expression of cross entropy loss is:
[0073]
[0074] Where: N is the number of samples; y i is the actual label (0 or 1); is the predicted probability of the model;
[0075] Logistic regression minimizes the loss function through optimization algorithms such as gradient descent to obtain the best weights and intercepts, so that the model's predictions on the training data are close to the actual labels;
[0076] Finally, the GRU neural network optimized by the new algorithm is used to detect electricity theft to achieve more efficient and accurate identification of electricity theft.
Claims
1. A method for detecting electricity theft based on an optimized GRU-LR model, characterized in that: The following steps are involved: 1) Data preprocessing: collection User power consumption data, including power consumption, instantaneous active power, instantaneous reactive power, voltage, current, and power factor characteristic values , Perform data preprocessing, including data cleaning, handling missing values, and standardization to ensure data quality and consistency; 2) Feature selection: L1 regularization is used as the feature selection method. By sparsely processing the features in the data set, feature indicators with a high correlation with electricity theft events are found; 3) Training the GRU model: Building a GRU deep learning model from the selected feature indicators , The Adam algorithm is used for model training to learn the temporal information and potential patterns in the data; 4) Logistic regression classification: Combined with the logistic regression classifier, the output of the GRU model is classified to achieve rapid identification of electricity theft events; 5) Model evaluation: Through the above steps, the model evaluation indicators are finally obtained to comprehensively evaluate the model; 6) Electricity theft detection: Use the trained model to detect electricity theft incidents by users.
2. According to claim 1, a method for detecting electricity theft based on an optimized GRU-LR model is characterized in that: The specific method of data preprocessing is: 1) Missing value processing Due to data Time point not The missing values formed by the collected data are filled by the mean method, and the monthly mean method is introduced to fill the missing data at a specific time. , When there are more than 3 missing points in a day, this distortion may have an adverse effect on the overall analysis, so the data of that day is removed from the dataset. ; 2) Standardization In the data standardization process, choose the maximum and minimum normalization method , The core idea of this method is to find the maximum and minimum values in the data set and then use a simple formula to scale all values to the range of 0 to 1. , The advantage of maximum and minimum normalization is that it preserves the distribution of the original data and is suitable for situations where data needs to be mapped to a specific range. , In this study, the maximum and minimum normalization was chosen to ensure the consistency and comparability of the data in subsequent analysis and modeling. , The calculation formula for maximum and minimum normalization is: Among them: x represents the original data; x max and x min Represents the maximum and minimum values in the data set, respectively.
3. According to claim 2, a method for detecting electricity theft based on an optimized GRU-LR model is characterized in that: The specific method of feature selection is: In order to select characteristic indicators for multiple eigenvalues in the data set, L1 regularization is used to select characteristic indicators for all eigenvalues. , L1 regularization is a technique that introduces sparsity into model training. , In linear regression, L1 regularization is implemented by adding the sum of the absolute values of the coefficients in the loss function , For specific features, L1 regularization makes the coefficients of some of these features tend to zero, thus excluding them from the final model. , In L1 regularization, the loss function usually consists of two parts: the prediction error term and the regularization term , The total loss function can be expressed as: J(θ)=L(θ)+λ·R(θ)(2) Where: J(θ) is the total loss function; L(θ) is the prediction error term, which measures the difference between the model's prediction and the actual value; R(θ) is the regularization term, which is used to penalize the model parameters; λ is the regularization parameter, which is used to control the strength of the regularization term.
4. According to claim 3, a method for detecting electricity theft based on an optimized GRU-LR model is characterized in that: Said Training the GRU model, its mathematical expression is: Where: r t 、z t 、h t ′、h t Respectively represent the reset gate, update gate, candidate hidden state at the current moment, and hidden state at the current moment; σ is the sigmoid function; W r , W z , W h are the corresponding weight matrices; [x t ,h t-1 ] is the hidden state h of the previous moment t-1 and the current input x t connected vectors; tanh is the hyperbolic tangent function; b r 、b z 、b h is the bias value of the input parameter.
5. According to claim 4, a method for detecting electricity theft based on an optimized GRU-LR model is characterized in that: Select the Adam algorithm to train the GRU model ; Use the Adam algorithm to update the parameters of the GRU model, including the weight value W and the bias value b , The correction formula is: Where: α is the learning rate; is the gradient of the loss function with respect to the model parameters; β1 and β2 are decay coefficients, usually close to 1; ε is a small value added for numerical stability , In this study, the loss function g is the mean absolute error (MAE).
6. The method for detecting electricity theft based on an optimized GRU-LR model according to claim 5, characterized in that: Combined with the logistic regression classifier, the output of the GRU model is classified: Logistic regression learns these weights w i and the intercept b to fit the training data and minimize the loss function , The loss function selects the cross entropy loss to measure the difference between the model's predicted probability and the actual label. , The expression of cross entropy loss is: Where: N is the number of samples; y i is the actual label (0 or 1); is the predicted probability of the model.
7. The method for detecting electricity theft based on an optimized GRU-LR model according to claim 6, characterized in that: Logistic regression minimizes the loss function through optimization algorithms such as gradient descent to obtain the best weights and intercepts, so that the model's predictions on the training data are close to the actual labels.
8. The method for detecting electricity theft based on an optimized GRU-LR model according to claim 7, characterized in that: Obtain the evaluation indicators of the model and conduct a comprehensive evaluation of the model.