Intelligent power grid federal learning electricity stealing detection method based on privacy enhancement

By adopting the TCN-CNN architecture and distributed federated learning framework in the smart grid, combined with LDP and MOTP technologies, the calculation complexity and privacy of the power stolen detection model are solved, and efficient power stolen detection and cross-regional data security sharing are achieved.

CN119919158AActive Publication Date: 2025-05-02NANJING UNIV OF POSTS & TELECOMM

Patent Information

Application Number
CN202510397520.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-01
Publication Date
2025-05-02
Estimated Expiration
2045-04-01

AI Technical Summary

Technical Problem

The existing power stolen detection model has high computational complexity, difficulty in capturing long-distance dependencies, limited receptive fields, high computing and communication overhead, and cannot achieve security mining of cross-regional data value due to privacy issues.

Method used

Using a smart grid federated learning method based on privacy enhancement, multi-scale timing-dependent features and spatial correlation are extracted through the TCN-CNN tandem architecture, model training is carried out in combination with a distributed federated learning framework, and data desensitization and model parameter encryption interaction are used using LDP technology and MOTP protocol.

Benefits of technology

It realizes the three-dimensional performance of power stolen features, improves the generalization ability of the model, reduces the cross-domain communication load, and ensures the privacy of user data and model detection efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119919158A_ABST
    Figure CN119919158A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of electricity larceny detection, in particular to an intelligent power grid federal learning electricity larceny detection method based on privacy enhancement, which comprises the following steps: S1, collecting user energy consumption data to construct a local training data set; s2, inputting a local training data set into the training model in batches to extract time sequence features and spatial features; s3, determining an output result, and updating the weight and bias of the training model; s4, inputting the trained weight and bias into a privacy protector to determine an encryption vector, and obtaining an aggregation vector through a data center; s5, obtaining a decryption vector through the aggregation vector, determining an electricity larceny detection model, judging whether the maximum number of iterations is reached or not, and if not, repeating the steps S2-S4; if yes, executing the next step; and S6, if the prediction result is greater than the screening threshold value, indicating that the correspondingly analyzed user is an electricity stealing user, and transmitting the information of the electricity stealing user to a data center.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of electricity theft detection, and in particular to a smart grid federated learning electricity theft detection method based on privacy enhancement. Background Art

[0002] The rapid development of smart grids has led to the widespread use of smart devices, providing data support for the management of power systems; but the increase in data traffic has also brought challenges, especially while protecting user privacy. It is estimated that global electricity theft causes huge losses every year; in actual applications, electricity theft not only causes economic losses, but may also disrupt energy production and distribution. It poses a multi-dimensional threat to the power system, including grid harmonic pollution, voltage fluctuations, load forecasting deviations, inaccurate generator scheduling, electrical fire risks, and undermining market fairness; therefore, live detection is crucial to the stable operation of the power system and the efficiency of energy management; therefore, how to efficiently use energy consumption data for live detection becomes the key.

[0003] In recent years, deep learning methods, such as recurrent neural networks (RNNs), long short-term memory (LSTMs), and one-dimensional convolutional neural networks (CNNs), have been introduced into the field of electricity theft detection to improve the ability to identify complex electricity usage patterns. However, these existing deep learning methods still have significant defects in practical applications: (1) Although RNNs and LSTMs can process time series data, they have high computational complexity and are susceptible to the gradient vanishing problem, making it difficult to efficiently capture long-distance dependencies; and although traditional one-dimensional CNNs have high computational efficiency, they are difficult to fully exploit the multi-scale time series features in electricity usage data due to their limited receptive field. As a result, the existing models have insufficient detection accuracy and generalization ability when facing nonlinear and high-noise electricity theft behaviors; (2) Electricity data contains sensitive information such as users' electricity usage habits and behavior patterns. Directly sharing this data will bring serious privacy leakage risks. Therefore, it is often difficult to directly share power data from different regions, which greatly limits the cross-regional use and analysis of data and hinders the performance improvement of the power theft detection model; (3) Although the direct sharing of power data is limited due to privacy issues, with the promotion of distributed energy systems, live detection still needs to integrate power consumption data from multiple regions and multiple users to improve performance. Existing methods mostly rely on centralized training and upload raw data to a central server, which can easily lead to privacy leakage and data security risks. Even if federated learning is used to alleviate privacy issues, the model parameter aggregation process is still vulnerable to eavesdropping or tampering attacks, and existing encryption schemes such as homomorphic encryption have too high computational and communication overheads to meet real-time requirements. Summary of the invention

[0004] In order to solve the technical problems that the existing electricity theft detection model has high computational complexity, difficulty in capturing long-distance dependencies, limited receptive field, high computational and communication overhead, and cannot realize secure mining of cross-regional data value due to privacy issues, the purpose of the present invention is to provide a smart grid federated learning electricity theft detection method based on privacy enhancement. The technical solutions adopted are as follows: Step S1: Collect user energy consumption data based on power operators, and perform preprocessing to build a local training data set; Step S2: Obtain a training model, input the local training data set into the training model in batches, and extract the temporal features and spatial features in the user energy consumption data respectively; Step S3: Based on the temporal features and spatial features, the positive and negative probabilities of the energy consumption data of all users in the corresponding batch are output, the output result is determined, the error between the output result and the actual data in the local training data set is calculated through the loss function, and the weights and biases of the training model are updated after back propagation; Step S4: input the trained weights and biases into the privacy protector, the privacy protector is used to provide the MOTP protocol to obtain an encryption vector, and the data center aggregates the encrypted vector to obtain an aggregate vector; Step S5: The power operator obtains the aggregation vector sent by the data center, obtains the decryption vector through the MOTP protocol, determines the power theft detection model, converts the decryption vector into a weight file to enter the next round of model training, and determines whether the maximum number of iterations has been reached. If not, repeat steps S2 to S4; if so, proceed to the next step; Step S6: construct a detection data set through the local training data set, input the detection data set into the electricity theft detection model to obtain the prediction result, set the screening threshold, if the prediction result is greater than the screening threshold, it means that the corresponding analyzed user is an electricity theft user, and transmit the information of the electricity theft user to the data center.

[0005] Preferably, step S1 includes: When collecting user energy consumption data, LDP technology is used to inject Gaussian noise. The corresponding calculation formula is:

[0006]

[0007] in, Indicates the output data after user energy consumption data is desensitized; Indicates user energy consumption data; represents Gaussian distribution; represents the standard deviation of Gaussian noise; It represents the global sensitivity, which is the difference between the maximum and minimum values ​​in the user's energy consumption data; represents the privacy budget; Perform data cleaning based on the output data after desensitization of user energy consumption data, and normalize the cleaned user energy consumption data; The normalized user energy consumption data is labeled to construct a local training dataset.

[0008] Preferably, data cleaning is performed based on the output data after desensitization of the user energy consumption data, and the corresponding calculation formula is:

[0009] in, Indicates that the user Daily user energy consumption data; Indicates that the user is Daily user energy consumption data; Indicates that the user is Daily user energy consumption data; Indicates a missing value; The calculation formula corresponding to the normalization process is:

[0010] in, Express The result value after normalization; Indicates the number of samples of user energy consumption data; Indicates the minimum value in the user's energy consumption data; Indicates the maximum value of the user's energy consumption data.

[0011] Preferably, step S2 includes: Input the local training data set into the training model in batches, defining the input dimension as ,in, Indicates the batch size; Indicates the number of days of user energy consumption data collected; The training model includes TCN architecture and CNN architecture. After being processed by TCN architecture, the input dimension is , and uses the dilated convolution structure to extract the time series features in the user energy consumption data; after being processed by the CNN architecture, the input dimension is , spatial features are extracted from temporal features through local perception mechanism.

[0012] Preferably, step S3 includes: After flattening the temporal features and spatial features, the positive and negative probabilities of the energy consumption data of all users in the corresponding batch are output, and the output result is defined as the data with the highest probability among the positive and negative probabilities; The error between the output result and the actual data in the local training data set is calculated through the loss function. After back propagation, the weights and biases of the training model are updated. The corresponding logical formula is:

[0013]

[0014] in, represents the updated weight; represents the weight before updating; represents the updated bias; represents the bias before updating; represents the learning rate; represents the gradient of the loss function with respect to the output result, Indicates the number of annotated labels, Indicates the output data after user energy consumption data is desensitized; Represents the inverse of the activation function; Represents the input vector.

[0015] Preferably, step S4 includes: The MOTP protocol includes MOTP encryption, MOTP aggregation and MOTP decryption; Use the MOTP encryption method to obtain the encrypted vector based on the trained weights and biases, and send it to the data center; In the data center, the encrypted vectors are aggregated using the MOTP method to obtain an aggregated vector, which is then returned to the power operator.

[0016] Preferably, the MOTP encryption method is used to obtain an encryption vector according to the trained weights and biases, including: Based on the updated weights and biases flattened into a one-dimensional vector, the corresponding calculation formula is:

[0017] in, Represents flattening to a one-dimensional vector; Quantize all elements in the one-dimensional vector into integers to obtain the quantized model vector. The corresponding calculation formula is:

[0018] in, Represents the first The integer after the quantization of the elements; Represents the first elements; Quantization factors representing powers of ten; Combined with the MOTP key, the quantized model vector is subjected to character modulo addition calculation to obtain the encrypted vector. The corresponding calculation formula is:

[0019] in, represents the encryption vector; An integer representing a one-dimensional vector quantized; Indicates the MOTP key; Represents character modulo addition.

[0020] Preferably, the encryption vector is aggregated using the MOTP aggregation method in the data center to obtain an aggregate vector, and the corresponding calculation formula is:

[0021] in, represents the aggregation vector; represents the encryption vector; Represents the number of elements in the encrypted vector; Represents character modulo addition.

[0022] Preferably, in step S5, the power operator obtains the aggregation vector sent by the data center, obtains the decryption vector through the MOTP protocol, and determines the power theft detection model, including: Calculate each character of each element in the aggregate vector, concatenate all the characters after calculation of each element into a string, and quantize it into an integer to obtain the decryption vector of the corresponding element. The corresponding calculation formula is:

[0023] in, Indicates The decryption vector of elements; Represents integer operations; Indicates concatenating characters into a string; Indicates The element characters.

[0024] The present invention has the following beneficial effects: This application adopts the TCN-CNN series architecture. The TCN (Temporal Convolutional Network) module uses dilated convolution to extract multi-scale temporal dependency features. Then, the CNN (Convolutional Neural Network) module uses dilated convolution to retain temporal coherence while modeling the spatial correlation of the power network topology with local receptive fields. The two are jointly optimized to achieve a three-dimensional representation of the power theft characteristics. Based on the distributed federated learning framework, power operators in each region deploy FedTCHN (Federated Learning - temporal convolutional hybrid network) sub-models locally, and replace the original data with encrypted interaction of model parameters. The transmission of the original data is not only realized, but also the knowledge sharing of cross-regional power theft samples is improved. At the same time, the edge node localized model training and security parameter aggregation mechanism are adopted to transmit only the encrypted model gradient update amount, which greatly reduces the cross-domain communication load, thereby reducing the communication overhead. The "LDP (Local differential privacy) technology + MOTP (modular additive one-time The dual privacy protection scheme of "modular one-time pad (modular addition one-time pad) protocol" is based on the client side. LDP is used to add noise to the user's energy consumption data to achieve desensitization of the original data. In the model aggregation stage, the MOTP mechanism is introduced. Based on the security principle of the one-time pad, character modular addition operation is used to support ciphertext addition aggregation to prevent the gradient parameters from being reversely deduced during the transmission process. The process is simple and the calculation amount is small. Compared with traditional homomorphic encryption, this protection scheme effectively reduces the communication and computing overhead in the federated learning aggregation process through the coordinated optimization of feature learning and privacy protection, ensuring the confidentiality of user data throughout the process while maintaining the model detection efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] In order to more clearly illustrate the technical solutions and advantages in the embodiments of the present invention or the prior art, the drawings required for use in the embodiments or the prior art descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0026] Figure 1 A schematic diagram of the composition structure of a smart grid federated learning electricity theft detection method based on privacy enhancement provided by an embodiment of the present invention; Figure 2An implementation flow chart of a method for detecting electricity theft in a smart grid based on federated learning with privacy enhancement provided by an embodiment of the present invention; Figure 3 A schematic diagram of a model training method for power theft detection based on smart grid federated learning based on privacy enhancement provided by an embodiment of the present invention; Figure 4 A schematic diagram of the distribution of some data before and after adding noise in a smart grid federated learning electricity theft detection method based on privacy enhancement provided by an embodiment of the present invention; Figure 5 This is a performance test diagram of a privacy-enhanced smart grid federated learning electricity theft detection method under the TCHN centralized and federated learning framework provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0027] In order to further explain the technical means and effects adopted by the present invention to achieve the predetermined invention purpose, the specific implementation method, structure, features and effects of a smart grid federated learning electricity theft detection method based on privacy enhancement proposed by the present invention are described in detail below in combination with the accompanying drawings and preferred embodiments. In the following description, different "one embodiment" or "another embodiment" does not necessarily refer to the same embodiment. In addition, specific features, structures or characteristics in one or more embodiments may be combined in any suitable form.

[0028] Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs.

[0029] The following is a specific solution of a smart grid federated learning electricity theft detection method based on privacy enhancement provided by the present invention, which is described in detail with reference to the accompanying drawings.

[0030] Please combine Figure 1-Figure 3 , which respectively show an implementation flow chart, a composition structure diagram and a model training diagram of a smart grid federated learning electricity theft detection method based on privacy enhancement provided by an embodiment of the present invention, wherein the method comprises: Step S1: Collect user energy consumption data based on power operators, and perform preprocessing to build a local training data set; Step S2: Obtain a training model, input the local training data set into the training model in batches, and extract the temporal features and spatial features in the user energy consumption data respectively; Step S3: Based on the temporal features and spatial features, the positive and negative probabilities of the energy consumption data of all users in the corresponding batch are output, the output result is determined, the error between the output result and the actual data in the local training data set is calculated through the loss function, and the weights and biases of the training model are updated after back propagation; Step S4: input the trained weights and biases into the privacy protector, the privacy protector is used to provide the MOTP protocol to obtain an encryption vector, and the data center aggregates the encrypted vector to obtain an aggregate vector; Step S5: The power operator obtains the aggregation vector sent by the data center, obtains the decryption vector through the MOTP protocol, determines the power theft detection model, converts the decryption vector into a weight file to enter the next round of model training, and determines whether the maximum number of iterations has been reached. If not, repeat steps S2 to S4; if so, proceed to the next step; Step S6: construct a detection data set through the local training data set, input the detection data set into the electricity theft detection model to obtain the prediction result, set the screening threshold, if the prediction result is greater than the screening threshold, it means that the corresponding analyzed user is an electricity theft user, and transmit the information of the electricity theft user to the data center.

[0031] To better explain, electricity theft refers to the act of illegally using electricity by various means without the consent of the power supply company, including but not limited to privately modifying the meter, bypassing the metering device, using illegal electricity theft equipment, etc.; and it poses a multi-dimensional threat to the power system. For example, illegal load access causes three-phase current imbalance, causing harmonic pollution and voltage fluctuations in the power grid, which directly affects the power supply quality; secondly, the load forecast deviation caused by electricity theft will cause inaccurate scheduling of generator sets and increase the demand for rotating reserve capacity; thirdly, illegal line connection may cause electrical fires and threaten public safety; in addition, the electricity fee gap caused by electricity theft will eventually be passed on to compliant users through the electricity price transmission mechanism, undermining the principle of market fairness; therefore, in order to avoid the occurrence of these problems, a smart grid federated learning electricity theft detection method based on privacy enhancement is proposed in this application.

[0032] Specifically, in the composition structure diagram, the privacy protector provides a privacy protection method for the data processor and model trainer. It provides LDP technology for subsequent data collection steps, adds Gaussian noise, and realizes the desensitization of the original data; provides MOTP protocol for model aggregation to realize gradient aggregation in the ciphertext state; the data processor is responsible for data collection, data cleaning and preprocessing, data annotation and data set construction, that is, building a standardized data stream processing pipeline, including data cleaning, establishing a time-power consumption mapping verification mechanism, and eliminating data missing through interpolation; feature engineering, using min-max standardization for linear normalization processing, constraining the feature value domain to the interval [0,1]; labeling and construction: relying on the power audit expert labeling system, a local training data set containing {feature vector, 0 / 1 label} is generated; the model trainer is responsible for realizing model optimization based on the federated learning framework, and through multiple rounds of "local training-ciphertext aggregation-model update" cycles until the maximum number of iterations is reached, the training model is trained to obtain the electricity theft detection model; the electricity theft detector deploys the detection architecture, loads the pre-trained model parameters to detect the pre-processed user data, that is, the historical user energy consumption data to be detected is pre-processed and input into the electricity theft detection model, and the corresponding processing measures are triggered for the detection results exceeding the screening threshold.

[0033] As an optional implementation, in this embodiment, the model trainer is jointly constructed by the regional power operator, the data center and the security center, wherein the regional power operator updates the FedTCHN model parameters based on the local data set and uploads it to the data center; the security center provides the MOTP key, and the three parties complete the electricity theft detection model aggregation through the MOTP protocol.

[0034] It can be explained that in step S1, the user energy consumption data is collected by the power operator, that is, the user energy consumption data is obtained through the smart grid. This involves the user's living habits. Once leaked or improperly used, it may cause serious privacy hazards. Therefore, it is necessary to perform privacy enhancement processing on the data.

[0035] See also Figure 4 , which shows a distribution diagram of part of the data before and after adding noise in a privacy-enhanced smart grid federated learning electricity theft detection method provided by an embodiment of the present invention; wherein, the distribution of the original data is relatively concentrated, which may make sensitive information easy to be inferred. After being processed by the LDP technology, the distribution of the differential data is relatively dispersed and uniform, thereby enhancing the privacy protection of the user's energy consumption data.

[0036] Furthermore, step S1 includes: Step S11: When collecting user energy consumption data, Gaussian noise is injected using LDP technology. The corresponding calculation formula is:

[0037]

[0038] in, Indicates the output data after user energy consumption data is desensitized; Indicates user energy consumption data; represents Gaussian distribution; represents the standard deviation of Gaussian noise; It represents the global sensitivity, which is the difference between the maximum and minimum values ​​in the user's energy consumption data; represents the privacy budget.

[0039] It is explained that during the collection of user energy consumption data, Gaussian noise is injected through LDP technology to desensitize the user energy consumption data and ensure the security of user privacy information. Even if the data is intercepted during data transmission or storage, the original user energy consumption data cannot be directly restored. The injection of Gaussian noise also enhances the robustness of the data and reduces model misjudgments caused by data anomalies or noise interference.

[0040] Step S12: performing data cleaning based on the output data after desensitization of the user energy consumption data, and normalizing the cleaned user energy consumption data; Furthermore, data cleaning is performed based on the output data after desensitization of the user energy consumption data. The corresponding calculation formula is:

[0041] in, Indicates that the user is Daily user energy consumption data; Indicates that the user is Daily user energy consumption data; Indicates that the user is Daily user energy consumption data; Indicates a missing value; It is explained that data cleaning includes processing missing values, abnormal values ​​and duplicate values, that is, data cleaning is performed on the desensitized user energy consumption data to make the data consistent without any residual sensitive information. Among them, a missing value means that due to a malfunction, the user energy consumption data of a certain user on a certain day was not collected correctly, resulting in a gap or anomaly.

[0042] The calculation formula corresponding to the normalization process is:

[0043] in, Express The result value after normalization; Indicates the number of samples of user energy consumption data; Indicates the minimum value in the user's energy consumption data; Indicates the maximum value of the user's energy consumption data.

[0044] To illustrate, in this embodiment, the The normalization method scales the user energy consumption data to 0-1 to improve the stability of the data used for subsequent model training.

[0045] Step S13: construct a local training data set by annotating the normalized user energy consumption data.

[0046] Specifically, the power audit expert annotation system is used to annotate the features of the detected user energy consumption data, and a local training data set containing {feature vector, 0 / 1 label} is generated, which is recorded as ,in, Indicates the corresponding user Daily user energy consumption data; Indicates the annotation label of the corresponding user.

[0047] Furthermore, step S2 includes: Step S21: Input the local training data set into the training model in batches, defining the input dimension as ,in, Indicates the batch size; Indicates the number of days of user energy consumption data collected; Step S22: The training model includes the TCN architecture and the CNN architecture. After being processed by the TCN architecture, the input dimension is , and uses the dilated convolution structure to extract the time series features in the user energy consumption data; after being processed by the CNN architecture, the input dimension is , spatial features are extracted from temporal features through local perception mechanism.

[0048] It can be explained that, in this embodiment, the training model is a global model, namely the FedTCHN model, including a TCN architecture and a CNN architecture; before the training model starts training, the data center initializes the parameters of the global model and sends it to all power operators who need to participate in the training. After receiving it, the power operator uses the global model as a local model, namely, the training model in step S2 for training.

[0049] Preferably, the batch size refers to the number of data samples processed by the training model during a training process; in this embodiment, the batch size is 64, that is, 64 user energy consumption data are input into the training each time; wherein, the number of days of statistically collected user energy consumption data can obtain the time span covered by the local training data set.

[0050] Step S22: The training model includes the TCN architecture and the CNN architecture. After being processed by the TCN architecture, the input dimension is , and uses the dilated convolution structure to extract the time series features in the user energy consumption data; after being processed by the CNN architecture, the input dimension is , spatial features are extracted from temporal features through local perception mechanism.

[0051] It is explained that the dilated convolution expands the receptive field of the convolution kernel by inserting holes inside the convolution kernel, that is, inserting a fixed number of zero weights between adjacent weights of the convolution kernel to expand the effective receptive field of the convolution kernel, effectively extracting the time series features in the user energy consumption data, so as to understand the pattern of user energy consumption data changing over time; the CNN architecture uses a local perception mechanism, that is, in time series data, the convolution kernel can slide on the time axis, perform element-by-element multiplication and addition operations with the corresponding local area, and extract local features from the input data through multi-layer convolution to assist the training model in capturing the local correlation of user energy consumption data at different time points. Through the combined use of these two architectures, the training model can more comprehensively understand and learn the complex characteristics of user energy consumption data.

[0052] Furthermore, step S3 includes: Step S31: flatten the temporal features and spatial features, and output the positive and negative probabilities of the energy consumption data of all users in the corresponding batch, and define the output result as the data with the highest probability among the positive and negative probabilities; Specifically, the temporal features and spatial features are flattened, that is, the data representing the two features are converted from a multidimensional data structure to a one-dimensional data structure, and calculations are performed to obtain the positive and negative class probabilities corresponding to each data, and the one with the largest probability value is selected as the output result.

[0053] Step S32: Calculate the error between the output result and the actual data in the local training data set through the loss function, and update the weight and bias of the training model after back propagation. The corresponding logical formula is:

[0054]

[0055] in, represents the updated weight; represents the weight before updating; represents the updated bias; represents the bias before updating; represents the learning rate; represents the gradient of the loss function with respect to the output result, Indicates the number of annotated labels, Indicates the output data after user energy consumption data is desensitized; Represents the inverse of the activation function; Represents the input vector.

[0056] Specifically, the loss function is used to measure the difference between the output result and the actual data in the local training data set, and then the back propagation algorithm is used to update the weights and biases of the training model, that is, the weights of the training model are adjusted according to the calculated error to reduce the error caused to the output result, which can improve the accuracy and performance of the training model; it can be explained that the parameters of the training model, that is, the FedTCHN model, are updated through the local training data set to perform localized training on user energy consumption data.

[0057] Furthermore, step S4 includes: The MOTP protocol includes MOTP encryption, MOTP aggregation, and MOTP decryption.

[0058] It can be explained that the weights and biases after training, that is, the weights and biases after being updated by the local training data set, are input into the privacy protector. The privacy protector provides the MOTP protocol for training model aggregation, providing a secure aggregation process for the training model to ensure the privacy of user energy consumption data; the protocol includes MOTP encryption to ensure the security of user energy consumption data during transmission; MOTP aggregation allows multiple data sets to be effectively aggregated without leaking individual data; MOTP decryption allows the aggregated data to be securely decrypted for subsequent analysis.

[0059] Step S41: Use the MOTP encryption method to obtain an encrypted vector based on the trained weights and biases, and send it to the data center.

[0060] Understandably, what is transmitted based on federated learning is the parameters of the training model rather than the original user energy consumption data. However, attackers can use the parameters related to the training model to reversely deduce the original user energy consumption data. To avoid this problem, the relevant parameters of the training model after training are processed using the MOTP protocol to improve the privacy of the user energy consumption data. Among them, the encryption vector can effectively prevent the model parameters after training from being intercepted or tampered with during the transmission process to ensure the security of the entire training model.

[0061] Furthermore, step S41 includes: Step S411: Flatten the updated weights and biases into a one-dimensional vector. The corresponding calculation formula is:

[0062] in, Represents flattening to a one-dimensional vector; Step S412: quantize all elements in the one-dimensional vector into integers to obtain a quantized model vector. The corresponding calculation formula is:

[0063] in, Represents the first The integer after the quantization of the elements; Represents the first elements; Quantization factors representing powers of ten; Step S413: Perform character modulo addition calculation on the quantized model vector in combination with the MOTP key to obtain an encrypted vector. The corresponding calculation formula is:

[0064] in, represents the encryption vector; An integer representing a one-dimensional vector quantized; Indicates the MOTP key; Represents character modulo addition.

[0065] Specifically, first, the weights after training are and bias All elements in are flattened into one-dimensional vectors, denoted as , Represents the number of elements in a one-dimensional vector; then the one-dimensional vector All elements in are quantized to integers, and the quantized model vector is obtained. ; Among them, the MOTP key is ; Quantize the model vector Perform character modulo addition calculation with the MOTP key to obtain the encryption vector .

[0066] Preferably, in this embodiment, after the character modulo addition calculation, the parameter carry vector can also be obtained. , the corresponding logic formula is:

[0067]

[0068] in, Indicates character modulo addition and carry calculation.

[0069] Understandably, the computational approach used to target and Calculate any character of any element in , obtain the encryption vector and parameter carry vector of the corresponding character of the corresponding element in turn, and then integrate all the obtained encryption vectors to obtain the encryption vector and parameter carry vector of the entire model parameter. The corresponding calculation formula is:

[0070]

[0071] in, Indicates The element Encryption vector of characters; Indicates The element Character parameter carry vector; Indicates converting data into characters; Indicates the ASCII value (American Standard Code for Information Interchange) corresponding to the character; Indicates The element Quantized model vector of characters; Indicates The element MOTP key of characters; Represents modulo operation; Represents the modulus; Represents an integer division operation.

[0072] To illustrate, in this embodiment, the encryption vector obtained according to step S41 is expressed as .

[0073] Step S42: In the data center, the encrypted vectors are aggregated using the MOTP aggregation method to obtain an aggregated vector, and the aggregated vector is returned to the power operator.

[0074] It can be explained that the aggregation vector refers to aggregating the information of multiple encryption vectors into a single vector, which is conducive to data transmission.

[0075] Furthermore, the MOTP aggregation method is used to aggregate the encryption vectors in the data center to obtain an aggregate vector. The corresponding calculation formula is:

[0076] in, represents the aggregation vector; represents the encryption vector; Represents the number of elements in the encrypted vector; Represents character modulo addition.

[0077] Specifically, for the encryption vector obtained above Get the aggregation vector and aggregate carry vector , combined with the parameter carry vector Get parameter carry and vector , the corresponding calculation formula is:

[0078]

[0079] in, Indicates character addition operation; Indicates the number of elements involved in the calculation in the corresponding encrypted vector.

[0080] It can be understood that since the parameter carry vector contains multiple elements corresponding to multiple characters, the parameter carry vector of any character of any element is calculated and integrated to obtain the parameter carry and vector , the corresponding calculation formula is:

[0081] in, Indicates converting the parameter carry vector corresponding to the character into an integer.

[0082] To illustrate, in this embodiment, the aggregation vector obtained according to step S42 is expressed as .

[0083] Furthermore, in step S5, the power operator obtains the aggregation vector sent by the data center, obtains the decryption vector through the MOTP protocol, and determines the power theft detection model, including: Calculate each character of each element in the aggregate vector, concatenate all the characters after calculation of each element into a string, and quantize it into an integer to obtain the decryption vector of the corresponding element. The corresponding calculation formula is:

[0084] in, Indicates The decryption vector of elements; Represents integer operations; Indicates concatenating characters into a string; Indicates The element characters.

[0085] Specifically, the calculation is still performed for any character of any element, and the corresponding calculation formula is:

[0086] in, Indicates the number of days of user energy consumption data collected; It represents the user's annotation label in the local training data set; then all the decryption vectors obtained by calculation are integrated to obtain the decryption vector; and then the training model processed by the MOTP protocol is the electricity theft detection model.

[0087] To illustrate, in this embodiment, the decryption vector obtained according to step S5 is expressed as .

[0088] It can be understood that the weights and biases after training are input into the privacy protector, and the privacy protector securely encrypts the parameters through the MOTP encryption method to obtain an encrypted vector, and transmits the encrypted vector to the data center, ensuring the security and privacy of the data during transmission; the data center uses the MOTP aggregation method to aggregate the parameters according to the encrypted vector to determine the aggregated vector, that is, the parameter vector that can represent the common information of all power operators participating in the training without leaking any single power operator, and returns the aggregated vector to each power operator; the decrypted vector is obtained through the MOTP decryption method, and then the power theft detection model is determined, which can not only effectively prevent power theft, but also ensure data security and privacy protection throughout the process; then the original tensor format of the updated training model parameters is converted into a parameter file for model training, and it is determined whether the maximum number of iterations is reached. If not, repeat steps S2~S4; if so, execute the next step, that is, step S6; specifically, a maximum number of iterations of the training model is given in advance, and the training model processed by the privacy protector and the model trainer is processed according to whether the maximum number of iterations is reached.

[0089] Furthermore, in step S6, a detection dataset is constructed using the local training dataset, denoted as ,in, Represents the elements of the detection dataset; Indicates the number of elements in the detection dataset; Represents the number of days of user energy consumption data collected; the detection data set is input into the electricity theft detection model to obtain the prediction result, which is recorded as ,in, Indicates that the prediction result corresponds to the element in the test data set; set the screening threshold If the prediction result is greater than the screening threshold, it means that the corresponding analyzed user is an electricity theft user, and the information of the electricity theft user is transmitted to the data center; on the contrary, if the prediction result is less than the screening threshold, it means that the current corresponding analyzed user is a normal user, and then continue to operate normally.

[0090] As an optional implementation method, for a privacy-enhanced smart grid federated learning electricity theft detection method proposed in this application, in order to verify its feasibility, an application example is conducted: 5 regional power operators are provided to be responsible for user management in their respective areas, and the user energy consumption data of each area cannot be directly shared, and each has only a small number of electricity theft user samples; therefore, in order to more effectively detect electricity theft users, the power operator, the data center, and the security center jointly form a federated learning network, and use the detection method proposed in this application to jointly train an electricity theft detection model, which does not need to share the user's original user energy consumption data. The power operators in each region can directly access the user's energy consumption data, and the electricity theft detection model parameters are interacted through the MOTP protocol, and only the power operators in each region can know their true model parameters.

[0091] Specifically, the user energy consumption data collected by the power operators in these five regions through the smart grid are implemented in steps S1-S6, wherein when the user energy consumption data is cleaned, the missing values ​​are filled. Since the collected user energy consumption data has all-zero rows, that is, the user energy consumption data between some rows are all zero, and the user energy consumption data to be analyzed subsequently contains positive labels and negative labels, the user energy consumption data of all zero rows are deleted to ensure the quality of the user energy consumption data, and then the subsequent data processing is performed to ensure the accuracy of the determination result of the electricity theft detection model; then the accuracy rate and the area under the curve are used as performance evaluation indicators to judge the reliability of the electricity theft detection model provided in this application for detecting electricity theft users.

[0092] It can be explained that the accuracy (ACC) represents the percentage of correctly classified energy consumption data of users, and the corresponding calculation formula is:

[0093] in, Indicates the number of positive classes predicted as positive; Indicates the number of negative classes predicted as negative classes; Indicates the number of negative classes predicted as positive classes; Indicates the number of positive classes predicted as negative classes. The higher the ACC value, the better the electricity theft detection model performs in correctly predicting electricity theft behavior.

[0094] Due to the imbalance of positive and negative samples in user energy consumption data, the area under the curve (AUC) is introduced as an evaluation indicator. Compared with a single accuracy rate, AUC is more adaptable to data sets with a serious imbalance in the ratio of positive and negative samples, so as to enhance the reliability of accurate evaluation. The value range of AUC is between 0 and 1. A value close to 1 indicates that the electricity theft detection model has a stronger ability to identify electricity theft users. Otherwise, the recognition ability is poor.

[0095] See also Figure 5 , which shows a performance test diagram of a privacy-enhanced smart grid federated learning electricity theft detection method under the TCHN centralized and federated learning framework provided by an embodiment of the present invention, that is, the TCHN model, that is, the electricity theft detection model is tested on the test data set, including centralized training and federated training, that is, the effect comparison is carried out according to the systems established by the five power operators provided, wherein the left figure represents the performance evaluation index performance obtained based on ACC; the right figure represents the performance evaluation index performance obtained based on AUC.

[0096] It can be shown that centralized training performs better in terms of the performance evaluation indicators of ACC and AUC, can reach a higher performance level faster, and is suitable for scenarios where data and computing resources are concentrated; distributed training, that is, based on federated learning, is slightly lower than centralized training in performance, but its performance is still very good, especially after the number of aggregation rounds increases, the performance gradually approaches that of centralized training; and distributed training has significant advantages in data privacy protection, distributed computing efficiency, robustness and scalability.

[0097] For better explanation, a test data set is constructed based on user energy consumption data provided by five power operators for testing, and compared with the homomorphic encryption provided by the existing method, and Table 1 is obtained, which is specifically expressed as follows: Table 1 Comparison of model aggregation schemes

[0098] It can be understood that the size of the electricity theft detection model after MOTP encryption is significantly smaller than the homomorphic encryption model, so the communication overhead consumed is also lower; and the total calculation time of MOTP is significantly lower than that of homomorphic encryption, indicating that the MOTP scheme is also better than homomorphic encryption in terms of computational overhead. Therefore, the MOTP protocol is better than the traditional homomorphic encryption scheme in overall performance, indicating that the privacy-enhanced smart grid federated learning electricity theft detection method proposed in this application is highly feasible.

[0099] It should be noted that the sequence of the above embodiments of the present invention is for description only and does not represent the advantages and disadvantages of the embodiments. The processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0100] The various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referenced to each other, and each embodiment focuses on the differences from other embodiments.

Claims

1. A smart grid federated learning electricity theft detection method based on privacy enhancement, characterized in that: The method comprises: Step S1: Collect user energy consumption data based on power operators, and perform preprocessing to build a local training data set; Step S2: Obtain a training model, input the local training data set into the training model in batches, and extract the temporal features and spatial features in the user energy consumption data respectively; Step S3: Based on the temporal features and spatial features, the positive and negative probabilities of the energy consumption data of all users in the corresponding batch are output, the output result is determined, the error between the output result and the actual data in the local training data set is calculated through the loss function, and the weights and biases of the training model are updated after back propagation; Step S4: input the trained weights and biases into the privacy protector, the privacy protector is used to provide the MOTP protocol to obtain an encryption vector, and the data center aggregates the encrypted vector to obtain an aggregate vector; Step S5: The power operator obtains the aggregation vector sent by the data center, obtains the decryption vector through the MOTP protocol, determines the power theft detection model, converts the decryption vector into a weight file to enter the next round of model training, and determines whether the maximum number of iterations has been reached. If not, repeat steps S2 to S4; if so, proceed to the next step; Step S6: construct a detection data set through the local training data set, input the detection data set into the electricity theft detection model to obtain the prediction result, set the screening threshold, if the prediction result is greater than the screening threshold, it means that the corresponding analyzed user is an electricity theft user, and transmit the information of the electricity theft user to the data center.

2. According to the privacy-enhanced smart grid federated learning electricity theft detection method according to claim 1, it is characterized in that: Step S1 includes: When collecting user energy consumption data, LDP technology is used to inject Gaussian noise. The corresponding calculation formula is: ; ; in, Indicates the output data after user energy consumption data is desensitized; Indicates user energy consumption data; represents Gaussian distribution; represents the standard deviation of Gaussian noise; It represents the global sensitivity, which is the difference between the maximum and minimum values ​​in the user's energy consumption data; represents the privacy budget; Perform data cleaning based on the output data after desensitization of user energy consumption data, and normalize the cleaned user energy consumption data; The normalized user energy consumption data is labeled to construct a local training dataset.

3. According to the privacy-enhanced smart grid federated learning electricity theft detection method according to claim 2, it is characterized in that: Data cleaning is performed based on the output data after desensitization of user energy consumption data. The corresponding calculation formula is: ; in, Indicates that the user is Daily user energy consumption data; Indicates that the user is Daily user energy consumption data; Indicates that the user is Daily user energy consumption data; Indicates a missing value; The calculation formula corresponding to the normalization process is: ; in, Express The result value after normalization; Indicates the number of samples of user energy consumption data; Indicates the minimum value in the user's energy consumption data; Indicates the maximum value of the user's energy consumption data.

4. According to the privacy-enhanced smart grid federated learning electricity theft detection method according to claim 1, it is characterized in that: Step S2 includes: Input the local training data set into the training model in batches, defining the input dimension as ,in, Indicates the batch size; Indicates the number of days of user energy consumption data collected; The training model includes TCN architecture and CNN architecture. After being processed by TCN architecture, the input dimension is , and uses the dilated convolution structure to extract the time series features in the user energy consumption data; after being processed by the CNN architecture, the input dimension is , spatial features are extracted from temporal features through local perception mechanism.

5. According to the privacy-enhanced smart grid federated learning electricity theft detection method according to claim 2, it is characterized in that: Step S3 includes: After flattening the temporal features and spatial features, the positive and negative probabilities of the energy consumption data of all users in the corresponding batch are output, and the output result is defined as the data with the highest probability among the positive and negative probabilities; The error between the output result and the actual data in the local training data set is calculated through the loss function. After back propagation, the weights and biases of the training model are updated. The corresponding logical formula is: ; ; in, represents the updated weight; represents the weight before updating; represents the updated bias; represents the bias before updating; represents the learning rate; represents the gradient of the loss function with respect to the output result, Indicates the number of annotated labels, Indicates the output data after user energy consumption data is desensitized; Represents the inverse of the activation function; Represents the input vector.

6. The method for detecting electricity theft in smart grid federated learning based on privacy enhancement according to claim 5 is characterized in that: Step S4 includes: The MOTP protocol includes MOTP encryption, MOTP aggregation and MOTP decryption; Use the MOTP encryption method to obtain the encrypted vector based on the trained weights and biases, and send it to the data center; In the data center, the encrypted vectors are aggregated using the MOTP method to obtain an aggregated vector, which is then returned to the power operator.

7. The method for detecting electricity theft in a smart grid based on federated learning with privacy enhancement according to claim 6 is characterized in that: The MOTP encryption method is used to obtain the encrypted vector based on the trained weights and biases, including: Based on the updated weights and biases flattened into a one-dimensional vector, the corresponding calculation formula is: ; in, Represents flattening to a one-dimensional vector; Quantize all elements in the one-dimensional vector into integers to obtain the quantized model vector. The corresponding calculation formula is: ; in, Represents the first The integer after the elements are quantized; Represents the first elements; Quantization factors representing powers of ten; Combined with the MOTP key, the quantized model vector is subjected to character modulo addition calculation to obtain the encrypted vector. The corresponding calculation formula is: ; in, represents the encryption vector; An integer representing a one-dimensional vector after quantization; Indicates the MOTP key; Represents character modulo addition.

8. The method for detecting electricity theft in a smart grid based on federated learning with privacy enhancement according to claim 6 is characterized in that: In the data center, the encryption vector is aggregated using the MOTP aggregation method to obtain the aggregation vector. The corresponding calculation formula is: ; in, represents the aggregation vector; represents the encryption vector; Represents the number of elements in the encrypted vector; Represents character modulo addition.

9. The method for detecting electricity theft in a smart grid based on federated learning with privacy enhancement according to claim 6 is characterized in that: In step S5, the power operator obtains the aggregation vector sent by the data center, obtains the decryption vector through the MOTP protocol, and determines the power theft detection model, including: Calculate each character of each element in the aggregate vector, concatenate all the characters after calculation of each element into a string, and quantize it into an integer to obtain the decryption vector of the corresponding element. The corresponding calculation formula is: ; in, Indicates The decryption vector of elements; Represents integer operations; Indicates concatenating characters into a string; Indicates The first element characters.

Citation Information

Patent Citations

  • Precise electric power theft detection method based on multi-modal Mama

    CN119475245A

  • Transverse federal learning electricity larceny detection method, system and equipment and medium

    CN119720270A

Cited By

  • Mine water storage pressure prediction method based on deep learning

    CN120278236A