An instant anti-stealing electricity detection method
By using machine learning algorithms such as decision trees, CNN and LSTM in the business database for power acquisition, combined model training and progressive model prediction, the problem of poor accuracy and immediacy in the existing anti-power detection technology is solved, and a more efficient and accurate anti-power detection effect is achieved.
Patent Information
- Application Number
- CN202211483433.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-24
- Publication Date
- 2025-06-27
- Estimated Expiration
- 2042-11-24
AI Technical Summary
The existing anti-powered detection technology has poor accuracy and poor immediacy. It is difficult for a single rule or algorithm to fully abstract the relationship between power consumption characteristics and power consumption. Most algorithms fail to make full use of the timing characteristics of power consumption, resulting in data migration and calculation time-consuming, and often lead to losses being discovered only after they occur.
Three machine learning algorithms: decision tree, CNN neural network and LSTM are adopted to design custom functions in the business database of electricity and power acquisition, combine model training and progressive model prediction, and combine real-time and historical power consumption data to perform horizontal combination and vertical progress of multiple algorithms to improve the accuracy and immediacy of prediction results.
It realizes more accurate and faster anti-power detection, directly performs predictions in the database, avoids data migration, makes full use of the analytical performance of the new generation of databases, and improves the immediacy and coverage of results.
Smart Images

Figure CN115757468B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of power grids, and more specifically, to an instant anti-stealing electricity detection method. Background Art
[0002] Anti-stealing electricity detection has always been a difficult problem in practice. The means of stealing electricity are constantly improving. The traditional method mainly based on equipment inspection has two problems: one is that it is difficult to obtain evidence, and the other is that it is increasingly difficult to cope with and prevent. In recent years, with the implementation of power energy and electricity quantity collection systems by large state-owned power companies such as State Grid and China Southern Power Grid, based on the collected electronic data, data analysis and mining methods are used to analyze the electricity consumption of customers, and then on-site detection is carried out for abnormal customers with large fluctuations in electricity quantity. This information-based means based on big data has gradually shown obvious advantages.
[0003] Currently, the commonly used big data information-based means are mainly divided into two types or a combination of these two types. One is to set clear rules for detection and warning, such as the electricity consumption fluctuation exceeding a certain percentage; the other is to use the artificial intelligence method of machine learning, that is, taking the actual credit ratings of historical electricity customers as labels, and iteratively learning based on the historical electricity consumption feature dataset to obtain a prediction model. The commonly used method model algorithms include logistic regression, random forest, and multi-layer neural network, etc. Practice has proved that although these methods have achieved certain results, there are still many problems: one is poor accuracy. A single rule or algorithm is difficult to comprehensively abstract the relationship between electricity consumption characteristics and electricity stealing. How to select an algorithm suitable for the essential characteristics of electricity consumption has not been fully considered. At the same time, most algorithms treat the user characteristics and electricity consumption data at each moment as isolated records, and the strong time series characteristics of electricity consumption are mostly not used; the other is poor timeliness. Since data mining and analysis often need to be processed using dedicated tools or environments, and the data obtained by the power energy and electricity quantity collection system must first be stored in the database, data migration work is inevitably required, and real-time electricity consumption data cannot be used for analysis and mining. At the same time, the characteristic of machine learning algorithms is that the larger the amount of data, the more accurate it is. The migration and calculation of a large amount of historical data are very time-consuming, often resulting in being discovered only when a large loss occurs.
[0004] Therefore, it is of great practical significance to explore and study a more efficient, convenient and accurate anti-stealing electricity prediction method. Summary of the Invention
[0005] To make up for the above deficiencies, the present invention provides an instant anti-stealing electricity detection method, aiming to improve the problems of poor accuracy and poor timeliness of the existing anti-stealing electricity detection technology.
[0006] The present invention is implemented as follows: An instant anti-stealing electricity detection method includes the following steps:
[0007] Step 1: Design and implement decision trees in the business database for power and energy consumption data collection. Adopt three machine learning algorithms: CNN neural network and LSTM, and retain them in the form of database custom functions UDF, denoted as UDF_DT, UDF_CNN, and UDF_LSTM respectively;
[0008] Step 2: Select the relevant features of users' electricity consumption data and the actual credit ratings of users in the business database for power and energy consumption data collection as the model training data set;
[0009] Step 3: Train the combined model. Based on the real-time and historical electricity consumption data sets, train the model;
[0010] Step 4: Predict using the combined model: Use SQL statements to predict the user features to be predicted according to the time period by using the above three training models, and obtain the predicted electricity theft probabilities of users respectively;
[0011] Step 5: Elect the prediction results of the combined method: Elect the results of each predicted electricity-consuming user in each time period, that is, among the probabilities of the predicted users in each time period, the level with the most probability intervals falling within the corresponding probability intervals of credit ratings 0, 1, 2, and 3 is used as the predicted credit rating of the combined method for this user;
[0012] Step 6: Predict using the progressive method model: For the model obtained in Step 3, first use M_DT to predict the user features to be predicted, then according to P_DT, select and generate a new user feature set above the preset probability value Gate_DT, then use the model M_CNN to perform progressive prediction on D_FeatureTraining_DT, then according to P_CNN_DT, select and generate a new user feature set above the preset probability value Gate_CNN, then use the model M_LSTM to perform progressive prediction, and then use P_DT_CNN_LSTM to obtain the progressive prediction credit ratings of the relevant users of D_FeatureTraining_DT_CNN corresponding to values 0, 1, 2, and 3 in the 0, 1 interval;
[0013] Step 7: After removing duplicates from the user combinations with predicted results obtained by the above combined method and progressive method that are greater than or equal to the warning credit rating set by the system, send them to the business system for warning detection.
[0014] In a preferred technical solution of the present invention, in Step 2, for the three selected algorithms, use the decision tree to represent and extract the branch logic features commonly possessed by electricity theft, use the CNN convolutional neural network to extract the features of similar regular images that the user quantity data usually presents in multiple dimensions such as time, region, and energy efficiency level, and use LSTM to extract the predictable features of abnormal continuous curves that the electricity consumption data can form in the time series.
[0015] In a preferred technical solution of the present invention, in step 2, the user electricity consumption data-related features are "time, month, user energy efficiency level, address, gender, user organization, monthly electricity consumption, meter type, substation line loss, three-phase unbalance rate, unit consumption".
[0016] In a preferred technical solution of the present invention, in step 2, the user's actual credit rating is level four, where 0 represents a low electricity theft tendency, 1 represents medium, 2 represents high, and 3 represents high risk, which is divided according to the severity of historical actual electricity theft.
[0017] In a preferred technical solution of the present invention, in step 3, a combined method model training script is written in programmable SQL statements, that is, the data set is trained using UDF_DT, UDF_CNN, and UDF_LSTM respectively to obtain independent models M_DT, M_CNN, and M_LSTM. The pseudocode is as follows:
[0018] select into M_DT from(D_FeatureTraining, D_LabelTraining);
[0019] select into M_CNN from(D_FeatureTraining, D_LabelTraining);
[0020] select into M_LSTM from(D_FeatureTraining, D_LabelTraining).
[0021] In a preferred technical solution of the present invention, during training, the 0, 1, 2, and 3 in D_LabelTraining need to be converted into the original electricity theft probability, which can use the original probability data or be normalized between 0 and 1.
[0022] In a preferred technical solution of the present invention, in step 4, the obtained user predicted electricity theft probabilities are denoted as P_DT, P_CNN, and P_LSTM. The pseudocode is as follows:
[0023] select into P_DT from M_DT(D_FeatureTraining);
[0024] select into P_CNN from M_CNN(D_FeatureTraining);
[0025] select into P_LSTM from M_LSTM(D_FeatureTraining).
[0026] In a preferred technical solution of the present invention, the LSTM model first obtains the curve of power consumption and time series relationship, and then compares the actual power consumption with the predicted power consumption. The normalized probability conversion of the difference value beyond the range can be obtained by performing a 0-1 interval normalization.
[0027] The beneficial effects of the present invention are as follows:
[0028] 1. Convenient and easy to master: The entire prediction process is realized by writing a database programmable SQL script program.
[0029] 2. More accurate results: The script program composed of multiple SQLs combines multiple algorithms. The use of each algorithm fully considers its association with the characteristics of electricity consumption data. The results of various algorithms are averaged by the combination method and advanced by the recursive method respectively. Finally, the two schemes are combined to obtain relatively accurate results, and the time series characteristics of electricity consumption data are fully considered; the latest real-time business data can be directly used, further improving the accuracy of the results.
[0030] 3. Fast and efficient: The overall prediction is directly executed in the database without data volume migration; the various professional and mature optimization capabilities of the new generation database for analysis performance are fully utilized, avoiding self-implementation of optimization outside the database, achieving the goal of fast and efficient. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention, and therefore should not be regarded as limiting the scope. For those of ordinary skill in the art, other related drawings can be obtained based on these drawings without creative efforts.
[0032] Figure 1 is the instant precise anti-theft electricity detection flow chart provided by the embodiment of the present invention;
[0033] Figure 2 is the instant precise anti-theft electricity detection flow block diagram provided by the embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0034] In order to make the objectives, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all of the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts fall within the scope of protection of the present invention.
[0035] Embodiment
[0036] Please refer to Figure 1 , the present invention provides a technical solution: an instant anti-stealing electricity detection method, including the following steps:
[0037] Step 1: Design and implement decision trees in the business database for collecting electric energy and electricity respectively. The present invention uses C4.5, CNN neural network, and the present invention uses LeNet5, LSTM, three machine learning algorithms, which are retained in the form of database user-defined functions UDF, and are respectively denoted as UDF_DT, UDF_CNN, UDF_LSTM;
[0038] It should be noted that the present invention selects these three algorithms. The decision tree is used to represent the branch logic features commonly possessed by electricity stealing (for example, the tendency of electricity stealing in high-class residential areas is generally lower than that in low-class communities, females are generally lower than males, and large-scale enterprises are generally lower than self-employed individuals, etc.). The CNN convolutional neural network is used to extract the features of similar regular images that user quantity data usually presents in multiple dimensions such as time, region, energy efficiency level, etc. The LSTM is used to extract the predictable features of abnormal continuous curves that electricity consumption data can form in time series (similar to the time series prediction features of stock prices);
[0039] Step 2: Select the relevant features of user electricity consumption data in the business database for collecting electric energy and electricity. The present invention adopts "time, month, user energy efficiency level, address, gender, user organization, monthly electricity consumption, electricity meter type, substation line loss, three-phase unbalance rate, unit consumption", etc., and the actual credit rating of users. The present invention is divided into four levels, 0 represents low electricity stealing tendency, 1 represents medium level, 2 represents high level, 3 represents high risk, which is divided according to the severity of actual electricity stealing that has occurred in history, as the model training data set;
[0040] Step 3: Combined method model training: Based on real-time and historical electricity consumption data sets (the historical span can be customized), which can be denoted as (D_FeatureTraining, D_LabelTraining); write a combined method model training script with programmable SQL statements, that is, use UDF_DT, UDF_CNN, UDF_LSTM to train the data set respectively, and obtain independent models M_DT, M_CNN, M_LSTM respectively. The pseudo-code is:
[0041] select into M_DT from(D_FeatureTraining, D_LabelTraining);
[0042] select into M_CNN from(D_FeatureTraining, D_LabelTraining);
[0043] SELECT INTO M_LSTM FROM (D_FeatureTraining, D_LabelTraining);
[0044] It should be noted that during training, the 0, 1, 2, and 3 in D_LabelTraining need to be converted into the original electricity theft probability, which can use the original probability data or be normalized between (0, 1).
[0045] Step 4: Prediction of the combined model: Using SQL statements, according to time periods, the above three training models are used to predict the user features to be predicted, and the user predicted electricity theft probabilities P_DT, P_CNN, and P_LSTM are obtained respectively. The pseudocode is as follows:
[0046] SELECT INTO P_DT FROM M_DT(D_FeatureTraining);
[0047] SELECT INTO P_CNN FROM M_CNN(D_FeatureTraining);
[0048] SELECT INTO P_LSTM FROM M_LSTM(D_FeatureTraining);
[0049] It should be noted that the LSTM model first obtains the curve of the relationship between electricity consumption and time series, and then compares the actual electricity consumption with the predicted electricity consumption. The probability conversion of the difference value exceeding the range is normalized in the interval (0, 1) to obtain
[0050] Step 5: Election of the prediction results of the combined method: For each time period, the results of P_DT, P_CNN, and P_LSTM of each predicted electricity user are elected. That is, among the probabilities of P_DT, P_CNN, and P_LSTM of the predicted users in each time period, the level with the most probability intervals corresponding to the credit levels (0, 1, 2, 3) is used as the combined method prediction credit level of the user;
[0051] Step 6: Prediction of the progressive model: For the model obtained in Step 3, first use M_DT to predict the user features to be predicted, that is:
[0052] SELECT INTO P_DT FROM M_DT(D_FeatureTraining);
[0053] Then, according to P_DT, a new user feature set above the preset probability value Gate_DT is selected, that is:
[0054] SELECT INTO (D_FeatureTraining_DT) FROM (D_FeatureTraining) WHERE P_DT >= Gate_DT;
[0055] Then, use the model M_CNN to perform progressive prediction on (D_FeatureTraining_DT), that is:
[0056] SELECT INTO P_CNN_DT FROM M_CNN(D_FeatureTraining_DT);
[0057] Then, based on P_CNN_DT, select and generate a new user feature set above the preset probability value Gate_CNN, that is:
[0058] SELECT INTO (D_FeatureTraining_DT_CNN) FROM (D_FeatureTraining_DT) WHERE P_CNN_DT >= Gate_CNN;
[0059] Then, use the model M_LSTM to perform progressive prediction on (D_FeatureTraining_DT_CNN), that is:
[0060] SELECT INTO P_DT_CNN_LSTM FROM M_LSTM(D_FeatureTraining_DT_CNN);
[0061] Then, use P_DT_CNN_LSTM to obtain the progressive prediction credit rating of the users related to D_FeatureTraining_DT_CNN corresponding to the values (0, 1, 2, 3) in the (0, 1) interval.
[0062] Step 7: After removing duplicates from the user combinations with prediction results obtained by the above combination method and progressive method that are greater than or equal to the warning credit rating set by the system, send them to the business system for warning detection.
[0063] The method designed by the present invention has the following advantages compared with the prior art:
[0064] Directly use real-time data and historical data in the business database for prediction, which can immediately utilize all business data and greatly improve the timeliness of the prediction results;
[0065] Directly use programmable SQL scripts to implement prediction, which is simple and easy to use, has a low threshold, and does not require the participation of professionals in machine learning;
[0066] Execute the prediction process directly in the business database. First, it is convenient to utilize all historical big data. Second, it can greatly improve the efficiency by leveraging the extreme big data analysis performance of high-end MPP databases, further enhancing the immediacy.
[0067] Adopt a horizontal combination of multiple prediction algorithms. Each algorithm reflects a special correlation between user characteristics and the tendency of electricity theft, thus obtaining the horizontal fusion result of various correlation relationships and improving the accuracy.
[0068] Adopt a progressive combination of multiple prediction algorithms and perform progressive prediction based on the results of the previous algorithm, thus accurately reflecting the vertical fusion result of various correlation relationships and further improving the accuracy.
[0069] Combine the horizontal and vertical prediction results through set combination, maximizing the coverage rate of the prediction results to support the discovery of potential electricity theft users with the greatest possibility.
[0070] It is found through experiments that the invented method is fast, accurate, and convenient, and it is an innovative approach that can be promoted and refined in practice.
[0071] The above is only the preferred embodiment of the present invention and is not used to limit the present invention. For those skilled in the art, the present invention can have various changes and modifications. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. An instant anti-stealing electricity detection method, characterized in that, It includes the following steps: Step 1: Design and implement three machine learning algorithms, namely decision tree, CNN neural network, and LSTM, in the business database for power and electricity consumption data collection, and retain them in the form of database user-defined functions (UDFs), denoted as UDF_DT, UDF_CNN, and UDF_LSTM respectively; Step 2: Select the relevant features of user electricity consumption data and the actual credit ratings of users in the business database for power and electricity consumption data collection as the model training data set; Step 3: Train the combined model based on the real-time and historical electricity consumption data sets; Step 4: Predict using the combined model: Use SQL statements to predict the user features to be predicted according to time periods using the three trained models, and obtain the predicted electricity theft probabilities of users respectively; Step 5: Elect the prediction results of the combined method: Elect the results of each predicted electricity consumption user in each time period, that is, among the probabilities of the predicted users in each time period, the grade with the most probability intervals falling within the corresponding probability intervals of credit grades 0, 1, 2, and 3 is used as the predicted credit grade of the combined method for this user; Step 6: Predict using the progressive method: For the model obtained in Step 3, first use M_DT to predict the user features to be predicted, then according to P_DT, select and generate a new set of user features above the preset probability value Gate_DT, then use the model M_CNN to perform progressive prediction on D_FeatureTraining_DT, then according to P_CNN_DT, select and generate a new set of user features above the preset probability value Gate_CNN, then use the model M_LSTM to perform progressive prediction, and then use P_DT_CNN_LSTM to obtain the progressive prediction credit grades of the relevant users of D_FeatureTraining_DT_CNN corresponding to values 0, 1, 2, and 3 in the 0-1 interval. Among them, M_DT is the decision tree model, P_DT is the electricity theft probability output by the M_DT model, Gate_DT is the decision tree probability threshold, M_CNN is the model trained based on the CNN algorithm, P_CNN_DT is the prediction result of M_CNN on the D_FeatureTraining_DT data set, representing the electricity theft probability, Gate_CNN is the preset probability threshold, M_LSTM is the model trained based on the LSTM algorithm, P_DT_CNN_LSTM is the prediction result of M_LSTM on the D_FeatureTraining_DT_CNN data set, D_FeatureTraining_DT is the data of high-risk users identified by the model, and D_FeatureTraining_DT_CNN is the filtered data of high-risk users; Step 7: After removing duplicates from the user combinations with predicted results obtained by the above combined method and progressive method that are greater than or equal to the warning credit grade set by the system, send them to the business system for warning detection.
2. The instant anti-stealing electricity detection method according to claim 1, wherein In step 2, for the three selected algorithms, a decision tree is used to represent and extract the branch logic features commonly possessed by electricity theft, a CNN (Convolutional Neural Network) is used to extract the features of the regular images presented by the user quantity data in three dimensions: time, region, and energy efficiency level, and an LSTM (Long Short-Term Memory) is used to extract the abnormal prediction features of the continuous curve formed by the electricity consumption data in time series.
3. The instant anti-stealing electricity detection method according to claim 1, characterized in that In step 2, the features related to the user's electricity consumption data include time, month, user energy efficiency level, address, gender, user organization, monthly electricity consumption, meter type, substation line loss, three-phase unbalance rate, and specific energy consumption.
4. The instant anti-stealing electricity detection method according to claim 1, wherein In step 2, the actual credit rating of the user is level 4. 0 represents a low electricity theft tendency, 1 represents medium, 2 represents high, and 3 represents high risk, which is divided according to the severity of the actual electricity theft that has occurred in history.
5. The instant anti-stealing electricity detection method according to claim 1, wherein In step 3, a combined method model training script is written in programmable SQL statements, that is, UDF_DT, UDF_CNN, and UDF_LSTM are used to train the data set respectively to obtain independent models M_DT, M_CNN, and M_LSTM. The pseudocode is as follows: select into M_DT from (D_FeatureTraining,D_LabelTraining); select into M_CNN from (D_FeatureTraining,D_LabelTraining); select into M_LSTM from (D_FeatureTraining,D_LabelTraining)。 6. The instant anti-stealing electricity detection method according to claim 5, wherein, During training, the 0, 1, 2, and 3 in D_LabelTraining need to be converted into the original electricity theft probability, and the original electricity theft probability is normalized between 0 and 1 using the original probability data.
7. The instant anti-stealing electricity detection method according to claim 1, wherein In step 4, the predicted electricity theft probabilities of the users obtained are denoted as P_DT, P_CNN, and P_LSTM. The pseudocode is as follows: select into P_DT from M_DT(D_FeatureTraining); select into P_CNN from M_CNN(D_FeatureTraining); select into P_LSTM from M_LSTM(D_FeatureTraining)。 8. The instant anti-stealing electricity detection method according to claim 7, wherein The LSTM model first obtains the curve of the relationship between electricity consumption and time series, and then compares the actual electricity consumption with the predicted electricity consumption, and performs a 0-1 interval normalization probability conversion on the difference value that exceeds the threshold.
Citation Information
Patent Citations
Electricity larceny prevention analysis method based on typical industry feature library and electricity larceny prevention sample library
CN110223196A
Detection of anomalies in an electrical network
US20210325441A1