Electricity stealing behavior detection method, system, terminal equipment and storage medium

文档序号:8806 发布日期:2021-09-17 浏览:42次 中文

1. A method for detecting electricity stealing behavior, comprising:

carrying out data cleaning on the original data set to obtain a training sample;

inputting the training sample into a convolutional neural network model to obtain a training result;

evaluating the current training result by using the evaluation index, if the current training result does not meet the preset condition, adjusting the weight ratio of the training sample, and training the convolutional neural network model by using the adjusted sample until the training result meets the preset condition to obtain an optimized convolutional neural network model;

combining the optimized convolutional neural network models according to a preset weight ratio to obtain a target detection model; and detecting the electricity stealing behavior of the user by utilizing the target detection model.

2. The method according to claim 1, wherein the data cleansing includes operations of removing duplicate values, complementing missing values, and deleting erroneous values.

3. The method according to claim 1 or 2, wherein the adjusting the weight ratio of the training samples comprises:

according to the training result, the sample weight with wrong classification is increased to a first preset value, and the sample weight with correct classification is reduced to a second preset value.

4. The electricity stealing behavior detection method according to claim 3, wherein the evaluation indexes include overall accuracy, prediction recall, and F1 value.

5. A system for detecting electricity stealing behavior, comprising:

the data cleaning unit is used for cleaning data of the original data set to obtain a training sample;

the first training unit is used for inputting the training samples into a convolutional neural network model to obtain a training result;

the second training unit is used for evaluating the current training result by utilizing the evaluation index, adjusting the weight ratio of the training sample if the current training result does not meet the preset condition, and training the convolutional neural network model by utilizing the adjusted sample until the training result meets the preset condition to obtain an optimized convolutional neural network model;

the detection unit is used for combining the optimized convolutional neural network models according to a preset weight ratio to obtain a target detection model; and detecting the electricity stealing behavior of the user by utilizing the target detection model.

6. The electrical theft behavior detection system of claim 5, wherein the data cleansing includes a remove duplicate value, a complement missing value, and a delete false value operation.

7. The electricity stealing behavior detection system according to claim 5 or 6, wherein the second training unit is further configured to:

according to the training result, the sample weight with wrong classification is increased to a first preset value, and the sample weight with correct classification is reduced to a second preset value.

8. The electrical larceny behavior detection system of claim 7, wherein the evaluation metrics include overall accuracy, prediction recall, and F1 values.

9. A terminal device, comprising: a processor, a memory and a computer program stored in the memory and configured to be executed by the processor, the processor implementing the method of electricity stealing behavior detection according to any one of claims 1 to 4 when executing the computer program.

10. A computer-readable storage medium, on which a computer program is stored, the computer program being executed by a processor to implement the electricity stealing behavior detection method according to any one of claims 1 to 4.

Background

The electricity stealing behavior refers to the behavior that the electricity consumption measured by an electricity meter is lower than the actual electricity consumption by a user through illegal means, and the behavior is helpful for the user to pay less electricity fee. Generally, users steal electricity by modifying electric energy meters, reconnecting transmission lines and the like, but the operations have the high possibility of causing phenomena of electrical equipment failure and line short circuit, and even causing casualties in severe cases. Obviously, the behavior of electricity stealing has brought great potential safety hazard to the normal operation of the power system.

At present, a detection method for electricity stealing of an electric power enterprise mainly depends on manual investigation, and is low in efficiency and high in cost. Although, power supply companies also try to prevent fraudulent activity by installing hardware. However, the additional hardware is expensive and takes up some space; and because these hardware sources are from different producers, do not have a unified installation method, further can increase the monitoring degree of difficulty. In addition, once some power data are missing during monitoring, whether the electricity stealing behavior exists in the user cannot be accurately and effectively judged.

Disclosure of Invention

The invention aims to provide a method, a system, a terminal device and a storage medium for detecting electricity stealing behavior, so as to solve the technical problems of high cost, strong limitation and incapability of guaranteeing accuracy in the existing method for detecting electricity stealing behavior.

In order to overcome the defects in the prior art, the invention provides a method for detecting electricity stealing behavior, which comprises the following steps:

carrying out data cleaning on the original data set to obtain a training sample;

inputting the training sample into a convolutional neural network model to obtain a training result;

evaluating the current training result by using the evaluation index, if the current training result does not meet the preset condition, adjusting the weight ratio of the training sample, and training the convolutional neural network model by using the adjusted sample until the training result meets the preset condition to obtain an optimized convolutional neural network model;

combining the optimized convolutional neural network models according to a preset weight ratio to obtain a target detection model; and detecting the electricity stealing behavior of the user by utilizing the target detection model.

Further, the data cleaning includes operations of removing duplicate values, filling missing values, and deleting erroneous values.

Further, the adjusting the weight ratio of the training samples includes:

according to the training result, the sample weight with wrong classification is increased to a first preset value, and the sample weight with correct classification is reduced to a second preset value.

Further, the evaluation indexes comprise overall accuracy, prediction recall and F1 values.

The invention also provides a system for detecting electricity stealing behavior, which comprises:

the data cleaning unit is used for cleaning data of the original data set to obtain a training sample;

the first training unit is used for inputting the training samples into a convolutional neural network model to obtain a training result;

the second training unit is used for evaluating the current training result by utilizing the evaluation index, adjusting the weight ratio of the training sample if the current training result does not meet the preset condition, and training the convolutional neural network model by utilizing the adjusted sample until the training result meets the preset condition to obtain an optimized convolutional neural network model;

the detection unit is used for combining the optimized convolutional neural network models according to a preset weight ratio to obtain a target detection model; and detecting the electricity stealing behavior of the user by utilizing the target detection model.

Further, the data cleaning includes operations of removing duplicate values, filling missing values, and deleting erroneous values.

Further, the second training unit is further configured to:

according to the training result, the sample weight with wrong classification is increased to a first preset value, and the sample weight with correct classification is reduced to a second preset value.

Further, the evaluation indexes comprise overall accuracy, prediction recall and F1 values.

The present invention also provides a terminal device, including: a processor, a memory and a computer program stored in the memory and configured to be executed by the processor, the processor implementing the method of electricity stealing behavior detection as claimed in any one of the above when executing the computer program.

The present invention also provides a computer-readable storage medium having stored thereon a computer program for execution by a processor to implement the method of electricity stealing behavior detection as described in any one of the above.

Compared with the prior art, the invention has the beneficial effects that:

the invention discloses a method for detecting electricity stealing behavior, which comprises the steps of carrying out data cleaning on an original data set to obtain a training sample; inputting the training sample into a convolutional neural network model to obtain a training result; evaluating the current training result by using the evaluation index, if the current training result does not meet the preset condition, adjusting the weight ratio of the training samples, and training the convolutional neural network model by using the adjusted samples until the training result meets the preset condition to obtain an optimized convolutional neural network model; combining the optimized convolutional neural network models according to a preset weight ratio to obtain a target detection model; and detecting the electricity stealing behavior of the user by utilizing the model.

The invention has high detection precision, can judge the electricity stealing behavior of the user according to the metering data of the ammeter under the condition of the loss of the topological structure or network parameters of the power network, and has the advantages of strong applicability, low cost and high accuracy.

Drawings

In order to more clearly illustrate the technical solution of the present invention, the drawings needed to be used in the embodiments will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art that other drawings can be obtained according to the drawings without creative efforts.

FIG. 1 is a schematic flow chart of a method for detecting electricity stealing behavior according to an embodiment of the present invention;

FIG. 2 is a schematic structural diagram of a system for detecting electricity stealing behavior according to an embodiment of the present invention;

fig. 3 is a schematic structural diagram of a terminal device according to an embodiment of the present invention.

Detailed Description

The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.

It should be understood that the step numbers used herein are for convenience of description only and are not used as limitations on the order in which the steps are performed.

It is to be understood that the terminology used in the description of the invention herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. As used in the specification of the present invention and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.

The terms "comprises" and "comprising" indicate the presence of the described features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.

The term "and/or" refers to and includes any and all possible combinations of one or more of the associated listed items.

In a first aspect:

referring to fig. 1, an embodiment of the present invention provides a method for detecting electricity stealing behavior, including:

and S10, performing data cleaning on the original data set to obtain a training sample.

It will be appreciated that there is much noise interference to the acquired raw data set, if not pre-processed, thereby affecting the accuracy of the training results. Therefore, the data cleaning is mainly carried out on the original data set in the step, and the training sample with higher quality is obtained.

In one embodiment, the main steps of data cleansing include: and operations of removing duplicate values, filling missing values and deleting error values.

And S20, inputting the training sample into a convolutional neural network model to obtain a training result.

In this step, training of samples is mainly performed, and the adopted model is a convolutional neural network model.

It should be noted that the convolutional neural network can directly extract important features from the electricity consumption data, and meanwhile, the weight sharing and the local connection of the convolutional neural network improve the accuracy of electricity stealing detection and reduce the complexity of the electricity stealing detection. Specifically, the convolutional neural network is composed of an input layer, a convolutional layer, a pooling layer, a full-link layer, and an output layer. The electricity consumption data is divided into electricity stealing users and normal users after passing through the convolutional neural network. The structure of the basic convolutional neural network model will be described in detail below:

2.1) input layer:

in the training sample, the power usage data is represented primarily by a two-dimensional matrix.

2.2) convolutional layer:

the convolution layer is composed of d convolution kernels, these convolution kernels extract important features from the electricity consumption data, the size of the electricity consumption data is a × b, the size of the convolution kernels is c × c, after the convolution operation, the input data becomes d feature maps, the size of which is:

in the formula, stride refers to the step size of the convolution operation, a refers to the date, and b refers to the number of electricity consumption data recorded by the smart meter.

2.3) a pooling layer:

it should be noted that the pooling layer resamples the feature map and retains the most important information. The pooling method includes average pooling, maximum pooling, and random pooling. The calculation is typically performed using average pooling and maximum pooling. The key features are extracted by calculating the mean or maximum of the feature map. In this example, maximum pooling is used, the size of the pooling layer is e × f, and the output of the pooling layer is:

2.4) full connection layer:

the full link layer links together the outputs of the d pooling layers, and its size is:

it will then be sent to a classification function. The classification is usually done in the fully connected layer using the SoftMax function. The output of SoftMax is 0 or 1. Here, 0 denotes a normal user and 1 denotes a power stealing user.

2.5) output layer:

it can be understood that the output layer is used for outputting the classification result of the SoftMax function.

In this embodiment, in order to achieve both the training speed and the accuracy of the result, the convolutional neural network model includes 2 convolutional layers and 2 pooling layers. The size of the first convolution layer is 3 × 32, the size of the second convolution layer is 3 × 64, the size of the first convolution layer is 1 × 2, the size of the second convolution layer is 17 × 3, the maximum number of iterations is set to 500, and the learning rate is set to 0.01.

And S30, evaluating the current training result by using the evaluation index, if the current training result does not meet the preset condition, adjusting the weight ratio of the training sample, and training the convolutional neural network model by using the adjusted sample until the training result meets the preset condition to obtain the optimized convolutional neural network model.

In the step, the result of iterative training is mainly evaluated to ensure that the training result meets the preset condition, so that the optimized convolutional neural network model can be obtained.

In one embodiment, the evaluation metrics include overall accuracy, prediction recall, and F1 values. When the data weight adjustment and the iterative training in the training sample are carried out for 500 times, the obtained optimized convolutional neural network model is more ideal than other modes.

Specifically, the convolutional neural network model in the present embodiment is a two-classification model that classifies all users into normal users and electricity stealing users, where emphasis is placed on the interest of electricity stealing users. Thus, the electricity stealing users are marked as 1 and the normal users are marked as 0. The confusion matrix obtained in the training result is shown in the following table:

TABLE 1 confusion matrix in electricity stealing detection model

As can be seen from table 1, the confusion matrix gives four values: TP, TN, FP and FN. The TP indication actually indicates a power theft and the prediction result also indicates a power theft, which indicates that the power-stealing user is seized. TN is in fact a normal user and the prediction also indicates that it is normal. FP indicates that it is actually a normal user, but the model prediction is wrong and power stealing. The FN is actually a power stealing subscriber and the prediction indicates that it is a normal subscriber. The accuracy, precision, recall and F1 values were calculated using the four values TP, TN, FP and FN.

Specifically, the following explanation is made for several indexes:

3.1) Accuracy (AR) is the ratio of electricity stealing users to normal users of a model classification pair, and is the most intuitive and common criterion for measuring the effectiveness of a model classification. The formula is as follows:

3.2) Precision Ratio (PR) is the number of samples that the model judges to be positive and actually positive, and is a proportion of the samples that the model judges to be positive. The formula is as follows:

3.3) recall (RR) indicates that the samples that the model determines to be positive account for all samples that are actually positive. The formula is as follows:

and 3.4) F value is a comprehensive index of the classification effect and is a uniform average value of accuracy and recall rate. The formula is as follows:

when the parameter α is 1, the most representative F1 value can be obtained, and the formula is as follows:

it can be seen that the F1 value is the result of the combination of the accuracy and the recall ratio, which fully reflects the classification level of the model, and the larger the F1 value is, the better the classification effect of the model is.

In one embodiment, the training result is determined not to satisfy the predetermined condition according to the evaluation index, so that the sample weight of the misclassification is increased to a first predetermined value and the sample weight of the correct classification is decreased to a second predetermined value according to the training result.

Specifically, let the original dataset be D and the weak classifier be f (·). In the training process, the weight of each sample is changed according to the training result, some normal users are classified as electricity stealing users, some electricity stealing users are classified as normal users, the weight of the misclassified sample is adjusted to be larger, and the weight of the correctly classified sample is adjusted to be smaller. The next classifier will be trained according to the adjusted data set, that is, the next classifier will focus more on the misclassified samples, and this iterative training process will not stop until the preset condition is reached. Where each convolutional neural network f (-) has its own weight α.

Further, in this embodiment, the number of times of training is m, and the training data set is:

in the formula, n is the number of samples,data of electricity consumption for the i-th user, yiThe binary tag data of the ith user, 0 represents a normal user, and 1 represents a power stealing user.

Further, when the number of training times is k, the weight of the sample is:

it should be noted that, in this embodiment, each weak classifier (convolutional neural network) has its own weight α, where α is based on ∈kCalculated, defined as follows:

if the ith sample is correctly classified by the kth classifier, the weight adjustment for the ith sample is changed:

if the classification is wrong, the weight of the ith sample is changed to:

therefore, by continuously adjusting the weights of the training samples, the classifier can be made to pay more attention to the samples which are classified incorrectly. Wherein the preset condition is that the training is stopped when the iteration number reaches 500 times.

S40, combining the optimized convolutional neural network models according to a preset weight ratio to obtain a target detection model; and detecting the electricity stealing behavior of the user by utilizing the target detection model.

It should be noted that each convolutional neural network has its own weight, and in this step, the trained convolutional neural network models are combined according to a certain weight to synthesize a model for finally detecting electricity stealing. That is, k weak classifiers (convolutional neural networks) are combined into one strong classifier according to the own weight, and are expressed as:

where F (-) is a strong classifier and F (-) is a weak classifier.

The electricity stealing behavior detection method provided by the embodiment of the invention has high detection precision, can judge the electricity stealing behavior of the user according to the metering data of the ammeter under the condition of loss of the topological structure or network parameters of the power network, and has the advantages of strong applicability, low cost and high accuracy.

In a second aspect:

in order to illustrate the effect of the invention, in a certain embodiment, a data set of Ireland is used as an original data set, a simulation test is performed by using the method provided by the invention, and the simulation result is compared with other methods.

Specifically, the Ireland dataset contains 810 normal residents and 270 electricity stealing users. Therefore, in the sample data of Ireland, there are 810 normal resident samples and 270 electricity stealing samples, and the ratio is 3: 1. Data of 21 continuous days of each user are taken as samples, and 48 characteristic values are obtained every day (the power consumption is collected every half hour by an Ireland power consumption information collection system).

Simulation tests using the method of the invention will now be performed using the Ireland dataset. The irish dataset was as per 7: the scale of 3 is divided into a training set, which is used to train and correct the model, and a test set, which is used to evaluate the model. The method provided by the invention is respectively compared with a decision tree, a logistic regression method, a convolutional neural network (three independent methods), a self-adaptive enhancement method based on the decision tree and a self-adaptive enhancement method based on the logistic regression (two synthetic methods), and the comparison result is shown in table 2:

TABLE 2 comparison of the predicted results of electricity stealing behavior of the present invention with three other independent methods

As can be seen from table 2, the electricity stealing behavior detection method provided by the invention is excellent in the overall accuracy, the prediction recall rate and the F1 value, and is higher than the other three comparison methods. It can be seen that the four indexes of the convolutional neural network are also obviously superior to those of the decision tree and the logistic regression, but the independent method of the convolutional neural network has slightly inferior effect to that of the present invention.

In this embodiment, the effect of the present invention is also combined with other two synthesis methods: the adaptive enhancement method based on the decision tree and the adaptive enhancement method based on the logistic regression are compared, and the comparison result is shown in table 3:

TABLE 3 comparison of the predicted results of electricity stealing behavior of the present invention with two other synthetic methods

The results in table 3 show that, in comparison of the synthesis methods, the electricity stealing behavior detection method provided by the invention is obviously superior to the other two synthesis methods in the four indexes of the overall accuracy, the prediction recall rate and the F1 value, and the accuracy of electricity stealing detection is also improved after the decision tree, the logistic regression and the self-adaptive enhancement synthesis.

In summary, whether compared with an independent electricity stealing detection algorithm or a synthesized electricity stealing detection algorithm, the electricity stealing behavior detection method provided by the invention has more excellent performance and has the highest value in the four index evaluations of accuracy, precision, recall rate and F1 value.

In a third aspect:

referring to fig. 2, an embodiment of the present invention further provides a system for detecting electricity stealing behavior, including:

the data cleaning unit 01 is used for cleaning data of the original data set to obtain a training sample;

the first training unit 02 is used for inputting the training samples into a convolutional neural network model to obtain a training result;

the second training unit 03 is configured to evaluate a current training result by using the evaluation index, adjust a weight ratio of the training sample if the current training result does not satisfy a preset condition, and train the convolutional neural network model by using the adjusted sample until the training result satisfies the preset condition, so as to obtain an optimized convolutional neural network model;

the detection unit 04 is used for combining the optimized convolutional neural network models according to a preset weight ratio to obtain a target detection model; and detecting the electricity stealing behavior of the user by utilizing the target detection model.

In a certain embodiment, the data scrubbing includes operations to remove duplicate values, to complement missing values, and to remove erroneous values.

In an embodiment, the second training unit 03 is further configured to:

according to the training result, the sample weight with wrong classification is increased to a first preset value, and the sample weight with correct classification is reduced to a second preset value.

In a certain embodiment, the evaluation metrics include overall accuracy, prediction recall, and F1 values.

It should be noted that the electricity stealing behavior detection system provided by the embodiment of the present invention is used for executing the electricity stealing behavior detection method according to the first aspect, and the method is not only high in detection precision, but also capable of determining the electricity stealing behavior of the user according to the metering data of the electricity meter under the condition that the topology structure or the network parameters of the power network are missing, and has the advantages of strong applicability, low cost and high accuracy.

In a fourth aspect:

referring to fig. 3, an embodiment of the present invention further provides a terminal device, where the terminal device includes:

a processor, a memory, and a bus;

the bus is used for connecting the processor and the memory;

the memory is used for storing operation instructions;

the processor is configured to call the operation instruction, and the executable instruction enables the processor to perform an operation corresponding to the electricity stealing behavior detection method according to the first aspect of the application.

In an alternative embodiment, there is provided a terminal device, as shown in fig. 3, the terminal device shown in fig. 3 includes: a processor 001 and a memory 003. Where processor 001 is coupled to memory 003, such as by bus 002. Optionally, terminal device 000 may also include a transceiver 004. It should be noted that the transceiver 004 in practical application is not limited to one, and the structure of the terminal device 000 does not constitute a limitation to the embodiment of the present application.

The processor 001 may be a CPU, general purpose processor, DSP, ASIC, FPGA or other programmable logic device, transistor logic device, hardware component, or any combination thereof. Which may implement or perform the various illustrative logical blocks, modules, and circuits described in connection with the disclosure. The processor 001 may also be a combination that performs computing functions, including for example, one or more microprocessors, a combination of DSPs and microprocessors, and the like.

Bus 002 may include a path to transfer information between the aforementioned components. The bus 002 may be a PCI bus or an EISA bus, etc. The bus 002 may be divided into an address bus, a data bus, a control bus, and the like. For ease of illustration, only one thick line is shown in FIG. 3, but this does not mean only one bus or one type of bus.

The memory 003 can be, but is not limited to, a ROM or other type of static storage device that can store static information and instructions, a RAM or other type of dynamic storage device that can store information and instructions, an EEPROM, a CD-ROM or other optical disk storage, optical disk storage (including compact disk, laser disk, optical disk, digital versatile disk, blu-ray disk, etc.), magnetic disk storage media or other magnetic storage devices, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a computer.

The memory 003 is used for storing application program codes for performing the present solution and is controlled in execution by the processor 001. Processor 001 is configured to execute application code stored in memory 003 to implement any of the method embodiments described above.

Wherein, the terminal device includes but is not limited to: mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and the like, and fixed terminals such as digital TVs, desktop computers, and the like.

Yet another embodiment of the present application provides a computer-readable storage medium having stored thereon a computer program, which, when run on a computer, causes the computer to perform the respective ones of the aforementioned method embodiments.

While the foregoing is directed to the preferred embodiment of the present invention, it will be understood by those skilled in the art that various changes and modifications may be made without departing from the spirit and scope of the invention.

完整详细技术资料下载
上一篇:石墨接头机器人自动装卡簧、装栓机
下一篇:一种雷电地闪识别方法、装置、设备及可读存储介质

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!