A Power Theft Detection Method for Smart Grid Federated Learning Based on Privacy Enhancement

By adopting federated learning method and MOTP protocol in the smart grid, combining time convolutional networks and convolutional neural networks to extract user energy consumption data characteristics, the problems of calculation complexity and privacy protection of the power theft detection model are solved, and efficient power theft detection and cross-regional data privacy protection are achieved.

CN119919158BActive Publication Date: 2025-06-10NANJING UNIV OF POSTS & TELECOMM
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510397520.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-04-01
Publication Date
2025-06-10
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

The smart grid federated learning method based on privacy enhancement is adopted to extract the timing and spatial features of user energy consumption data through the time convolution network and the convolution neural network architecture, combine the local training data set and the global model for model training, and the model parameter encryption interaction is carried out through the MOTP protocol to achieve knowledge sharing and model generalization capabilities of cross-regional power stolen samples.

Benefits of technology

It realizes the three-dimensional performance of power stolen features, reduces cross-domain communication load, improves the generalization ability of the model, and ensures the privacy and security of user data through the dual privacy protection scheme of local differential privacy and MOTP protocol.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119919158B_ABST
    Figure CN119919158B_ABST
Patent Text Reader

Abstract

The present invention relates to the technical field of electricity theft detection, and specifically relates to an electricity theft detection method for smart grid federated learning based on privacy enhancement, including: Step S1: Collect user energy consumption data to construct a local training data set; Step S2: Input the local training data set into the training model in batches to extract temporal features and spatial features; Step S3: Determine the output result and update the weights and biases of the training model; Step S4: Input the weights and biases after training into the privacy protector to determine the encrypted vector, and obtain the aggregated vector through the data center; Step S5: Obtain the decrypted vector through the aggregated vector, determine the electricity theft detection model, and judge whether the maximum number of iterations is reached. If not, repeat Steps S2 to S4; if so, execute the next step; Step S6: If the prediction result is greater than the screening threshold, it indicates that the corresponding analyzed user is an electricity theft user, and transmit the information of the electricity theft user to the 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 particularly relates to an electricity theft detection method for smart grid federated learning based on privacy enhancement. Background Art

[0002] The rapid development of the smart grid has brought about the wide application of smart devices, providing data support for the management of the power system. However, the increase in data traffic has also brought challenges, especially in protecting user privacy while there is still electricity theft behavior. In practical applications, electricity theft not only causes economic losses, but may also disrupt energy production and distribution, posing multi-dimensional threats to the power system, including grid harmonic pollution, voltage fluctuations, load prediction deviations, generator unit scheduling inaccuracies, electrical fire risks, and undermining market fairness. Therefore, live detection is crucial for the stable operation of the power system and the efficiency of energy management. Thus, how to efficiently utilize energy consumption data for live detection has become the key.

[0003] In recent years, deep learning methods, such as recurrent neural network RNN (Recurrent Neural Networks), long short-term memory network LSTM (Long Short-Term Memory), and one-dimensional convolutional neural network CNN (Convolutional Neural Network), etc., have been introduced into the field of electricity theft detection to improve the recognition ability of complex electricity consumption patterns. However, these existing deep learning methods still have significant defects in practical applications: (1) Although RNN and LSTM can process time series data, they have high computational complexity and are vulnerable to the problem of gradient disappearance, making it difficult to efficiently capture long-distance dependence relationships. While the traditional one-dimensional CNN has relatively high computational efficiency, due to its limited receptive field, it is difficult to fully mine multi-scale time series features in electricity consumption data. As a result, the existing models have insufficient detection accuracy and generalization ability when facing non-linear and high-noise electricity theft behaviors; (2) The electricity data contains sensitive information such as users' electricity consumption habits and behavior patterns. Directly sharing these data will bring serious privacy leakage risks. Therefore, it is often difficult to directly share the electricity data in different regions, which greatly limits the cross-regional utilization and analysis of data and hinders the performance improvement of the electricity theft detection model; (3) Although the direct sharing of electricity data is restricted due to privacy issues, with the popularization of distributed energy systems, live detection still needs to integrate the electricity consumption data of multiple regions and multiple users to improve performance. Existing methods mostly rely on centralized training, uploading the original data to the central server, which is prone to privacy leakage and data security risks. Even if federated learning is used to alleviate privacy problems, 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 and are difficult to meet real-time requirements. Summary of the Invention

[0004] To solve the technical problems of the existing electricity theft detection model, such as high computational complexity, difficulty in capturing long-distance dependencies, limited receptive fields, high computational and communication overheads, and inability to securely mine the data value across regions due to privacy issues, the purpose of the present invention is to provide a privacy-enhanced federated learning electricity theft detection method for smart grids. The specific technical solutions adopted are as follows:

[0005] Step S1: Based on the electricity operator, collect user energy consumption data and preprocess it to construct a local training dataset;

[0006] Step S2: Obtain a training model, where the training model is a global model, including a temporal convolutional network architecture and a convolutional neural network architecture. Input the local training dataset into the training model in batches, and extract the temporal features and spatial features in the user energy consumption data respectively;

[0007] Step S3: Based on the temporal features and spatial features, output the positive and negative class probabilities of all user energy consumption data in the corresponding batch, determine the output result, calculate the error between the output result and the actual data in the local training dataset through a loss function, and update the weights and biases of the training model after backpropagation;

[0008] Step S4: Input the trained weights and biases into a privacy protector, where the privacy protector is used to provide the MOTP protocol to obtain an encrypted vector, and the data center aggregates the encrypted vectors to obtain an aggregated vector;

[0009] Step S5: The electricity operator obtains the aggregated vector sent by the data center, and obtains a decrypted vector through the MOTP protocol, determines the electricity theft detection model, converts the decrypted vector into a weight file to enter the next round of model training, and determines whether the maximum number of iterations is reached. If not, repeat steps S2 - S4; if so, execute the next step;

[0010] Step S6: Construct a detection dataset through the local training dataset, input the detection dataset into the electricity theft detection model to obtain a prediction result, set a screening threshold. If the prediction result is greater than the screening threshold, it indicates that the corresponding analyzed user is an electricity theft user, and transmit the information of the electricity theft user to the data center.

[0011] Preferably, in step S1, it includes:

[0012] When collecting user energy consumption data, use the LDP technology to inject Gaussian noise, and the corresponding calculation formula is:

[0013] y = x + N(0,σ 2 )

[0014]

[0015] Among them, y represents the output data after the desensitization of the user energy consumption data; x represents the user energy consumption data; N represents the Gaussian distribution; σ represents the standard deviation of the Gaussian noise; Δf represents the global sensitivity, that is, the difference between the maximum value and the minimum value in the user energy consumption data; ε represents the privacy budget;

[0016] Perform data cleaning based on the output data after the desensitization of the user energy consumption data, and perform normalization processing on the cleaned user energy consumption data;

[0017] Construct a local training dataset through annotation for the normalized user energy consumption data.

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

[0019]

[0020] Among them, x i represents the user energy consumption data of the user on the i-th day; x i-1 represents the user energy consumption data of the user on the (i - 1)-th day; x i+1 represents the user energy consumption data of the user on the (i + 1)-th day; NaN represents a missing value;

[0021] The corresponding calculation formula for normalization processing is:

[0022]

[0023] Among them, Z i represents the result value after the normalization processing of x i ; n represents the sample number of the user energy consumption data; min represents the minimum value in the user energy consumption data; max represents the maximum value in the user energy consumption data.

[0024] Preferably, in step S2, it includes:

[0025] Input the local training dataset into the training model in batches, and define the input dimension as [b, 1, n], where b represents the batch size; n represents the number of days of the collected user energy consumption data;

[0026] After being processed by the time convolutional network architecture, the input dimension is [b, 128, n], and the dilated convolutional structure is used to extract the temporal features in the user energy consumption data; after being processed by the convolutional neural network architecture, the input dimension is [b, 16, n], and the local perception mechanism is used to extract the spatial features from the temporal features.

[0027] Preferably, in step S3, it includes:

[0028] After flattening the temporal features and spatial features, the positive and negative class 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 largest probability among the positive and negative class probabilities;

[0029] Calculate the error between the output result and the actual data in the local training dataset through the loss function, and update the weights and biases of the training model after backpropagation. The corresponding logical formula is:

[0030]

[0031] where, W lo represents the updated weight; represents the weight before update; b lo represents the updated bias; represents the bias before update; η represents the learning rate; represents the gradient of the loss function with respect to the output result, L represents the number of labeled labels, y represents the output data after desensitization of the user energy consumption data; f ′ represents the reciprocal of the activation function; x represents the input vector.

[0032] Preferably, in step S4, it includes:

[0033] The MOTP protocol includes MOTP encryption, MOTP aggregation, and MOTP decryption;

[0034] Use the MOTP encryption method to obtain an encrypted vector based on the weights and biases after training is completed, and send it to the data center;

[0035] Use the MOTP aggregation method in the data center to obtain an aggregated vector from the encrypted vector, and return the aggregated vector to the power operator.

[0036] Preferably, using the MOTP encryption method to obtain an encrypted vector based on the weights and biases after training is completed, includes:

[0037] Flatten the updated weights and biases into a one-dimensional vector, and the corresponding calculation formula is:

[0038] w lo =[fl(W lo ),fl(b lo )]

[0039] where, fl represents flattening into a one-dimensional vector;

[0040] Quantize all elements in the one-dimensional vector into integers to obtain a quantized model vector, and the corresponding calculation formula is:

[0041]

[0042] where, Represents the integer after quantization of the \(i\)-th element in a one-dimensional vector; Represents the \(i\)-th element in a one-dimensional vector; \(Q\) represents the quantization factor of a power of ten;

[0043] Perform character modulo addition calculation on the quantization model vector in combination with the MOTP key to obtain the encrypted vector. The corresponding calculation formula is:

[0044]

[0045] Among them, Represents the encrypted vector; Represents the integer after quantization of the one-dimensional vector; \(\beta\) lo Represents the MOTP key; Represents the character modulo addition operation.

[0046] Preferably, in the data center, use the MOTP aggregation method for the encrypted vector to obtain the aggregated vector. The corresponding calculation formula is:

[0047]

[0048] Among them, Represents the aggregated vector; Represents the encrypted vector; \(t\) represents the number of elements in the encrypted vector; Represents the character modulo addition operation.

[0049] Preferably, in step S5, the power operator obtains the aggregated vector sent by the data center and obtains the decrypted vector through the MOTP protocol to determine the electricity theft detection model, including:

[0050] Calculate based on each character of each element in the aggregated vector, splice all the characters after calculation of each element into a string, and quantize it into an integer to obtain the decrypted vector corresponding to the element. The corresponding calculation formula is:

[0051]

[0052] Among them, Represents the decrypted vector of the \(i\)-th element; int represents integer operation; join represents splicing characters into a string; Represents the \(o\)-th character of the \(i\)-th element.

[0053] The present invention has the following beneficial effects:

[0054] This application adopts a TCN-CNN tandem architecture. The TCN (Temporal Convolutional Network) module uses dilated convolution to extract multi-scale temporal dependence features. Subsequently, the CNN (Convolutional Neural Network) module uses atrous convolution to model the spatial correlation of the power grid topology with a local receptive field while retaining temporal coherence. The joint optimization of the two realizes the three-dimensional representation of electricity theft features. Based on the distributed federated learning framework, each regional power operator deploys a FedTCHN (Federated Learning-temporal convolutional hybrid network) sub-model locally. By encrypting and interacting with model parameters to replace the centralized transmission of original data, it not only realizes the knowledge sharing of cross-regional electricity theft samples and improves the generalization ability of the model. At the same time, by adopting the edge node local model training and secure parameter aggregation mechanism, only the encrypted model gradient updates are transmitted, greatly reducing the cross-domain communication load and thus reducing the communication overhead. A dual privacy protection scheme of "LDP (Local differential privacy) technology + MOTP (modular additive one-time pad) protocol" is proposed. On the client side, LDP is used to add noise to user energy consumption data to desensitize 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 operations are used to support ciphertext addition aggregation, preventing the reverse derivation of gradient parameters during transmission. The process is simple and has a small computational cost. This protection scheme, compared with traditional homomorphic encryption, effectively reduces the communication and computational overhead in the federated learning aggregation process through the collaborative optimization of feature learning and privacy protection, while ensuring the confidentiality of user data throughout the process and maintaining the model detection efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0055] To more clearly illustrate the technical solutions and advantages in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0056] Figure 1 It is a flowchart of the implementation of a method for detecting electricity theft in a smart grid federated learning based on privacy enhancement provided by an embodiment of the present invention;

[0057] Figure 2Schematic diagram of the composition structure of a power theft detection method based on privacy-enhanced federated learning for smart grid provided by an embodiment of the present invention;

[0058] Figure 3 Schematic diagram of model training of a power theft detection method based on privacy-enhanced federated learning for smart grid provided by an embodiment of the present invention;

[0059] Figure 4 Schematic diagram of the distribution of some data before and after adding noise in a power theft detection method based on privacy-enhanced federated learning for smart grid provided by an embodiment of the present invention;

[0060] Figure 5 Performance test chart of TCHN centralized and federated learning frameworks in a power theft detection method based on privacy-enhanced federated learning for smart grid provided by an embodiment of the present invention. Detailed implementation manners

[0061] In order to further elaborate on the technical means and effects adopted by the present invention to achieve the predetermined invention purpose, the following combines the accompanying drawings and preferred embodiments to elaborate in detail on a power theft detection method based on privacy-enhanced federated learning for smart grid proposed by the present invention, its specific implementation manners, structures, features and effects. In the following description, different "one embodiment" or "another embodiment" do not necessarily refer to the same embodiment. In addition, the specific features, structures or characteristics in one or more embodiments can be combined in any suitable form.

[0062] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the technical field to which the present invention belongs.

[0063] The following specifically describes the specific solution of a power theft detection method based on privacy-enhanced federated learning for smart grid provided by the present invention with reference to the accompanying drawings.

[0064] Please refer to Figures 1 - 3 , which respectively show the implementation flowchart, composition structure schematic diagram and model training schematic diagram of a power theft detection method based on privacy-enhanced federated learning for smart grid provided by an embodiment of the present invention. The method includes:

[0065] Step S1: Collect user energy consumption data based on power operators and preprocess it to construct a local training data set;

[0066] Step S2: Obtain a training model. The training model is a global model, including a temporal convolutional network architecture and a convolutional neural network architecture. 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;

[0067] 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;

[0068] 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;

[0069] 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;

[0070] 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.

[0071] 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.

[0072] Specifically, in the composition structure diagram, the privacy protector provides privacy protection methods for the data processor and the model trainer. It provides the LDP technology for the subsequent data collection step, adds Gaussian noise to desensitize the original data; provides the MOTP protocol for model aggregation to achieve gradient aggregation in the ciphertext state. The data processor is responsible for data collection, data cleaning and preprocessing, data annotation and dataset construction, that is, constructing a standardized data stream processing pipeline, including data cleaning, establishing a time-electricity consumption mapping verification mechanism, and eliminating data missing through interpolation; feature engineering, using min-max standardization for linear normalization processing to constrain the feature value range to the [0,1] interval; annotation and construction: relying on the power audit expert annotation system to generate a local training dataset containing {feature vector, 0 / 1 label}. The model trainer is responsible for optimizing the model based on the federated learning framework. Through multiple rounds of "local training-ciphertext aggregation-model update" cycles until the maximum number of iterations is reached, the training of the trained model is realized to obtain the electricity theft detection model. The electricity theft detector deploys a detection architecture and loads the pre-trained model parameters to detect the preprocessed user data, that is, inputs the preprocessed historical user energy consumption data to be detected into the electricity theft detection model, and triggers corresponding processing measures for the detection results exceeding the screening threshold.

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

[0074] It can be explained that in step S1, the user energy consumption data is collected based on the power operator, that is, the user energy consumption data is obtained through the smart grid. It involves the living habits of users. Once it is leaked or misused, it may bring serious privacy hazards. Therefore, privacy enhancement processing needs to be performed on this data.

[0075] Please refer to Figure 4 , which shows a distribution diagram of some data before and after adding noise of a method for detecting electricity theft based on privacy-enhanced federated learning of smart grid provided by an embodiment of the present invention; among them, 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, enhancing the privacy protection of the user energy consumption data.

[0076] Furthermore, in step S1, it includes:

[0077] Step S11: Inject Gaussian noise using the LDP technology when collecting user energy consumption data, and the corresponding calculation formula is:

[0078] y = x + N(0, σ 2 )

[0079]

[0080] Among them, y represents the output data after the user energy consumption data is desensitized; x represents the user energy consumption data; N represents the Gaussian distribution; σ represents the standard deviation of the Gaussian noise; Δf represents the global sensitivity, that is, the difference between the maximum value and the minimum value in the user energy consumption data; ε represents the privacy budget.

[0081] It is explained that during the acquisition process of the user energy consumption data, Gaussian noise is injected through the LDP technology to desensitize the user energy consumption data, ensuring the security of the user's privacy information. Even if it is intercepted during the data transmission or storage process, the original user energy consumption data cannot be directly restored; and the injection of Gaussian noise also enhances the robustness of the data and reduces the misjudgment of the model caused by data anomalies or noise interference.

[0082] Step S12: Perform data cleaning based on the output data after the user energy consumption data is desensitized, and perform normalization processing on the cleaned user energy consumption data;

[0083] Furthermore, data cleaning is performed based on the output data after the user energy consumption data is desensitized, and the corresponding calculation formula is:

[0084]

[0085] Among them, x i represents the user energy consumption data of the user on the i-th day; x i-1 represents the user energy consumption data of the user on the (i - 1)-th day; x i+1 represents the user energy consumption data of the user on the (i + 1)-th day; NaN represents a missing value;

[0086] It is explained that data cleaning includes handling missing values, outliers, and duplicate values, that is, data cleaning is performed on the desensitized user energy consumption data to make the data consistent and without residual sensitive information. Among them, the missing value refers to the situation where due to a failure, the user energy consumption data of a certain user on a certain day is not correctly collected, resulting in a vacancy or anomaly.

[0087] The calculation formula for the normalization process is:

[0088]

[0089] Among them, Z i represents the result value after the normalization process of x i ; n represents the sample size of the user energy consumption data; min represents the minimum value in the user energy consumption data; max represents the maximum value in the user energy consumption data.

[0090] It is explained that in this embodiment, the min-max normalization processing method is used to scale the user energy consumption data to 0-1 to improve the stability of the data for subsequent model training.

[0091] Step S13: Construct a local training dataset from the normalized user energy consumption data through annotation.

[0092] Specifically, relying on the power audit expert annotation system to annotate the characteristics of the detected user energy consumption data, a local training dataset containing {feature vector, 0 / 1 label} is generated, denoted as where represents the user energy consumption data of user n days; l represents the annotation label of the user.

[0093] Furthermore, in step S2, it includes:

[0094] Step S21: Input the local training dataset into the training model in batches, and define the input dimension as [b, 1, n], where b represents the batch size; n represents the number of days of the collected user energy consumption data;

[0095] After being processed by the time convolutional network architecture, the input dimension is [b, 128, n], and the dilated convolutional structure is used to extract the temporal features in the user energy consumption data; after being processed by the convolutional neural network architecture, the input dimension is [b, 16, n], and the local perception mechanism is used to extract the spatial features from the temporal features.

[0096] It can be explained that in this embodiment, the training model is a global model, that is, the FedTCHN model, including the time convolutional network, that is, the TCN architecture and the convolutional neural network, that is, the CNN architecture; before the training model starts training, the data center initializes the parameters of the global model and distributes them to all power operators that need to participate in the training. After receiving them, the power operators use the global model as the local model, that is, the training model in step S2 for training.

[0097] Preferably, the batch size refers to the number of data samples processed by the training model in one training process; in this embodiment, the batch size is 64, that is, 64 pieces of user energy consumption data are input into the training each time; among them, the time span covered by the local training dataset can be obtained by counting the number of days of the collected user energy consumption data.

[0098] It is explained that 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 temporal features in the user energy consumption data to understand the pattern of the 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 and perform element-wise product summation operations with the corresponding local regions, and extracts local features from the input data through multiple layers of convolution to assist the training model in capturing the local correlations of the 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 the user energy consumption data.

[0099] Further, in step S3, it includes:

[0100] Step S31: After flattening the temporal features and spatial features, output the positive and negative class probabilities of all user energy consumption data in the corresponding batch, and define the output result as the data with the largest probability among the positive and negative class probabilities;

[0101] Specifically, flatten the temporal features and spatial features, that is, convert the data representing the two features from a multi-dimensional data structure into a one-dimensional data structure, and perform calculations to obtain the positive and negative class probabilities corresponding to each data, and select the one with the largest probability value as the output result.

[0102] Step S32: Calculate the error between the output result and the actual data in the local training dataset through the loss function, and update the weights and biases of the training model after backpropagation. The corresponding logical formula is:

[0103]

[0104] Among them, W lo represents the updated weight; represents the weight before update; b lo represents the updated bias; represents the bias before update; η represents the learning rate; represents the gradient of the loss function with respect to the output result, L represents the number of labeled labels, y represents the output data after desensitization of the user energy consumption data; f ′ represents the reciprocal of the activation function; x represents the input vector.

[0105] Specifically, the difference between the output result and the actual data in the local training dataset is measured by the loss function, and then the backpropagation 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 stated that the training model is updated through the local training dataset, that is, the parameters of the FedTCHN model, for local training of user energy consumption data.

[0106] Further, in step S4, it includes:

[0107] The MOTP protocol includes MOTP encryption, MOTP aggregation, and MOTP decryption.

[0108] It can be stated that the weights and biases after training, that is, the weights and biases updated through the local training dataset, are input into the privacy protector. The privacy protector provides the MOTP protocol for the aggregation of the training model, providing a secure aggregation process for the training model to ensure the privacy of user energy consumption data; this protocol includes MOTP encryption to ensure the security of user energy consumption data during transmission; MOTP aggregation, which allows for effective aggregation of multiple datasets without revealing individual data; and MOTP decryption, which enables the aggregated data to be securely decrypted for subsequent analysis.

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

[0110] It can be understood that in federated learning, the parameters of the training model are transmitted instead of the original user energy consumption data. However, attackers can use the parameters related to the training model to reverse-derive the original user energy consumption data. To avoid this problem, the relevant parameters of the trained training model are processed using the MOTP protocol to improve the privacy of user energy consumption data; among them, the encrypted vector can effectively prevent the model parameters after training from being intercepted or tampered with during transmission to ensure the security of the entire training model.

[0111] Further, in step S41, it includes:

[0112] Step S411: Flatten the updated weights and biases into a one-dimensional vector, and the corresponding calculation formula is:

[0113] w lo =[fl(W lo ),fl(b lo )]

[0114] where fl represents flattening into a one-dimensional vector;

[0115] Step S412: Quantize all elements in the one-dimensional vector into integers to obtain a quantized model vector. The corresponding calculation formula is:

[0116]

[0117] where, represents the integer after quantization of the i-th element in the one-dimensional vector; represents the i-th element in the one-dimensional vector; Q represents the quantization factor of the power of ten;

[0118] Step S413: Combine the MOTP key to perform character modulo addition calculation on the quantized model vector to obtain an encrypted vector. The corresponding calculation formula is:

[0119]

[0120] where, represents the encrypted vector; represents the integer after quantization of the one-dimensional vector; β lo represents the MOTP key; represents the character modulo addition operation.

[0121] Specifically, first flatten all elements in the weight W lo and the bias b lo after training into a one-dimensional vector, denoted as s represents the number of elements in the one-dimensional vector; then quantize all elements in the one-dimensional vector w lo into integers to obtain the quantized model vector where, the MOTP key is Perform character modulo addition calculation on the quantized model vector and the MOTP key to obtain the encrypted vector

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

[0123]

[0124] where, / / / represents the character modulo addition carry calculation.

[0125] It can be understood that the calculation method is used to calculate any character of any element in and u lo in sequence, obtain the encrypted vector and the parameter carry vector corresponding to the corresponding character of the corresponding element, and then integrate all the obtained encrypted vectors to obtain the encrypted vector and the parameter carry vector of the entire model parameter. The corresponding calculation formula is:

[0126]

[0127] Among them, represents the encryption vector of the j-th character of the i-th element; represents the parameter carry vector of the j-th character of the i-th element; char represents converting data into characters; ord represents the ascll value corresponding to the character (American Standard Code for Information Interchange, that is, the American Standard Information Interchange Code); represents the quantization model vector of the j-th character of the i-th element; β i,j represents the MOTP key of the j-th character of the i-th element; mod represents the modulo operation; N represents the modulus; / / represents integer division operation.

[0128] It should be noted that in this embodiment, the encryption vector obtained according to step S41 is represented as

[0129] Step S42: Use the MOTP aggregation method for the encryption vector in the data center to obtain an aggregation vector, and return the aggregation vector to the power operator.

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

[0131] Furthermore, using the MOTP aggregation method for the encryption vector in the data center to obtain an aggregation vector, the corresponding calculation formula is:

[0132]

[0133] Among them, represents the aggregation vector; represents the encryption vector; t represents the number of elements in the encryption vector; represents the character modulo addition operation.

[0134] Specifically, for the aforementioned obtained encryption vector obtain the aggregation vector and the aggregation carry vector u ag , combined with the parameter carry vector u lo obtain the parameter carry sum vector u ad , the corresponding calculation formula is:

[0135]

[0136] Among them, ++ represents the character addition operation; represents the number of elements participating in the calculation in the corresponding encryption vector.

[0137] Understandably, since the parameter carry vector contains multiple elements corresponding to multiple characters, the parameter carry vector based on any character of any element is calculated, and the parameter carry sum vector u is obtained by integration. ad , and the corresponding calculation formula is:

[0138]

[0139] where int means converting the parameter carry vector of the corresponding character into an integer.

[0140] It should be noted that in this embodiment, the aggregation vector obtained according to step S42 is expressed as

[0141] Furthermore, in step S5, the power operator obtains the aggregation vector sent by the data center, and obtains the decryption vector through the MOTP protocol to determine the electricity theft detection model, including:

[0142] Calculate based on each character of each element in the aggregation vector, splice all the characters after calculation of each element into a string, and quantify it into an integer to obtain the decryption vector corresponding to the element. The corresponding calculation formula is:

[0143]

[0144] where represents the decryption vector of the i-th element; int represents integer operation; join means splicing characters into a string; represents the o-th character of the i-th element.

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

[0146]

[0147] where n represents the number of days of the user's energy consumption data collected; l represents the labeled label of the user in the local training dataset; and then all the calculated decryption vectors are integrated to obtain the decryption vector; and then the training model processed by the MOTP protocol is the electricity theft detection model.

[0148] It should be noted that in this embodiment, the decryption vector obtained according to step S5 is expressed as

[0149] Understandably, the weights and biases after training are input into the privacy protector. The privacy protector securely encrypts the parameters using 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 aggregates the parameters according to the encrypted vector using the MOTP aggregation method to determine the aggregated vector, which can represent the common information of all participating power operators in training without revealing any individual power operator's parameter vector, and returns the aggregated vector to each power operator. Then, the decrypted vector is obtained through the MOTP decryption method to further determine the electricity theft detection model, which can not only effectively prevent electricity theft behavior but also ensure data security and privacy protection throughout the process. Next, the original tensor format of the updated training model parameters is converted into a parameter file for model training, and it is judged whether the maximum number of iterations is reached. If not, steps S2 - S4 are repeated; if so, the next step, that is, step S6, is executed. Specifically, a maximum number of iterations is given to the training model in advance, and for the training model processed by the privacy protector and the model trainer, the next step is processed according to whether the maximum number of iterations is reached.

[0150] Further, in step S6, a detection dataset is constructed from the local training dataset, denoted as where d represents the elements of the detection dataset; q represents the number of elements in the detection dataset; n represents the number of days of the collected user energy consumption data. The detection dataset is input into the electricity theft detection model to obtain the prediction result, denoted as where p represents the element in the detection dataset corresponding to the prediction result. A screening threshold ts is set. If the prediction result is greater than the screening threshold, it indicates that the corresponding analyzed user is an electricity theft user, and the information of the electricity theft user is transmitted to the data center; otherwise, if the prediction result is less than the screening threshold, it indicates that the currently corresponding analyzed user is a normal user, and then the operation continues normally.

[0151] As an optional implementation manner, for the electricity theft detection method based on privacy-enhanced federated learning of smart grid proposed in this application, to verify its feasibility, an application example is as follows: Five regional power operators are responsible for user management in their respective regions, and the user energy consumption data of each region cannot be directly shared, and each only has a small number of electricity theft user samples. Therefore, to more effectively detect electricity theft users, the power operators, the data center, and the security center jointly form a federated learning network, and the detection method proposed in this application is used to jointly train and obtain an electricity theft detection model. It does not need to share the original user energy consumption data of users. Each regional power operator can directly access the user energy consumption data, and the parameters of the electricity theft detection model are interacted through the MOTP protocol, and only each regional power operator can know its own real model parameters.

[0152] Specifically, the user energy consumption data collected by these 5 regional power operators through the smart grid are implemented with steps S1 - S6. When cleaning the user energy consumption data, missing values are filled. Since there are all - zero rows in the collected user energy consumption data, that is, the user energy consumption data between some rows are all zero, and the subsequent analyzed user energy consumption data includes positive and negative labels, all user energy consumption data with all - zero rows are deleted to ensure the quality of the user energy consumption data, and then subsequent data processing is carried out to ensure the accuracy of the determination result of the electricity - stealing detection model; then, the dual indicators of accuracy rate and area under the curve are used as performance evaluation indicators to judge the reliability of the electricity - stealing detection model provided in this application for detecting electricity - stealing users.

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

[0154]

[0155] Among them, TP represents the number of positive classes predicted as positive classes; TN represents the number of negative classes predicted as negative classes; FP represents the number of negative classes predicted as positive classes; FN represents the number of positive classes predicted as negative classes; the higher the ACC value, the better the electricity - stealing detection model performs in correctly predicting electricity - stealing behaviors.

[0156] Due to the imbalance of positive and negative samples in the user energy consumption data, the area under the curve (AUC, Area Under Curve) is introduced as an evaluation indicator. Compared with the single accuracy rate, AUC is more adaptable to datasets 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, and a value close to 1 indicates that the electricity - stealing detection model has a stronger ability to identify electricity - stealing users, and vice versa, the identification ability is relatively poor.

[0157] Please refer to Figure 5 , which shows the performance test chart under the TCHN centralized and federated learning frameworks of a privacy - enhanced smart grid federated learning electricity - stealing detection method provided by an embodiment of the present invention, that is, the TCHN model, namely the electricity - stealing detection model, is tested on the test dataset, including centralized training and federated training, that is, the effect comparison is carried out according to the system established by the provided 5 power operators. Among them, 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.

[0158] It should be noted that centralized training performs better in terms of performance evaluation metrics such as 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 terms of performance, but its performance is still very excellent. Especially after the number of aggregation rounds increases, the performance gradually approaches that of centralized training; and distributed training has significant advantages in aspects such as data privacy protection, distributed computing efficiency, robustness, and scalability.

[0159] For better illustration, tests are conducted on a test data set composed of user energy consumption data provided by 5 power operators, and compared with the homomorphic encryption provided by the existing method to obtain Table 1, which is specifically shown as follows:

[0160] Table 1 Comparison of model aggregation schemes

[0161]

[0162] It can be understood that the size of the electricity theft detection model after MOTP encryption is significantly smaller than that of the homomorphic encryption model, so the communication overhead consumed is also lower; and the total computing time of MOTP is significantly lower than that of homomorphic encryption, indicating that the MOTP scheme is also superior to homomorphic encryption in terms of computing overhead. Therefore, the MOTP protocol is superior to the traditional homomorphic encryption scheme in overall performance, indicating the high feasibility of the electricity theft detection method for smart grid federated learning based on privacy enhancement proposed in this application.

[0163] It should be noted that the above sequence of embodiments of the present invention is only for description and does not represent the superiority or inferiority 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.

[0164] Each embodiment in this specification is described in a progressive manner. The same or similar parts among the embodiments can be referred 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: obtaining a training model, which is a global model including a temporal convolutional network architecture and a convolutional neural network architecture, inputting the local training data set into the training model in batches, and extracting 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; Wherein, step S4 includes: The MOTP protocol includes MOTP encryption, MOTP aggregation and MOTP decryption; The MOTP encryption method is used to obtain the encrypted vector based on the trained weights and biases and sent to the data center, including: Based on the updated weights and biases flattened into a one-dimensional vector, the corresponding calculation formula is: w lo =[fl(W lo ),fl(b lo )] Among them, fl represents flattening into 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, An integer representing the quantized value of the i-th element in a one-dimensional vector; represents the i-th element in a one-dimensional vector; Q represents the quantization factor of a power 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; represents the integer after one-dimensional vector quantization; β lo Indicates the MOTP key; ⊕ indicates character modulo addition operation; In the data center, the encrypted vector is aggregated using the MOTP aggregation method to obtain an aggregated vector, and the aggregated vector is returned to the power operator, including: 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 an encrypted vector; t represents the number of elements in the encrypted vector; ⊕ represents character modulo addition operation; 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; 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, represents the decrypted vector of the i-th element; int represents integer operations; join represents concatenating characters into a string; Represents the oth character of the i-th element; 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: y=x+N(0,σ 2 ) Where y represents the output data after user energy consumption data is desensitized; x represents user energy consumption data; N represents Gaussian distribution; σ represents the standard deviation of Gaussian noise; Δf represents global sensitivity, that is, the difference between the maximum and minimum values ​​in user 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: Among them, x i represents the energy consumption data of the user on the i-th day; x i-1 represents the energy consumption data of the user on the i-1th day; x i+1 Represents the user energy consumption data on the i+1th day; NaN represents a missing value; The calculation formula corresponding to the normalization process is: Among them, Z i Indicates x i The result value after normalization processing; n represents the number of samples of user energy consumption data; min represents the minimum value in the user energy consumption data; max represents the maximum value in the user 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: The local training data set is input into the training model in batches, and the input dimension is defined as [b, 1, n], where b represents the batch size; n represents the number of days of user energy consumption data collected; After being processed by the temporal convolutional network architecture, the input dimension is [b, 128, n], and the dilated convolution structure is used to extract the temporal features in the user energy consumption data; after being processed by the convolutional neural network architecture, the input dimension is [b, 16, n], and the spatial features are extracted from the temporal features through the 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: Among them, W lo represents the updated weight; represents the weight before updating; b lo represents the updated bias; represents the bias before updating; η represents the learning rate; represents the gradient of the loss function to the output result, L represents the number of annotated labels, and y represents the output data after the user energy consumption data is desensitized; f ′ represents the inverse of the activation function; x represents the input vector.

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