An integrated electricity stealing detection method for data missing and class imbalance

CN119357740BActive Publication Date: 2026-09-22TIANJIN UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411377439.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-30
Publication Date
2026-09-22
Estimated Expiration
2044-09-30

AI Technical Summary

Technical Problem

[0006]本发明的目的在于克服现有技术的不足,提出一种面向数据缺失与类不平衡的集成窃电检测方法,能够解决数据不完备和窃电样本匮乏情况下窃电检测精度低的难题

Benefits of technology

[0097]1、本发明提出一种基于TimeGAN的缺失数据补全方法,采用TimeGAN的生成器结构调整重构后的数据,并引入有监督信息与判别器有效提高数据填充精度。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119357740B_ABST
    Figure CN119357740B_ABST
Patent Text Reader

Abstract

The present application relates to a kind of integrated electricity stealing detection methods for data missing and class imbalance, comprising the following steps: step S1: missing data is recovered using TimeGAN time reconstruction capability, i.e. fill normal user and electricity stealing user data;Step S2: the concept of intra-class imbalance is introduced, and a conditional time series generative adversarial network CTimeGAN is developed to synthesize electricity stealing samples and enhance electricity stealing sample data;Step S3: after data filling in step S1 and data enhancement in step S2, the electricity stealing sample data will be used as the input of the electricity stealing detector for optimization, so as to obtain the optimal configuration of the stacking integrated electricity stealing detector;Step S4: the original data processed in step S1 and step S2 is input into the stacking integrated electricity stealing detector based on double-layer heuristic optimization configuration, and the classification results of normal users and electricity stealing users are obtained.The present application can solve the problem of low electricity stealing detection precision under the condition of incomplete data and lack of electricity stealing samples.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of electricity theft detection technology, and relates to an integrated electricity theft detection method, especially an integrated electricity theft detection method for data missing and class imbalance. Background Technology

[0002] Power losses in power systems are divided into technical losses and non-technical losses, and one of the main causes of non-technical losses to the power grid is electricity theft by users. It has been reported that the United States, India, and the United Kingdom lose more than $6 billion, $16.2 billion, and $173 million annually due to electricity theft, respectively. Besides causing significant economic losses, electricity theft also negatively impacts the stability and efficiency of the power grid. As electricity theft becomes increasingly sophisticated and technically complex, traditional methods of identifying thieves through line loss analysis and on-site inspections are no longer sufficient to meet cost and efficiency requirements.

[0003] Therefore, data-driven electricity theft detection methods have become a widely studied research direction in the power industry. However, existing electricity theft detection methods face challenges such as incomplete data, scarce electricity theft samples, and insufficient performance of electricity theft detectors, making it extremely difficult to accurately identify electricity theft users.

[0004] To address the aforementioned problems, this invention proposes an integrated electricity theft detection method oriented towards data missingness and class imbalance.

[0005] A search revealed no publicly available literature of the same or similar prior art as this invention. Summary of the Invention

[0006] The purpose of this invention is to overcome the shortcomings of the prior art and propose an integrated electricity theft detection method for data missing and class imbalance, which can solve the problem of low detection accuracy when data is incomplete and electricity theft samples are scarce.

[0007] The present invention solves its practical problem by adopting the following technical solution:

[0008] An integrated electricity theft detection method for addressing data missingness and class imbalance includes the following steps:

[0009] Step S1: Use TimeGAN's time series reconstruction capability to recover missing data, i.e., fill in the data of normal users and electricity theft users;

[0010] Step S2: The concept of intra-class imbalance was introduced, and a Conditional Temporal Generative Adversarial Network (CTimeGAN) was developed to synthesize electricity theft samples and enhance the electricity theft sample data.

[0011] Step S3: The electricity theft sample data after the data filling in step S1 and the data enhancement in step S2 will be used as the input of the electricity theft detector for optimization, so as to obtain the optimal configuration of the Stacking integrated electricity theft detector.

[0012] Step S4: Input the raw data processed in Steps S1 and S2 into the Stacking integrated electricity theft detector based on the dual-layer heuristic optimization configuration to obtain the classification results of normal users and electricity theft users.

[0013] Furthermore, the specific steps of step S1 include:

[0014] (1) First, the missing / complete state of data is marked by a binary mask matrix. A denoising autoencoder training method is introduced in the training process to improve the learning of the trend of existing real data.

[0015] (2) Then, the reconstructed data is adjusted using the TimeGAN generator structure and trained together with the discriminator to improve the data filling accuracy.

[0016] Furthermore, the specific steps of step (1) of step S1 include:

[0017] Step S101: Map the original electricity consumption data to the latent space using the embedding function of TimeGAN, and then reconstruct the original electricity consumption data using the recovery function;

[0018] The specific process is as follows:

[0019] h t =e(h t-1 ,x t )

[0020]

[0021] In the formula: x t and Represent the dynamic eigenvector and reconstructed value at time t, respectively; h t-1 and h t Let represent the dynamic feature vectors after dimensionality reduction at time t-1 and time t; functions e and r are the embedding function and the recovery function, respectively.

[0022] To ensure that the embedding and recovery functions accurately construct the low-dimensional feature space and reconstruct the original feature space, a joint loss function is defined. To embed network parameters θ e and restore network parameters θ r The update provides the basis for:

[0023]

[0024] In the formula: represents the expected value of a function; ||·||2 represents the Euclidean norm.

[0025] Step S102: Use the reconstruction capabilities of the TimeGAN embedding and recovery functions to fill in missing data, employing a binary mask matrix M. t Mark data status:

[0026]

[0027] Where: N U This represents the number of users input during data interpolation. The data point representing the u-th user at time t is missing data;

[0028] Step S103: Based on the binary mask proposed in step S102, the joint training loss function of the TimeGAN embedding function and recovery function is improved to the reconstruction error of non-missing values:

[0029]

[0030] Step S104: Introduce a training method similar to a denoising autoencoder, randomly adding multiplicative noise to the original signal. The data is zeroed out. Then, the original data is restored by mapping the features of the randomly corrupted data, thus enabling the TimeGAN encoder to learn more robust and generalizable data recovery capabilities in the event of missing data. The joint loss function after introducing supervised loss is:

[0031]

[0032]

[0033] In the formula: r N and e N These represent the recovery function and the embedding function in the TimeGAN data interpolation process, respectively.

[0034] Furthermore, the specific steps of step (2) of step S1 include:

[0035] Step S105: The generator reconstructs the data. And the actual electricity consumption data of similar user groups during the same period corresponding to the missing values. As input, the reconstructed data is corrected:

[0036]

[0037] The power consumption data after data interpolation is as follows:

[0038]

[0039] In the formula: G(·) represents the generator-corrected padding data; G(·) represents the generator correction function.

[0040] Step S106: Use a discriminator to determine the synthetic values ​​in the complete time series, i.e., estimate its original mask matrix M; therefore, measure the discriminator estimation result using binary cross-entropy. The loss between the original mask matrix M and the original mask matrix M:

[0041]

[0042] Where: N T This represents the length of the time series.

[0043] Design a new loss function to adapt the generator to the data imputation task: part of which is the discriminator loss L D The other part is the set correction loss.

[0044]

[0045] In the formula: λ represents the weight of the correction loss.

[0046] Step S107: The user's electricity consumption data is input into the trained TimeGAN. The missing values ​​in the normal and electricity theft sample data are filled in by the embedding function and the recovery function. The filling effect is improved by the generator and the discriminator, so as to provide complete raw data for subsequent identification of electricity theft users.

[0047] Furthermore, the specific steps of step 2 include:

[0048] Step S201: Identify different electricity theft patterns among electricity theft users; use the K-shape clustering method to divide the electricity consumption curves of electricity theft users in historical data into K patterns:

[0049]

[0050]

[0051]

[0052] In the formula: SBD is a shape-based distance; and This represents the electricity consumption sequences of two users for similarity measurement; T represents the length of the time series; ω represents the cross-correlation sequence CC. ω The length of ω is ω∈{1,2,…,2T-1}; k is the relative sliding distance between the two sequences.

[0053] Step S202: Propose a Conditional Temporal Generative Adversarial Network (CTimeGAN) model for data augmentation of electricity theft users; input the clustering results of step S201 as a conditional supervision term into CTimeGAN, so that the generator of CTimeGAN can generate electricity theft sequences of specified patterns, thereby achieving balanced data augmentation for each electricity theft pattern.

[0054] Step S203: The discriminator distinguishes between the electricity theft data synthesized in step S202 and the historical real electricity theft data. The inputs are the output of the generator and the hidden layer output of the real electricity theft data.

[0055] Step S204: In the data augmentation process described in steps S202 and S03, the joint loss function of the CTimeGAN generator and discriminator is designed as follows:

[0056]

[0057] The supervised loss function is defined as:

[0058]

[0059] In the formula: y in Represents the K-shape clustering result; z t Represents a dynamic random vector; D(·) represents the discriminator function; G C (·) represents the generation function of the CTimeGAN generator; y t Classification results representing actual electricity theft data; This represents the classification results of the synthetic electricity theft data.

[0060] Step S205: Through the above steps, CTimeGAN can generate synthetic data that is similar to the statistical characteristics of actual electricity theft, enhance the electricity theft sample data, provide sufficient input data for the electricity theft detection algorithm, and thus effectively improve the accuracy of identifying electricity theft users.

[0061] Furthermore, the specific steps of step S3 include:

[0062] (1) To improve the accuracy of electricity theft detection, a Stacking integrated electricity theft detector based on dual-layer heuristic optimization was developed.

[0063] (2) In order to solve the problem of synchronous dynamic optimization of the combination of electricity theft detector models and hyperparameters, a two-layer heuristic optimization configuration model for Stacking integrated optimization configuration is constructed, and time-varying binary transfer function and external repository are introduced to help improve the algorithm performance of Stacking integrated electricity theft detector based on two-layer heuristic optimization constructed in optimization step (1).

[0064] Furthermore, the specific method for step (1) of step S3 is as follows:

[0065] Step S301: Transform the selection of the Stacking heterogeneous model into decision variables. The optimization problem, in which It is a binary variable, where 1 indicates that the model was selected as a base classifier. It is an integer from 1 to 1, representing the choice of the meta-classifier. Thus, the optimal stacking integrated electricity theft detector is constructed through two-layer heuristic optimization.

[0066] Furthermore, the specific steps of step 3, step (2) include:

[0067] Step S302: Construct a two-layer heuristic optimization configuration model framework for Stacking integrated optimization configuration. This model framework is divided into an upper-layer optimization model and a lower-layer optimization model. The upper-layer optimization model provides the configuration of the base classifier and meta-model of the Stacking integrated electricity theft detector, while the lower-layer optimization model feeds back the corresponding hyperparameter optimization results based on the model configuration provided by the upper layer.

[0068] Step S303: Construct the objective function of a two-layer heuristic optimization configuration model for stacking ensemble configuration. K-fold cross-validation is used so that each fold is used for both training and validation, effectively avoiding model overfitting and inaccurate evaluation due to insufficient validation data.

[0069]

[0070] In the formula: K V This indicates the number of folds in the K-fold cross-validation; and represents the precision and recall of category c when the i-th fold is used as the validation set, respectively.

[0071] Step S304: Set constraints for the two-layer heuristic optimization configuration model for Stacking integration optimization configuration;

[0072] The decision variables of the upper-level optimization model include the selection outcome of the heterogeneous model. The constraints are set as follows:

[0073]

[0074] The decision variables of the lower-level optimization model are the settings of hyperparameters. The constraints are:

[0075]

[0076] In the formula: pi This represents the combination of hyperparameters for the i-th model; The combination of hyperparameters representing the metamodel; This represents the j-th hyperparameter of the i-th model; and These represent the upper and lower bounds of the j-th hyperparameter of the i-th model, respectively.

[0077] Step S305: Combining the objective function and constraints of steps S303 and S304, solve the two-layer heuristic optimization configuration model for stacking ensemble optimization configuration based on the Whale Optimization Algorithm (WOA).

[0078] Step S306: Optimization of the lower-level WOA is carried out based on the configuration of the upper-level WOA. The lower-level heuristic fitness feedback is used to achieve closed-loop iteration. The upper-level optimization model is solved by combining the WOA with the time-varying binary transfer function.

[0079] Furthermore, the specific method of step S306 is as follows:

[0080] In the whale optimization algorithm, whale behavior is divided into two phases: the development phase and the exploration phase. During the development phase, the selection results of the heterogeneous model are updated, and the whale moves closer to the optimal search agent. The specific position calculation formula is as follows:

[0081]

[0082]

[0083] In the formula: t represents the current iteration number; D is the distance between the current whale individual and the optimal solution; Indicates the optimal position at the current iteration number; X t This represents the current position of the individual whale; A and C are the position update coefficients, respectively.

[0084] A 50% probability is set for randomly choosing between development and exploration behaviors, thereby updating the decision variables of the upper-level optimization model;

[0085]

[0086] Introducing time-varying binary transfer functions in WOA:

[0087]

[0088]

[0089] In the formula: XM represents the position of the individual in the heuristic algorithm; t is the current iteration number; t max This represents the maximum number of iterations. For control parameters; and These are the upper and lower limits of the control parameter, respectively.

[0090] The location of the decision variables for the upper-level Stacking configuration can be transformed as follows:

[0091]

[0092] In the formula: represents the value of the d-th decision variable of the m-th search agent; rand represents a random number between 0 and 1.

[0093] Step S307: Solve the lower-level optimization model using WOA with external repository assistance;

[0094] Furthermore, the specific method of step S307 is as follows:

[0095] An external archive is built to record the hyperparameters corresponding to the historical best objective function for each model when used as a base classifier and meta-model. During the optimization of lower-level models, the initial values ​​of the hyperparameters for each classification model will be obtained from the external archive to help the lower-level WOA find the optimal hyperparameters as quickly as possible.

[0096] Advantages and beneficial effects of the present invention:

[0097] 1. This invention proposes a missing data completion method based on TimeGAN. It uses the generator structure of TimeGAN to adjust and reconstruct the data, and introduces supervised information and discriminator to effectively improve the data filling accuracy.

[0098] 2. This invention proposes a CTimeGAN data synthesis model that considers intra-class imbalance. While synthesizing electricity theft samples, K-shape clustering results are used as conditional supervision terms to assist CTimeGAN in learning the distribution of different electricity theft patterns, thereby overcoming the problem of decreased accuracy in identifying electricity theft users caused by intra-class imbalance.

[0099] 3. This invention constructs a two-layer heuristic optimization framework for Stacking integration optimization configuration, which solves the problem of synchronous dynamic optimization of Stacking integration model configuration and hyperparameters, effectively improves the performance of electricity theft detection model, and provides a preferred solution for the application of Stacking integration model in the industry. Attached Figure Description

[0100] Figure 1 This is a flowchart of an integrated electricity theft detection method for data missing and class imbalance according to the present invention;

[0101] Figure 2 This is a flowchart of the dual-layer Stacking integrated optimization configuration of the present invention;

[0102] Figure 3 This is a comparison chart of AUC scores between different Stacking configuration schemes and the configuration scheme optimized by this invention;

[0103] Figure 4 This is a comparison chart of the accuracy of the data imputation method proposed in this invention with other methods under different missing rates;

[0104] Figure 5 This is a classification accuracy diagram before and after imputation of 10% missing data according to the present invention;

[0105] Figure 6 This is a classification accuracy diagram before and after imputation of 30% missing data according to the present invention;

[0106] Figure 7 This is a comparison chart of convergence curves with and without an external repository. Detailed Implementation

[0107] The embodiments of the present invention will be further described in detail below:

[0108] An integrated electricity theft detection method addressing data missingness and class imbalance, such as... Figure 1 As shown, it includes the following steps:

[0109] Step S1: Use TimeGAN's time series reconstruction capability to recover missing data, that is, fill in the data of normal users and electricity theft users to avoid misjudgment caused by missing data.

[0110] The specific steps of step S1 include:

[0111] (1) First, the missing / complete state of data is marked by a binary mask matrix. A denoising autoencoder training method is introduced in the training process to improve the learning of the trend of existing real data.

[0112] (2) Then, the reconstructed data is adjusted using the TimeGAN generator structure and trained together with the discriminator to improve the data filling accuracy.

[0113] The specific steps of step (1) of step S1 include:

[0114] Step S101: Map the original electricity consumption data to the latent space using the embedding function of TimeGAN, and then reconstruct the original electricity consumption data using the recovery function;

[0115] The specific process is as follows:

[0116] h t =e(h t-1 ,x t )

[0117]

[0118] In the formula: x t and Represent the dynamic eigenvector and reconstructed value at time t, respectively; h t-1 and h t Let represent the dynamic feature vectors after dimensionality reduction at time t-1 and time t; functions e and r are the embedding function and the recovery function, respectively.

[0119] To ensure that the embedding and recovery functions accurately construct the low-dimensional feature space and reconstruct the original feature space, a joint loss function is defined. To embed network parameters θ e and restore network parameters θ r The update provides the basis for:

[0120]

[0121] In the formula: represents the expected value of a function; ||·||2 represents the Euclidean norm.

[0122] In this embodiment, the working principle of step S101 is as follows: the structure of TimeGAN includes an embedding function, a recovery function, a sequence generator, and a sequence discriminator. The key lies in the joint training of the autoencoder components (the first two) and the adversarial components (the latter two), thereby enabling TimeGAN to simultaneously learn the temporal features of electricity theft data, generate representations, and iterate across time.

[0123] Step S102: Use the reconstruction capabilities of the TimeGAN embedding and recovery functions to fill in missing data, employing a binary mask matrix M. t Mark data status:

[0124]

[0125] Where: N U This represents the number of users input during data interpolation. The data point representing the u-th user at time t is missing data.

[0126] Step S103: Based on the binary mask proposed in step S102, the joint training loss function of the TimeGAN embedding function and recovery function is improved to the reconstruction error of non-missing values:

[0127]

[0128] Step S104: Introduce a training method similar to a denoising autoencoder, randomly adding multiplicative noise to the original signal. The data is zeroed out. Then, the original data is restored by mapping the features of the randomly corrupted data, thus enabling the TimeGAN encoder to learn more robust and generalizable data recovery capabilities in the event of missing data. The joint loss function after introducing supervised loss is:

[0129]

[0130]

[0131] In the formula: r N and e N These represent the recovery function and the embedding function in the TimeGAN data interpolation process, respectively.

[0132] The working principle of step S104 is that the imputation of missing data does not provide supervised information to better guide model training, which will cause the model to overfit the existing real data.

[0133] The specific steps of step (2) of step S1 include:

[0134] Step S105: The generator reconstructs the data. And the actual electricity consumption data of similar user groups during the same period corresponding to the missing values. As input, the reconstructed data is corrected:

[0135]

[0136] The power consumption data after data interpolation is as follows:

[0137]

[0138] In the formula: G(·) represents the generator-corrected padding data; G(·) represents the generator correction function.

[0139] Step S106: Use a discriminator to determine the composite values ​​in the complete time series, i.e., estimate its original mask matrix M. Therefore, the discriminator estimation result is measured using binary cross-entropy. The loss between the original mask matrix M and the original mask matrix M:

[0140]

[0141] Where: N T This represents the length of the time series.

[0142] Design a new loss function to adapt the generator to the data imputation task: part of which is the discriminator loss. The other part is the set correction loss.

[0143]

[0144] In the formula: λ represents the weight of the correction loss.

[0145] Step S107: The user's electricity consumption data is input into the trained TimeGAN. The missing values ​​in the normal and electricity theft sample data are filled in by the embedding function and the recovery function. The filling effect is improved by the generator and the discriminator, so as to provide complete raw data for subsequent identification of electricity theft users.

[0146] Step S2: The concept of intra-class imbalance was introduced, and a Conditional Temporal Generative Adversarial Network (CTimeGAN) was developed to synthesize electricity theft samples and enhance the electricity theft sample data.

[0147] The specific method for step S2 is as follows:

[0148] The concept of intra-class imbalance was introduced in the data augmentation process. Different electricity theft patterns were mined by K-shape clustering algorithm, and the clustering results were used as conditional supervision terms to assist the Conditional Temporal Generative Adversarial Network (CTimeGAN) in learning the distribution of different electricity theft patterns, so that each electricity theft pattern was synthesized in an balanced manner.

[0149] The specific steps of step 2 include:

[0150] Step S201: Identify different electricity theft patterns among electricity theft users; use the K-shape clustering method to divide the electricity consumption curves of electricity theft users in historical data into K patterns:

[0151]

[0152]

[0153]

[0154] In the formula: SBD is a shape-based distance; and This represents the electricity consumption sequences of two users for similarity measurement; T represents the length of the time series; ω represents the cross-correlation sequence CC. ω The length of ω is ω∈{1,2,…,2T-1}; k is the relative sliding distance between the two sequences.

[0155] Step S202: Propose a Conditional Temporal Generative Adversarial Network (CTimeGAN) model for data augmentation of electricity theft users; input the clustering results of step S201 as a conditional supervision term into CTimeGAN, so that the generator of CTimeGAN can generate electricity theft sequences of specified patterns, thereby achieving balanced data augmentation for each electricity theft pattern.

[0156] Step S203: The discriminator distinguishes between the electricity theft data synthesized in step S202 and the historical real electricity theft data. The inputs are the generator output and the hidden layer output of the real electricity theft data.

[0157] Step S204: In the data augmentation process described in steps S202 and S03, the joint loss function of the CTimeGAN generator and discriminator is designed as follows:

[0158]

[0159] The supervised loss function is defined as:

[0160]

[0161] In the formula: y in Represents the K-shape clustering result; z t Represents a dynamic random vector; D(·) represents the discriminator function; G C (·) represents the generation function of the CTimeGAN generator; y t Classification results representing actual electricity theft data; This represents the classification results of the synthetic electricity theft data.

[0162] Step S205: Through the above steps, CTimeGAN can generate synthetic data that is similar to the statistical characteristics of actual electricity theft, enhance the electricity theft sample data, provide sufficient input data for the electricity theft detection algorithm, and thus effectively improve the accuracy of identifying electricity theft users.

[0163] Step S3: The electricity theft sample data after the data filling in step S1 and the data enhancement in step S2 will be used as the input of the electricity theft detector for optimization, so as to obtain the optimal configuration of the Stacking integrated electricity theft detector, so as to complete the detection of electricity theft behavior in the application process.

[0164] The specific steps of step S3 include:

[0165] (3) To improve the accuracy of electricity theft detection, a Stacking integrated electricity theft detector based on dual-layer heuristic optimization was developed.

[0166] like Figure 2 As shown, the specific method of step S3 (1) is as follows:

[0167] Step S301: Transform the selection of the Stacking heterogeneous model into decision variables. The optimization problem, in which It is a binary variable, where 1 indicates that the model was selected as a base classifier. It is an integer from 1 to 1, representing the choice of the meta-classifier. Thus, the optimal stacking integrated electricity theft detector is constructed through two-layer heuristic optimization.

[0168] The working principle of step S301 is as follows: The basic idea of ​​Stacking is to construct two-layer classification models: a base classifier and a meta-classifier. The base classifier classifies the electricity consumption data and obtains the classification results. The classification results of multiple base classifiers serve as the input to the meta-classifier, which is responsible for learning the mapping relationship between the output of the base classifiers and the electricity theft detection results. Since Stacking is a heterogeneous model ensemble strategy, different combinations of classifiers may perform better on different datasets or problems, requiring optimization.

[0169] (4) In order to solve the problem of synchronous dynamic optimization of the combination of electricity theft detector models and hyperparameters, a two-layer heuristic optimization configuration model for Stacking integrated optimization configuration is constructed, and time-varying binary transfer function and external repository are introduced to help improve the algorithm performance of Stacking integrated electricity theft detector based on two-layer heuristic optimization constructed in optimization step (1).

[0170] The specific steps of step 3, step (2) include:

[0171] Step S302: Construct a two-layer heuristic optimization configuration model framework for Stacking integrated optimization configuration. This model framework is divided into an upper-layer optimization model and a lower-layer optimization model. The upper-layer optimization model provides the configuration of the base classifier and meta-model of the Stacking integrated electricity theft detector, while the lower-layer optimization model feeds back the corresponding hyperparameter optimization results based on the model configuration provided by the upper layer.

[0172] The working principle of step S302 is that the selection of hyperparameters, without prior knowledge guidance, is often difficult to make scientifically based on human experience. Most scholars typically use heuristic algorithms to optimize hyperparameters. However, in the optimization process of Stacking configurations, the number and type of hyperparameters change under different heterogeneous model combinations, making it difficult to optimize both the heterogeneous model combinations and the hyperparameters simultaneously.

[0173] Step S303: Construct the objective function of a two-layer heuristic optimization configuration model for stacking ensemble configuration. K-fold cross-validation is used so that each fold is used for both training and validation, effectively avoiding model overfitting and inaccurate evaluation due to insufficient validation data.

[0174]

[0175] In the formula: K V This indicates the number of folds in the K-fold cross-validation; and represents the precision and recall of category c when the i-th fold is used as the validation set, respectively.

[0176] The working principle of step S303 is that the two-layer heuristic optimization configuration method requires an index that can represent the comprehensive classification ability of the model as the objective function to guide the optimization.

[0177] Step S304: Set constraints for the two-layer heuristic optimization configuration model for Stacking integration optimization configuration;

[0178] The decision variables of the upper-level optimization model include the selection outcome of the heterogeneous model. The constraints are set as follows:

[0179]

[0180] The decision variables of the lower-level optimization model are the settings of hyperparameters. The constraints are:

[0181]

[0182] In the formula: p i This represents the combination of hyperparameters for the i-th model; The combination of hyperparameters representing the metamodel; This represents the j-th hyperparameter of the i-th model; and These represent the upper and lower bounds of the j-th hyperparameter of the i-th model, respectively.

[0183] Step S305: Combining the objective function and constraints of steps S303 and S304, solve the two-layer heuristic optimization configuration model for stacking ensemble optimization configuration based on the Whale Optimization Algorithm (WOA).

[0184] Step S306: Optimization of the lower-level WOA is carried out based on the configuration of the upper-level WOA. The lower-level heuristic fitness feedback is used to achieve closed-loop iteration. The upper-level optimization model is solved by combining the WOA with the time-varying binary transfer function.

[0185] The specific method for step S306 is as follows:

[0186] In the whale optimization algorithm, whale behavior is divided into two phases: the development phase and the exploration phase. During the development phase, the selection results of the heterogeneous model are updated, and the whale moves closer to the optimal search agent. The specific position calculation formula is as follows:

[0187]

[0188]

[0189] In the formula: t represents the current iteration number; D is the distance between the current whale individual and the optimal solution; Indicates the optimal position at the current iteration number; X t This represents the current position of the individual whale; A and C are the position update coefficients, respectively.

[0190] A 50% probability is set for randomly choosing between development and exploration behaviors, thereby updating the decision variables of the upper-level optimization model;

[0191]

[0192] This invention introduces a time-varying binary transfer function into WOA to improve the quality of the solution:

[0193]

[0194]

[0195] In the formula: XM represents the position of the individual in the heuristic algorithm; t is the current iteration number; t max This represents the maximum number of iterations. For control parameters; and These are the upper and lower limits of the control parameter, respectively.

[0196] The location of the decision variables for the upper-level Stacking configuration can be transformed as follows:

[0197]

[0198] In the formula: represents the value of the d-th decision variable of the m-th search agent; rand represents a random number between 0 and 1.

[0199] The working principle of step S306 is as follows: Since binary variables are involved in the optimization of the upper-level model, traditional continuous numerical optimization loses its driving force. In the early stages of operation, the optimization algorithm should focus more on exploration to avoid getting trapped in local optima; in the later stages, it needs to focus more on development.

[0200] Step S307: Solve the lower-level optimization model using WOA with external repository assistance;

[0201] The specific method for step S307 is as follows:

[0202] This invention constructs an external archive to record the hyperparameters corresponding to the historical best objective function for each model when used as a base classifier and meta-model. During the optimization of lower-level models, the initial values ​​of the hyperparameters for each classification model are obtained from the external archive to assist the lower-level WOA in finding the optimal hyperparameters as quickly as possible.

[0203] Step S4: Input the raw data processed in Steps S1 and S2 into the Stacking integrated electricity theft detector based on the dual-layer heuristic optimization configuration to obtain the classification results of normal users and electricity theft users.

[0204] The preferred embodiment of the specific application of the present invention:

[0205] To verify the effectiveness of electricity theft detection considering class imbalance and missing data, a suitable electricity user dataset needs to be found first, and the collected dataset needs to be preprocessed to provide data support for subsequent case studies. To verify the effectiveness and superiority of the proposed model, four sets of experiments were designed to simulate and verify the methods proposed in Sections 2 and 3. Taking a real dataset from the State Grid as an example, it includes 38,757 fair users and 3,615 fraudulent users, with each customer's electricity consumption sequence containing 1,035 sampling points. The ratio of the training set to the test set is 8:2, and the test set contains user data for five different electricity theft patterns. To reflect the comprehensive classification performance of the model under imbalanced conditions, the evaluation metrics used are detection rate (DR), macro-average F1 score (Macro-F1), and area under the curve (AUC), specifically defined as follows:

[0206]

[0207]

[0208]

[0209] In the formula: TP represents the number of electricity theft samples correctly classified by the model; FN represents the number of electricity theft samples identified as normal samples by the model; M and N represent the number of electricity theft samples and normal samples, respectively; p i For each electricity theft sample, calculate the number of samples whose ranking is higher than that of all normal samples; C is the set of electricity theft samples.

[0210] First, to avoid the infinite gradient phenomenon caused by missing data, the proposed data imputation method is used to impute missing values ​​in the dataset. It is worth noting that, to avoid revealing potential abnormal behavior by electricity theft users, TimeGAN data imputation is only performed on normal users. Subsequently, adhering to the principle of "excellence in diversity," this invention selects 11 relatively advanced classifiers in the field of data processing, including: Convolutional Neural Networks (CNN), Long Short-Term Memory Networks (LSTM), Temporal Convolutional Networks (TCN), and Backpropagation Neural Networks (BPNN) from the neural network category; Lightweight Gradient Boosting Machines (LightGBM), Extreme Gradient Boosting Machines (XGBoost), and Random Forests (RF) from ensemble learning; and Support Vector Machines (SVM), K-Nearest Neighbors (KNN), Logistic Regression (LR), and Naive Bayes (NB) from traditional machine learning models. This comprehensive consideration can also provide a reference for other research.

[0211] Table 1. Stacking configuration results after dual-layer heuristic optimization

[0212]

[0213] The upper-layer WOA population size was set to 150, and the number of iterations was set to 200. The lower-layer WOA population size was set to 60, and the number of iterations was set to 50. The standardized training set data was used as input for optimization, and the optimization results are shown in Table 1. It can be seen that the ensemble classifier was chosen more frequently, indicating its better application potential in electricity theft detection tasks. Specifically, the XGBoost classifier was used as both the base model and the meta-model, demonstrating that it can not only accurately classify time series data but also effectively fuse the detection results of different classifiers, exhibiting strong generalization ability.

[0214] Table 2. Accuracy of each electricity theft detection model after data augmentation

[0215]

[0216] To demonstrate the superiority of the electricity theft detection model obtained in this invention, the Stacking ensemble classifier developed in this invention is compared with other advanced classifiers. The hyperparameters of other classifiers were obtained from external repositories, and the DR scores and Macro-F1 scores are shown in Table 2. The data with the highest accuracy is displayed in bold. As can be seen from the table, there are significant differences in detection rates among different models, with CNN and TCN classifiers, which have feature extraction capabilities, showing significantly higher detection rates. Overall, the classifier developed in this invention performs optimally for almost every category, with an average Macro-F1 score 12.93% higher and an average DR score 15.78% higher than other classifiers, fully demonstrating the superiority of the proposed electricity theft detection model. Naive Bayes (NB) performed the worst in the experiment, indicating that its assumption of ignoring the correlation between features cannot meet the requirements of the electricity theft detection task, and also confirming the existence of mutually coupled temporal correlations in user electricity consumption time series.

[0217] For ease of comparison, samples without data augmentation were used for training, and the accuracy of each electricity theft detection model is shown in Table 3. Comparing Table 3 with Table 2, it can be seen that the data augmentation method proposed in this invention can effectively improve the DR scores of each model by synthesizing samples of different electricity theft patterns. Simultaneously, sufficient learning from the electricity theft samples improves the overall classification performance of the models, thus increasing the Macro-F1 scores of each model. Moreover, the Stacking ensemble electricity theft detection model proposed in this invention shows the best performance both before and after data augmentation, exhibiting the best generalization ability.

[0218] Table 3. Accuracy of each electricity theft detection model before data augmentation

[0219]

[0220] Table 4 Stacking configurations for different studies

[0221]

[0222] To demonstrate the effectiveness of the stacking optimization configuration of this invention, we compared the stacking configuration scheme obtained by this invention with stacking configurations in other studies. The model configurations of each study are shown in Table 4. The AUC scores of each configuration scheme are as follows: Figure 3As shown, Configuration 1 lacks comprehensive consideration of algorithm diversity, thus exhibiting a lower AUC score on the dataset of this invention. Configuration 2, in the original paper, selected base classifiers and meta-classifiers based on the model's performance on mixed datasets, thus achieving higher accuracy than Configuration 1. Configuration 3 considers nine different classifiers as base classifiers, demonstrating good diversity; however, the large number of models and the lack of optimization result in severe information redundancy, leading to lower accuracy than the configuration scheme proposed in this invention. The results from Configurations 3 and 4 show that stacking configurations, which perform well in other fault diagnosis fields, are not necessarily suitable for detecting electricity theft. In other words, optimizing configurations for specific problems is essential. Overall, all three configuration schemes selected XGBoost as the meta-classifier, indirectly confirming the rationality of the configuration scheme in this invention, and the configuration scheme obtained in this invention achieves the best electricity theft detection effect.

[0223] To visualize the data imputation effect, this invention manually masks some measurements from normal user time series as missing values ​​to simulate imputation, and treats these values ​​as the underlying facts for verification. The missing value ratio ranges from 10% to 40%, with the remaining data used for training. Baseline methods include commonly used data imputation techniques such as K-Nearest Neighbors (KNN), Generative Adversarial Networks (GANs), Autoencoders (AEs), and Linear Interpolation (LI). The experiment was repeated 10 times to obtain the mean absolute error of each scheme under different missing values, such as... Figure 4 As shown, the difficulty of data imputation for any model increases with the increase in the missing data rate. At a low missing data rate (10%), linear interpolation also exhibits low imputation error because at low missing data rates, most missing data points are single-point missing, and the surrounding data points often represent the true value of the missing point well. As the missing data rate gradually increases, traditional linear interpolation methods gradually lose competitiveness, indicating that the linear relationship assumption is no longer sufficient for the needs of this scenario. When there is a large amount of missing data, deep learning models demonstrate good robustness by capturing and modeling complex patterns and relationships in the data, enabling them to make reasonable predictions even with limited information. Overall, the TimeGAN data imputation method proposed in this invention achieves the highest accuracy across different missing data ratios.

[0224] The classification results can be seen as indirect proof of the imputation accuracy. Therefore, this invention investigated the improvement effect of different data imputation methods on the overall model performance using Stacking as the classifier. For a comprehensive comparison, the missing values ​​in the training set were set to 10% and 30%, and the experiment was repeated 5 times. The Macro-F1 scores before and after data imputation using different methods are shown below. Figure 5 and Figure 6As shown in Figure X, data integrity has a significant impact on the effectiveness of electricity theft detection. Furthermore, as the missing data rate increases, key information is more easily obscured, leading to a significant decrease in classifier accuracy. Moreover, at a low missing data rate (10%), linear interpolation provides a more accurate implication than KNN, resulting in better detection accuracy. At a high missing data rate (30%), both linear interpolation and KNN are significantly less effective than deep learning methods, consistent with the data imputation error results in Figure X. Compared to other data imputation methods, the model proposed in this invention achieves an average Macro-F1 score 2.325% higher at a 10% missing data rate and an average Macro-F1 score 11.1% higher at a 30% missing data rate. This indicates that the proposed method provides estimates that better reflect the actual data distribution, effectively assisting the model in distinguishing between legitimate and thieving electricity users.

[0225] To verify the superiority of the proposed CTimeGAN data augmentation method, this section investigates comparisons with different benchmarks, including Generative Adversarial Networks (GANs), Synthetic Minority Oversampling (SMOTE), Variational Autoencoders (VAEs), and Random Oversampling (ROS). Electricity theft samples were synthesized using each of these data augmentation methods, and the accuracy after data augmentation was visualized based on a Stacking ensemble classifier, as shown in Table 5. It can be seen that ROS performs the worst overall. This is because repeated sampling of minority class samples increases redundant information, reducing the model's generalization ability. While increasing the detection rate, it also leads to many normal users being falsely identified as electricity thieves. GANs and VAEs, being deep learning methods, can learn complex data distributions and generate higher-quality samples compared to SMOTE and ROS. However, GANs and VAEs cannot capture the temporal dependencies in the data, thus performing worse than CTimeGAN. VAEs, in particular, tend to generate data with a distribution closer to the real data, enhancing the model's ability to identify electricity thieves, which helps improve the detection rate but leads to a decrease in overall accuracy. The CTimeGAN proposed in this invention can not only learn the data distribution, but also capture the dynamics and transformation patterns in the time series. It can improve the model's ability to identify electricity theft users with less noise information, and on average, it is 8.23% higher in DR score, 3.45% higher in AUC score, and 5.60% higher in Macro-F1 score than the baseline method.

[0226] Table 5 Classification accuracy after processing with different data augmentation methods

[0227]

[0228] To verify the effectiveness of the proposed external repository, a lower-level iteration process corresponding to a certain round of upper-level iteration was selected. The search performance difference between introducing and not introducing the external repository during the lower-level optimization iteration process was compared. Figure 7 As shown, the lower layer optimizes for different decision variables due to the different stacking configurations provided by the upper-level optimization model, resulting in slower convergence of the traditional scheme using randomly initialized hyperparameters. The external repository, with its heuristic memory function, can provide the lower-level heuristic optimization with initial hyperparameters closer to the optimum, achieving a higher-quality solution set with fewer iterations, thus fully validating the effectiveness of the proposed method.

[0229] It should be emphasized that the embodiments described in this invention are illustrative rather than limiting. Therefore, this invention includes, but is not limited to, the embodiments described in the specific implementation. Any other implementations derived by those skilled in the art based on the technical solutions of this invention are also within the scope of protection of this invention.

Claims

1. An integrated electricity theft detection method for addressing data missingness and class imbalance, characterized in that: Includes the following steps: Step S1: Use TimeGAN's time series reconstruction capability to recover missing data, i.e., fill in the data of normal users and electricity theft users; Step S2: The concept of intra-class imbalance was introduced, and a Conditional Temporal Generative Adversarial Network (CTimeGAN) was developed to synthesize electricity theft samples and enhance the electricity theft sample data. Step S3: The electricity theft sample data after the data filling in step S1 and the data enhancement in step S2 will be used as the input of the electricity theft detector for optimization, so as to obtain the optimal configuration of the Stacking integrated electricity theft detector. Step S4: Input the raw data processed in steps S1 and S2 into the Stacking integrated electricity theft detector based on the dual-layer heuristic optimization configuration to obtain the classification results of normal users and electricity theft users; The specific steps of step S1 include: (1) First, the missing / complete state of data is marked by a binary mask matrix. A denoising autoencoder training method is introduced in the training process to improve the learning of the trend of existing real data. (2) Then, the reconstructed data is adjusted using the generator structure of TimeGAN and trained together with the discriminator to improve the data filling accuracy; The specific steps of step (1) of step S1 include: Step S101: Map the original electricity consumption data to the latent space using the embedding function of TimeGAN, and then reconstruct the original electricity consumption data using the recovery function; The specific process is as follows: In the formula: x t and They represent t Time-varying dynamic feature vectors and reconstructed values; h t-1 and h t express t -1 time and t The dynamic feature vector after dimensionality reduction at any given time; function e and r These are the embedding function and the recovery function, respectively. To ensure that the embedding and recovery functions accurately construct the low-dimensional feature space and reconstruct the original feature space, a joint loss function is defined. To embed network parameters and restore network parameters The update provides the basis for: In the formula: This represents finding the expected value of a function; Represents the Euclidean norm; Step S102: Use the reconstruction capabilities of the TimeGAN embedding and recovery functions to fill in missing data, employing a binary mask matrix. Mark data status: In the formula: This represents the number of users input during data interpolation; Representing the u individual users t The data points at each time point are missing data. Step S103: Based on the binary mask proposed in step S102, the joint training loss function of the TimeGAN embedding function and recovery function is improved to the reconstruction error of non-missing values: Step S104: Introduce a training method similar to a denoising autoencoder, randomly adding multiplicative noise to the original signal. The data is set to zero; then, the original data is restored by mapping the features of the randomly corrupted data, thus enabling the TimeGAN encoder to learn more robust and generalizable data recovery capabilities in the event of missing data; the joint loss function after introducing supervised loss is: In the formula: and These represent the recovery function and the embedding function in the TimeGAN data interpolation process, respectively. The specific steps of step (2) of step S1 include: Step S105: The generator reconstructs the data. And the actual electricity consumption data of similar user groups during the same period corresponding to the missing values. As input, the reconstructed data is corrected: The power consumption data after data interpolation is as follows: In the formula: This represents the padding data after generator correction; Represents the generator correction function; Step S106: Use a discriminator to determine the synthetic values ​​in the complete time series, i.e., estimate its original mask matrix. M Therefore, the discriminator estimation result is measured using binary cross-entropy. and the original mask matrix M Losses between: In the formula: N T Represents the length of the time series; Design a new loss function to adapt the generator to the data imputation task: part of which is the discriminator loss. The other part is the set correction loss. : In the formula: This represents the weight of the corrected loss; Step S107: The user's electricity consumption data is input into the trained TimeGAN. The missing values ​​in the normal and electricity theft sample data are filled by the embedding function and the recovery function. The filling effect is improved by the generator and the discriminator, so as to provide complete original data for subsequent identification of electricity theft users. The specific steps of step S2 include: Step S201: Identify different electricity theft patterns among electricity theft users; use the K-shape clustering method to divide the electricity consumption curves of electricity theft users in historical data into... K One pattern: In the formula: SBD is a shape-based distance; and This represents the electricity consumption sequences of two users for whom a similarity measurement is performed. T Indicates the length of the time series; Represents cross-correlation sequences Length, ; k It is the relative sliding distance between the two sequences; Step S202: Propose a Conditional Temporal Generative Adversarial Network (CTimeGAN) model for data augmentation of electricity theft users; input the clustering results of step S201 as a conditional supervision term into CTimeGAN, so that the generator of CTimeGAN can generate electricity theft sequences of specified patterns, thereby achieving balanced data augmentation for each electricity theft pattern. Step S203: The discriminator distinguishes between the electricity theft data synthesized in step S202 and the historical real electricity theft data. The input is the output of the generator and the hidden layer output of the real electricity theft data. Step S204: In the data augmentation process described in steps S202 and S203, the joint loss function of the CTimeGAN generator and discriminator is designed as follows: The supervised loss function is defined as: In the formula: This represents the K-shape clustering result; z t Represents a dynamic random vector; Represents the discriminator function; The generation function representing the CTimeGAN generator; Classification results representing actual electricity theft data; Step S205: Through the above steps, CTimeGAN can generate synthetic data that is similar to the statistical characteristics of actual electricity theft, enhance the electricity theft sample data, provide sufficient input data for the electricity theft detection algorithm, and thus effectively improve the accuracy of identifying electricity theft users. The specific steps of step S3 include: (1) To improve the accuracy of electricity theft detection, a Stacking integrated electricity theft detector based on dual-layer heuristic optimization was developed; (2) In order to solve the problem of synchronous dynamic optimization of the combination of electricity theft detector models and hyperparameters, a two-layer heuristic optimization configuration model for Stacking integrated optimization configuration is constructed, and a time-varying binary transfer function and external repository are introduced to help improve the algorithm performance of the Stacking integrated electricity theft detector based on two-layer heuristic optimization constructed in optimization step (1). The specific method for step (1) of step S3 is as follows: Step S301: Transform the selection of the Stacking heterogeneous model into decision variables. The optimization problem, in which It is a binary variable, where 1 indicates that the model was selected as a base classifier. It is from 1 to N s The integer represents the choice of the meta-classifier; thus, the optimal Stacking integrated electricity theft detector is constructed through two-layer heuristic optimization. The specific steps of step S3 (2) include: Step S302: Construct a two-layer heuristic optimization configuration model framework for Stacking integrated optimization configuration. This model framework is divided into an upper-layer optimization model and a lower-layer optimization model. The upper-layer optimization model provides the configuration of the base classifier and meta-model of the Stacking integrated electricity theft detector, and the lower-layer optimization model feeds back the corresponding hyperparameter optimization results based on the model configuration provided by the upper layer. Step S303: Construct the objective function of a two-layer heuristic optimization configuration model for stacking ensemble configuration. K-fold cross-validation is used so that each fold is used for both training and validation, effectively avoiding model overfitting and inaccurate evaluation due to insufficient validation data. In the formula: K V This indicates the number of folds in the K-fold cross-validation; and Representing the first i When fold is used as a validation set, the category c Accuracy and recall; Step S304: Set constraints for the two-layer heuristic optimization configuration model for Stacking integration optimization configuration; The decision variables of the upper-level optimization model include the selection outcome of the heterogeneous model. The constraints are set as follows: The decision variables of the lower-level optimization model are the settings of hyperparameters. The constraints are: ≤ ≤ In the formula: Representing the i Combinations of hyperparameters for each model; The combination of hyperparameters representing the metamodel; Representing the i The model of the first j One hyperparameter; and Representing the first i The model of the first j The upper and lower bounds of each hyperparameter; Step S305: Combining the objective function and constraints of steps S303 and S304, solve the two-layer heuristic optimization configuration model for stacking ensemble optimization configuration based on the Whale Optimization Algorithm (WOA). Step S306: The optimization of the lower-level WOA is carried out based on the configuration of the upper-level WOA. The fitness of the lower-level heuristic is fed back to the upper-level to realize closed-loop iteration; the upper-level optimization model is solved by combining the WOA with the time-varying binary transfer function. Step S307: Solve the lower-level optimization model using WOA with external repository assistance.

2. The integrated electricity theft detection method for data missingness and class imbalance according to claim 1, characterized in that: The specific method for step S306 is as follows: In the whale optimization algorithm, whale behavior is divided into two phases: the development phase and the exploration phase. During the development phase, the selection results of the heterogeneous model are updated, and the whale moves closer to the optimal search agent. The specific position calculation formula is as follows: In the formula: t Indicates the current iteration number; D This represents the distance between the current individual whale and the optimal solution. This indicates the optimal position at the current iteration number; Indicates the current location of the individual whale; A and C These are the position update coefficients; A 50% probability is set for randomly choosing between development and exploration behaviors, thereby updating the decision variables of the upper-level optimization model; Introducing time-varying binary transfer functions in WOA: In the formula: XM represents the position of the individual in the heuristic algorithm; t is the current iteration number; This represents the maximum number of iterations. For control parameters; and These are the upper and lower limits of the control parameter, respectively; The location of the decision variables for the Stacking configuration at the upper level is transformed as follows: In the formula: represents the value of the d-th decision variable of the m-th search agent; rand represents a random number between 0 and 1.

3. The integrated electricity theft detection method for data missingness and class imbalance according to claim 1, characterized in that: The specific method for step S307 is as follows: An external repository is built to record the hyperparameters corresponding to the historical best objective function when each model is used as a base classifier and meta-model. When optimizing the lower-level model, the initial values ​​of the hyperparameters of each classification model will be obtained from the external repository to help the lower-level WOA find the optimal hyperparameters as quickly as possible.

Citation Information

Patent Citations

  • Non-technical line loss detection system and method

    CN117609922A

  • Electricity larceny detection method fusing resampling and Stacking ensemble learning

    CN118606757A