Power consumption anomaly detection method and system based on diffusion model, medium and processor

By using a diffusion model-based method for detecting power anomalies, and leveraging a noise predictor neural network and an anomaly threshold prediction network, the method addresses the shortcomings in accuracy and real-time performance of traditional detection methods. This enables efficient and accurate detection of power anomalies, thereby improving the stability and detection efficiency of the power system.

CN120910413APending Publication Date: 2025-11-07ELECTRIC POWER RES INST OF GUANGXI POWER GRID CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510793760.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-13
Publication Date
2025-11-07

AI Technical Summary

Technical Problem

Traditional methods for detecting abnormal electricity consumption suffer from low detection accuracy, poor real-time performance, and high computational complexity in smart grid and big data environments, making it difficult to detect abnormal electricity consumption quickly and accurately.

Method used

A power consumption anomaly detection method based on a diffusion model is adopted. Random Gaussian noise is transformed into a real cloud environment indicator distribution through stepwise denoising. The indicator parameters at future times are predicted by a noise predictor neural network, and anomaly identification is performed by an anomaly threshold prediction network.

Benefits of technology

It improves the stability and detection efficiency of the power system, ensures the safety of the power grid and reduces operating costs, and achieves high-precision, real-time detection of power consumption anomalies.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120910413A_ABST
    Figure CN120910413A_ABST
Patent Text Reader

Abstract

The invention discloses a power consumption anomaly detection method and system based on a diffusion model, a medium and a processor, and belongs to the technical field of power consumption anomaly detection. The method comprises the steps of collecting original index parameters of a power utilization unit and performing normalization to generate first-level data; dividing the first-level data into a second-level sample set with time sequence dependence; injecting noise training by taking the secondary sample set as a training set to obtain a noise predictor neural network; predicting index parameters at future moments by using the network; and carrying out anomaly judgment on the prediction result. The system comprises an acquisition module, a division module, a training module, a prediction module and a discrimination module. A computer readable storage medium and a processor are used for executing the method. According to the method, the index parameters are gradually denoised and predicted through the diffusion model, the abnormal power consumption behavior is pre-judged in combination with the abnormal threshold, the problems of low detection precision, poor real-time performance and the like of a traditional method are solved, and the stability and the detection efficiency of the power system are improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of power consumption anomaly detection, and particularly relates to a power consumption anomaly detection method and system based on a diffusion model, a medium and a processor. BACKGROUND

[0002] With the rapid development of China's economy and the continuous improvement of people's living standards, the demand for electricity continues to grow, and the scale of the power grid continues to expand. At the same time, ensuring the safe, economic and efficient operation of the power grid has become an important issue in the management of the power system. Power consumption anomaly detection, as an important part of power system management, plays a crucial role in preventing power accidents, reducing line losses and improving power supply reliability.

[0003] In traditional power consumption anomaly detection methods, common technical means include threshold detection, expert systems, neural networks, etc. However, these methods generally have low detection accuracy, poor real-time performance, and high computational complexity when dealing with large amounts of complex data. In particular, under the current smart grid and big data environment, how to quickly and accurately detect power consumption anomalies has become a major challenge in the field of power systems.

[0004] In view of this, a power consumption anomaly detection method and system based on a diffusion model, a medium and a processor are needed. SUMMARY

[0005] To address the problems of low detection accuracy, poor real-time performance and high computational complexity in the prior art, the present application provides a power consumption anomaly detection method and system based on a diffusion model, a medium and a processor, which converts random Gaussian noise into real cloud environment index distribution through step-by-step denoising, accurately predicts the next time index parameters of the power system, and uses an anomaly threshold prediction network to make an abnormal prediction on the prediction results to determine whether there is abnormal power consumption behavior, thereby solving the problems of low detection accuracy and poor real-time performance in traditional methods and improving the stability and detection efficiency of the power system. The specific technical solutions are as follows:

[0006] A power consumption anomaly detection method based on a diffusion model, comprising:

[0007] S1: Collecting original index parameters of power consumption units, and generating structured first-level data through normalization processing;

[0008] S2: Dividing the first-level data into a second-level sample set with time sequence dependence according to time sequence characteristics;

[0009] S3: Using the second-level sample set as a training set, injecting noise into the training set to train a neural network, and obtaining a noise predictor neural network θ ;

[0010] S4: Using the noise predictor neural networkθ obtaining a prediction result;

[0011] S5: performing abnormality discrimination on the prediction result to obtain an electricity utilization unit abnormality detection result.

[0012] Further, in step S2, the dividing the first-level data into second-level sample sets with time sequence dependence according to time sequence characteristics comprises the following steps:

[0013] S21: dividing the first-level data by taking consecutive p records as a sample window to obtain n-p samples x;

[0014] S22: arranging all parameters of the first p-1 records of each sample in chronological order as feature values of the sample, arranging all parameters in the last record as label values of the sample, and dividing the sample into features and labels;

[0015] S23: dividing all samples into features and labels to form a second-level sample set.

[0016] Further, in step S3, the second-level sample set is used as a training set, noise is injected into the training set, and the noise predictor neural network ε is obtained by training the neural network, comprising the following steps: θ

[0017] S31: taking the second-level sample set as a training set X train ;

[0018] S32: gradually adding Gaussian noise to the training set X train , and the values in the training set X train after adding T-step noise become completely random Gaussian noise;

[0019] S33: inputting the t-step noisy sample x t and the step number t into the noise predictor neural network ε θ to obtain the noise prediction value z θ in x t .

[0020] S34: by minimizing the mean square error between the predicted noise z θ and the actual added noise z t , the parameters of the noise predictor neural network ε θ are optimized by using the back propagation and gradient descent method, and the noise predictor neural network ε θ with optimal parameters is found after multiple rounds of training, which is used for subsequent noise prediction in samples.

[0021] Further, in step S33, the t-step noisy sample x​t The calculation formula is as follows:

[0022]

[0023] α t = 1-β t ;

[0024] wherein z t is Gaussian noise; x0is an initial state sample; β t is the noise intensity of the t-th step in the forward noise adding process.

[0025] Further, in step S33, the conditional probability distribution of the previous state sample x t of the noisy sample x t-1 t is calculated according to the following formula:

[0026]

[0027] In the above formula, q(x t-1 |x t , x0) is the probability distribution of the sample x t-1 ; q(x t |x t-1 ) is the probability distribution of the forward noise adding process, representing the noise transition probability from x t-1 to x t ; q(x t-1 |x0) is the probability distribution of x t-1 given the initial sample x0; q(x t |x0) is the probability distribution of x t given the initial sample x0.

[0028] Further, in step S4, the index parameter prediction of the future time by the noise predictor neural network ε θ is obtained, including the following steps:

[0029] S41: Set the input sample as feature data containing p records wherein the first p-1 records are historical records, and the p-th record is a missing value;

[0030] S42: The missing value part is first filled with Gaussian noise to form a noisy sample;

[0031] S43: Calculate the sample x test after adding noise in the t-1th step The formula is as follows:

[0032]

[0033] In the above formula, represents Xtest Noisy sample after adding the noise of t-1 step; z t-1 is a random Gaussian noise; is an initial state sample;

[0034] S44: Sampling and X test Random Gaussian noise of the same dimension and filling into X test After obtaining the noisy sample X T , X T and the number of steps T input the noise predictor neural network ε θ Obtain the predicted noise Use the predicted noise Calculate the mean μ of the T-1 step sample T-1 and variance Obtain the sample after denoising one step through the mean and variance of the T-1 step sample

[0035] S45: Combine and the contents to obtain the reorganized T-1 step sample X T-1 ,

[0036] S46: Repeat the above steps S43 to S45 for T times to obtain clean samples x0 conforming to the distribution of the training samples; The last record of the clean sample x0 is the prediction result.

[0037] Further, in step S45, the sample X T-1 The reorganization formula is as follows:

[0038]

[0039] Where m is an indicator matrix consisting of 0 and 1, and the dimension is the same as X test ; ⊙ represents element-level multiplication.

[0040] An electricity abnormality detection system based on a diffusion model, applied to the electricity abnormality detection method based on the diffusion model described above, comprising:

[0041] The acquisition module is used to acquire the original index parameters of the electricity unit, and generate structured first-level data after normalization processing;

[0042] The division module is used to divide the first-level data into a second-level sample set with time sequence dependence according to the time sequence characteristics;

[0043] The training module is used to take the second-level sample set as a training set, inject noise into the training set, and use the training set to train the neural network to obtain a noise predictor neural network ε θ ;

[0044] a prediction module configured to utilize a noise predictor neural network epsilon θ predicting the index parameter at the future time to obtain a prediction result;

[0045] a discrimination module configured to perform abnormality discrimination on the prediction result to obtain an electricity consumption unit abnormality detection result.

[0046] A computer-readable storage medium comprising a stored program, wherein the program, when executed, controls a device in which the computer-readable storage medium is located to perform the electricity consumption abnormality detection method based on the diffusion model described above.

[0047] A processor configured to execute a program, wherein the program, when executed, performs the electricity consumption abnormality detection method based on the diffusion model described above.

[0048] Compared with the prior art, the present application has the following advantages:

[0049] 1. The present application introduces a diffusion model to solve the problems of low detection accuracy, poor real-time performance, and high computational complexity in traditional electricity consumption abnormality detection. The data acquisition module obtains various index parameters of the electricity consumption unit, the data division module divides the collected data into secondary samples suitable for training, the sample training module trains the secondary samples with noise to form a tertiary neural network model with learning ability. Then, the time series prediction module uses the trained neural network model to predict the electricity consumption index at the future time, and the abnormality discrimination module performs real-time analysis on the prediction result to identify abnormal electricity consumption, thereby ensuring the stability and safety of the power system, improving the detection efficiency, and reducing the operating cost.

[0050] 2. The random Gaussian noise is converted into a real cloud environment index distribution by step-by-step denoising, and the next time index parameter of the power system is accurately predicted. The abnormal threshold prediction network performs abnormal prediction on the prediction result to determine whether there is abnormal electricity consumption behavior, solves the problems of low detection accuracy and poor real-time performance in traditional methods, and improves the stability and detection efficiency of the power system. BRIEF DESCRIPTION OF DRAWINGS

[0051] In order to more clearly illustrate the specific embodiments of the present application or the technical solutions in the prior art, the drawings needed in the specific embodiments or prior art description will be briefly introduced below. In all the drawings, similar elements or parts are generally identified by similar reference numerals. In the drawings, each element or part is not necessarily drawn according to the actual scale.

[0052] Figure 1 It is a flowchart of an electricity consumption abnormality detection method based on a diffusion model;

[0053] Figure 2A structural schematic diagram of a power consumption anomaly detection system based on a diffusion model;

[0054] Figure 3 A timing distribution module diagram of a power consumption anomaly detection method;

[0055] Figure 4 A threshold prediction network diagram of a power consumption anomaly detection method. DETAILED DESCRIPTION

[0056] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are some of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work fall within the scope of protection of the present application.

[0057] It should be understood that when used in the specification and the appended claims, the terms "comprise" and "include" indicate the presence of the described features, integers, steps, operations, elements, and / or components, but do not exclude one or more other features, integers, steps, operations, elements, components, and / or groups thereof.

[0058] It should also be understood that the terms used in the present application specification are only for the purpose of describing specific embodiments and are not intended to limit the present application. As used in the present application specification and the appended claims, unless otherwise clearly indicated by the context, the singular forms "a", "an" and "the" are intended to include the plural forms.

[0059] It should be further understood that the term "and / or" used in the present application specification and the appended claims means any combination of one or more of the associated listed items and all possible combinations, and includes these combinations.

[0060] Embodiment one

[0061] As Figure 1 shown, a power consumption anomaly detection method based on a diffusion model includes the following steps:

[0062] S1: Collecting power consumption unit original index parameters (real-time collection) through sensors and monitoring devices, and generating structured first-level data through normalization processing.

[0063] Further, the original index parameters of the power consumption unit include: system log data, active power, reactive power, power factor, voltage, current, frequency, historical load data. These parameters can comprehensively reflect the real-time running state and load condition of the power consumption unit; the system log data is used to record the running events and state changes of the power consumption equipment, which helps to track the specific time and possible reasons of the abnormality; the active power represents the actual consumed power, which is used to measure the effective power consumption of the equipment; the reactive power represents the power component that does not do actual work in the power system, which has an impact on the stability of the power system; the power factor reflects the efficiency of the power equipment, which is an important indicator to measure the power utilization rate; the voltage and current represent the voltage level and current value flowing through the power system respectively, which are the key parameters to maintain the normal operation of the power grid; the frequency is used to monitor the synchronism and stability of the power system, and the frequency deviation may cause abnormal work of the power equipment; in addition, the historical load data reflects the load change of the power consumption unit at different time periods, which helps to identify periodic fluctuations and load peaks, thereby providing a reference for power consumption anomaly detection; in the present application, by collecting and analyzing the above-mentioned primary power consumption index parameters, the feature data set reflecting the running state of the power consumption unit can be accurately constructed, thereby providing reliable data support for subsequent anomaly detection and prediction.

[0064] The original index parameters of the power consumption unit can also be collected by other means, such as through a smart meter network. Each power consumption unit is equipped with a smart meter, which periodically uploads data to a cloud data center. These data include real-time voltage, current, power, and basic load history data. The smart meter network has high convenience and can reduce the centralized cost of collection equipment. However, the disadvantage of this method is that the collection frequency of the smart meter is usually low, which cannot meet the high-frequency time series analysis requirements, and therefore the detection accuracy and real-time performance are not as good as the embodiments of the present application.

[0065] In an optional embodiment, the original index parameters of the power consumption unit can also be collected by other means, such as through a wireless sensor network (WSN). The wireless sensor network is arranged with multiple sensor nodes at different parts of each power consumption unit. Each node independently collects voltage, current, power, and other parameters, and aggregates the data to a sink node through wireless means, and then transmits the data to the central control system. This method has the advantages of wide coverage and flexible deployment, and is suitable for real-time monitoring of large power consumption networks. However, the wireless sensor network is limited by bandwidth and transmission distance, which may cause data delay and be easily disturbed by environmental factors, thereby affecting the stability and accuracy of the data.

[0066] S11: Collect the original index parameters of the power consumption unit every 5 seconds as a sample, and form a table form of the original data sequence X ∈ R n×d, represents a total of n samples, each sample contains d features, and each sample represents the state value of each index parameter of the power unit at a certain time.

[0067] S12: Process the original data sequence X using a type of processing mode, and the type of processing mode here is normalization processing (i.e. a type of processing mode) to obtain primary data.

[0068] For each group of features (such as the i-th group), calculate the maximum value max i and the minimum value min i in n samples.

[0069] Through the formula:

[0070]

[0071] The data is normalized, and the feature value is mapped to the interval [0, 1]; wherein is the original feature value (i-th dimension), that is, the value corresponding to the n-th row and i-th column in X; is the normalized feature value (i-th dimension), and finally the primary data is obtained. The normalization processing method can reduce the difference between different dimension parameters, make the data more stable in model training, and also reduce the training bias caused by the difference in feature value size, improve the learning efficiency and accuracy of the model.

[0072] Further, the type of processing mode can also be implemented in other ways, for example, by segmenting the data for processing, this method calculates the maximum and minimum values of the data in different time periods respectively, and normalizes the data characteristics of each time period.

[0073] Further, the type of processing mode can also be implemented in other ways, for example, it can also be implemented by principal component analysis (PCA) for feature dimension reduction, the PCA method concentrates important information in the data into a few principal components (i.e. a few feature dimensions) through the feature covariance matrix, thereby reducing the input dimension of the model. This method has a certain effect on removing data structure and noise, and can simplify the calculation amount and improve the processing speed to a certain extent.

[0074] All values in the data are normalized to between 0 and 1, and then the data is divided into sample features and sample labels according to the time sequence characteristics, so as to facilitate the training of the machine learning model.

[0075] S2: Divide the normalized primary data into a secondary sample set with time sequence dependence according to the time sequence characteristics, so as to facilitate the training of the machine learning model, refer to Figure 3 .

[0076] S21: Take the continuous p (in this embodiment, 60 records are used for sample 1) records as a window as a sample x, and divide it by a sliding step of 1 (for example, sample 1 and sample 2 are two samples separated by 1 record in the first-level data) to obtain n-p (in this embodiment, n-60) samples.

[0077] S22: Then, each sample is divided into features and labels, and all parameters of the first p-1 records of each sample are arranged in chronological order to obtain the feature value of the sample, and all parameters in the last 1 record are taken as the label value of the sample.

[0078] Taking sample 1 as an example, which contains 60 records, all parameters of the first 59 records are arranged in chronological order as the feature value x of sample 1 z1 , and the chilled water return water temperature value in the last 1 record is taken as the label value x of sample 1 b1 .

[0079] S23: The features and labels of all samples are divided to obtain the feature value x z and the label value x b ; all samples form a second-level sample set, each sample contains the feature value x z and the label value x b .

[0080] S3: The second-level sample set is used as a training set, and the noise is injected into the training set to train the neural network, and the noise predictor neural network ε θ is obtained.

[0081] The neural network uses a diffusion model (Diffusion Model) or a derivative variant thereof.

[0082] It should be noted that the noise injection training includes adding noise to the training set and training, and the noise predictor neural network ε θ is obtained after training.

[0083] S31: The second-level sample set is used as a training set X train .

[0084] S32: Gaussian noise is gradually added to the training set X train , and the components of the Gaussian noise added at each step are determined by a set of parameters set in advance. After T steps of noise are added, the values in the training set X train become completely random Gaussian noise.

[0085] Further, for any sample x train in the training set X i , its initial state without any Gaussian noise is denoted as x0, and its state after t steps of noise are added is denoted as xt The state of each step is obtained by adding Gaussian noise to the state of its previous step, so the process of adding noise can be regarded as a Markov chain.

[0086] Further, the sample after adding Gaussian noise at step t can be obtained by the following formula:

[0087]

[0088] where x t and x t-1 represent the samples after adding noise at step t and step t-1 respectively; a t is the tth parameter in a set of parameters preset in advance; z t represents randomly sampled Gaussian noise; formula (2) represents that the sample at step t is obtained by adding Gaussian noise to the sample at step t-1. Since each step of the sample is only related to the previous step of the sample, and the initial sample state x0 is also known (i.e., the training set X train ).

[0089] In summary, the formula of the noisy sample after adding Gaussian noise at any step t is as follows:

[0090]

[0091] where a t = 1- b t is a parameter artificially selected; z t is randomly sampled Gaussian noise. Formula (3) obtains the sample x t after adding noise at any step by the initial sample state x0.

[0092] By the Bayesian posterior formula, the conditional probability distribution q(x t |x t-1 , x0) of the sample x t-1 at step t-1 is obtained based on the noisy sample x t at step t and the initial sample x0 by formula (4), which is as follows:

[0093]

[0094] In the above formula, q(x t-1 |x t , x0) is the probability distribution of the sample x t-1 , i.e., the distribution law to which the sample x t-1 may conform; x0 is the initial noiseless sample; x t-1 is the noisy sample at step t-1; x t is the noisy sample at step t; q(xt |x t-1 t-1 to x t is a Gaussian distribution; q(x t-1 |x0) is the probability distribution of x t-1 given the initial sample x0(the intermediate state distribution of the forward noise adding process); q(x t |x0) is the probability distribution of x t after t steps of the forward noise adding process, each parameter of which is a Gaussian distribution, so q(x t-1 |x t ,x0) is also a Gaussian distribution.

[0095] Further, the probability distribution of sample x t-1 is not directly equal to sample x t-1 , but tells us where sample x t-1 is most likely to appear and the credibility(variance) of these values.

[0096] Further, the probability distribution of sample x t-1 is only a theoretical distribution form and cannot be directly used to calculate the specific value of sample x t-1 , so only the mean and variance of the distribution need to be calculated, which directly determines how to denoise x t from x t-1 .

[0097] The mean and variance of the above three Gaussian distributions are simplified to obtain the mean and variance of q(x t-1 |x t ,x0), which are represented as:

[0098]

[0099] In the above formula, β t is the noise intensity of the t-th step in the forward noise adding process; α t = 1-β t ; reflects how much “real data component” is left from the initial sample x0to x t ; is the variance of x t , which reflects the dispersion degree of the distribution of sample x t-1 under the condition of knowing x t and x0, and is used to control the “uncertainty” of the reverse denoising process. The greater the variance, the lower the confidence in the current sample x t during denoising, and the more cautious the predicted value needs to be adjusted.

[0100]

[0101] That is,

[0102] The mean of the posterior probability q(x t-1 | x t , x0) is used.

[0103] Equation 6 is a direct mathematical basis for noise prediction: the noise prediction value z t is associated with the denoised sample to form an optimizable objective function.

[0104] Equation 5 is an indirect constraint condition for noise prediction: the denoising uncertainty is characterized by the variance, which affects the degree of dependence of the model on noise prediction, and ensures the stability of the denoising process.

[0105] Core logic: use equations 5 and 6 to convert the noise prediction problem into an optimization problem of solving the optimal z t through the mean equation, and then use the nonlinear fitting ability of the neural network to achieve accurate prediction.

[0106] The noise predictor neural network ε θ includes an encoder and a decoder.

[0107] S33: The input of the noise predictor neural network ε θ is the noisy sample x t at the t-th step and the step number t, to obtain the noise prediction value z t added to x θ .

[0108] S34: Minimize the mean square error between the predicted noise z θ and the actual added noise z t : L = ||z θ -z t || 2 , and use backpropagation and gradient descent method to optimize the parameters of the noise predictor neural network ε θ , and after multiple rounds of training, find the noise predictor neural network ε θ with optimal parameters for subsequent prediction of noise in samples.

[0109] S4: Use the noise predictor neural network ε θ to predict the index parameter at the future time, to obtain the prediction result.

[0110] It should be noted that the time series prediction using the three-level neural network includes time series prediction of the index parameter of the cloud environment running process using the three-level neural network, which converts the prediction problem of the future time into the filling problem of the index parameter of the future time.

[0111] S41: converting the index parameter prediction of the future time into a missing value filling problem. Let the input sample be feature data containing p records , wherein the first p-1 records are historical records, and the pth record (future time data) is a missing value.

[0112] S42: filling the missing value part with Gaussian noise first to form a noisy sample.

[0113] For example, for a sample X containing missing values test ∈R 60*d , wherein X test The first 59 records exist, and the 60th record represents the index parameter of the next time, and the subsequent prediction target is to predict the 60th record, so it is a missing value. The missing value part is filled with Gaussian noise first to form a noisy sample.

[0114] S43: calculating X test After the sample of step t-1 is added with noise The formula is as follows (7):

[0115]

[0116] In the above formula, X test is the noisy sample after adding the noise of step t-1; z t-1 is a random Gaussian noise; is an initial state sample, that is, the filling X of the 60th record filled with Gaussian noise test .

[0117] S44: sampling a random Gaussian noise with the same dimension as X test and filling it into X test to obtain a noisy sample X T , inputting X T and the step number T into the noise predictor neural network ε θ to obtain the predicted noise Through formulas (5) and (6), the mean and variance of the sample of step T-1 are calculated using the predicted noise Through the mean and variance of the sample of step T-1, the sample after one de-noising step is obtained

[0118] S45: combining and The recombined T-1 step sample X T-1 is obtained by formula (8)

[0119]

[0120] wherein m e R 60*d is an indicator matrix composed of 0 and 1, and has the same dimension as X test , wherein 1 indicates that the position corresponds to an element in X test with no missing value, and 0 indicates that the element in X test corresponding position is missing; for example, all elements of the first 59 rows of m are 1, and all elements of the 60th row are 0; and represents element-level multiplication, which retains the known historical data (the first 59) and updates the missing value prediction (the 60th).

[0121] S46: Repeat the above steps S43 to S45 for T times, that is, the sample X T with added random sampling Gaussian noise is denoised for T times to obtain a clean sample x0 conforming to the distribution of the training sample, that is, a complete sample containing the first 59 known historical data and the 60th predicted value.

[0122] S5: Abnormality discrimination is performed on the prediction result to obtain the abnormality detection result of the power utilization unit.

[0123] It should be noted that the abnormality discrimination on the prediction result includes comparing the prediction result with a preset threshold to obtain the abnormality detection result of the power utilization unit, as shown in Figure 4 .

[0124] Further, after S4, the prediction result of the index parameter of the power system at the future time is obtained, that is, the 60th row in x0 obtained by denoising T times in S4, which is taken as the prediction result R. The predicted index parameter of the power system is input to the threshold prediction network for abnormality discrimination; by comparing the prediction result R with the preset threshold T, if R is greater than or equal to T, the power system is abnormal, that is, the problem needs to be found out in time, and if R is less than T, the power system is safe.

[0125] The neural network of the scheme uses a noise prediction module based on a diffusion model to convert random Gaussian noise into a real cloud environment index distribution through step-by-step denoising, accurately predicts the index parameter of the power system at the next time, and judges whether there is an abnormal power utilization behavior through an abnormal threshold prediction network, solves the problems of low detection accuracy and poor real-time performance in traditional methods, and improves the stability and detection efficiency of the power system.

[0126] The application uses time sequence division, and divides index parameters in the operation process of the power system into a trainable data set according to time sequence characteristics. Meanwhile, the abnormality detection problem of the power system is converted into a missing value filling problem, which can be effectively solved by a diffusion model.

[0127] The application adopts a noise prediction module based on a diffusion model, and can gradually denoise random Gaussian noise into a real cloud environment index parameter value distribution through given power system index parameters. Through the generated index parameters, the index parameter value of the power system at the next moment can be accurately predicted.

[0128] The application proposes an abnormal threshold prediction network, which can make an abnormal prediction on the predicted index parameters of the power system at the future moment.

[0129] Embodiment two

[0130] As shown in Figure 2 A power consumption anomaly detection system based on a diffusion model is applied to the power consumption anomaly detection method based on the diffusion model described above, and includes:

[0131] A collection module is configured to collect original index parameters of a power consumption unit, and generate structured first-level data through normalization processing;

[0132] A division module is configured to divide the first-level data into a second-level sample set with time sequence dependence according to time sequence characteristics;

[0133] A training module is configured to use the second-level sample set as a training set, inject noise into the training set, and use the training set to train a neural network to obtain a noise predictor neural network ε θ ;

[0134] A prediction module is configured to use the noise predictor neural network ε θ to predict index parameters at a future moment to obtain a prediction result;

[0135] A discrimination module is configured to perform abnormal discrimination on the prediction result to obtain a power consumption unit anomaly detection result.

[0136] Embodiment three

[0137] A computer readable storage medium includes a stored program, wherein the program controls the device where the computer readable storage medium is located to execute the power consumption anomaly detection method based on the diffusion model described above when the program is running.

[0138] Embodiment four

[0139] A processor is configured to run a program, wherein the program performs the power consumption anomaly detection method based on the diffusion model described above when the program is running.

[0140] Benefits:

[0141] 1. Improved detection accuracy: By gradually denoising through the diffusion model, random Gaussian noise is converted into a real power consumption indicator distribution, accurately predicting future parameter values and avoiding misjudgments caused by rough data processing in traditional methods, significantly improving the accuracy of anomaly detection.

[0142] 2. Real-time optimization: The noise predictor based on neural networks can quickly process time series data, combined with the sliding window method to divide samples, achieving real-time analysis of power consumption data, significantly reducing detection delay compared to traditional expert systems or threshold detection.

[0143] 3. Reduced computational complexity: Through mathematical derivation of Gaussian noise injection and reverse denoising (e.g., Equations 5 and 6), the complex time series prediction problem is transformed into mean-variance calculation that can be optimized, reducing the computational load of model training and inference, and improving processing efficiency.

[0144] 4. More intelligent anomaly discrimination: By dynamically comparing pre-set thresholds with prediction results, combined with the diffusion model's learning ability for data distribution, subtle changes in power consumption patterns can be adaptively identified, effectively detecting implicit anomalies that traditional methods cannot capture.

[0145] The present application discloses a power consumption anomaly detection method and system based on a diffusion model, a medium and a processor, belonging to the technical field of power consumption anomaly detection. The method includes: collecting power consumption unit original indicator parameters and normalizing to generate primary data; dividing the primary data into a secondary sample set with time sequence dependence; injecting noise to train a noise predictor neural network using the secondary sample set as the training set; predicting future indicator parameters using the network; and performing anomaly discrimination on the prediction results. The system includes acquisition, division, training, prediction, and discrimination modules. The computer-readable storage medium and the processor are used to execute the method. The present application predicts indicator parameters by gradually denoising through the diffusion model, and pre-judges abnormal power consumption behavior by combining anomaly thresholds, solving the problems of low detection accuracy and poor real-time performance of traditional methods, and improving the stability and detection efficiency of the power system.

[0146] Those skilled in the art can realize that the units of the examples described in combination with the embodiments disclosed herein can be realized in electronic hardware, computer software or a combination of both. In order to clearly illustrate the interchangeability of hardware and software, the components of the examples have been described in general terms in the above description. Whether the functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.

[0147] In the embodiments of the present application, it should be understood that the division of units is only a logical functional division, and actual implementation can have another division manner, for example, multiple units can be combined as one unit, one unit can be split into multiple units, or some features can be ignored, etc.

[0148] In addition, each functional unit in each embodiment of the present application can be integrated in one processing unit, or each unit can exist physically, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of a software functional unit.

[0149] When the integrated unit is realized in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer readable storage medium. Based on such understanding, the technical solutions of the present application essentially or the part that contributes to the prior art or the whole or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in each embodiment of the present application. The foregoing storage medium includes: a U disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a mobile hard disk, a magnetic disk or an optical disk, and various program code storage media.

[0150] Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present application, and not to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: it can still modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacement for part or all of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present application, and they should be covered in the scope of the claims and the specification of the present application.

Claims

1. A method for detecting power consumption anomaly based on diffusion model, characterized in that, The method comprises the following steps: S1: collecting original index parameters of the power consumption unit, and generating structured first-level data through normalization processing; S2: dividing the first-level data into second-level sample sets with time sequence dependence according to time sequence characteristics; S3: taking the secondary sample set as a training set, injecting noise into the training set to train the neural network, obtaining a noise predictor neural network ε θ ; S4: Utilizing the noise predictor neural network ε θ The index parameter prediction of the future time is obtained, and a prediction result is obtained. S5: performing abnormality discrimination on the prediction result to obtain the abnormality detection result of the power consumption unit. 2.The diffusion model based power consumption anomaly detection method according to claim 1, characterized in that, In step S2, the first-level data is divided into second-level sample sets with time sequence dependence according to time sequence characteristics, including the following steps: S21: dividing the first-level data by taking continuous p records as a sample window to obtain n-p samples x; S22: arranging all parameters of the first p-1 records of each sample in chronological order as the characteristic value of the sample, arranging all parameters in the last 1 record as the label value of the sample, and dividing the sample into characteristics and labels; S23: dividing all samples into characteristics and labels to form a second-level sample set. 3.The diffusion model based power consumption anomaly detection method according to claim 1, characterized in that, In step S3, the secondary sample set is used as a training set, and the training set is used to train the neural network after injecting noise into the training set, to obtain a noise predictor neural network ε θ comprising the following steps: S31: taking the secondary sample set as the training set X train ; S32: The training set X train The values in the training set X train become completely random Gaussian noise after T-step noise is added. S33: input the noisy sample x t and the step number t into the noise predictor neural network ε θ to obtain the noise prediction value z t in x θ ; S34: By minimizing the prediction noise z θ And the actual added noise z t The mean square error between the two is used to optimize the noise predictor neural network ε using backpropagation and gradient descent methods. θ The parameters are determined, and a noise predictor neural network ε with optimal parameters is found through multiple rounds of training. θ This is used to detect noise in subsequent prediction samples. 4.The diffusion model based power consumption anomaly detection method according to claim 3, characterized in that, In step S33, the noisy sample x t The calculation formula is as follows: α t =1-β t ; where z t is a Gaussian noise; xo an initial state sample; β t is the noise intensity at the t-th step of the forward noise addition process.

5. The diffusion model-based power consumption anomaly detection method according to claim 4, characterized in that, In step S33, the noisy sample x t the previous state sample x t-1 The conditional probability distribution of the previous state sample x is calculated as follows: In the above formula, q(x) t-1 |x t x0) is the sample x t-1 The probability distribution of q(x); t |x t-1 Let be the probability distribution of the positive noise-adding process, representing the probability distribution from x. t-1 To x t The noise-adding transition probability; q(x) t-1 When |x0) is a known initial sample x0, x t-1 The probability distribution of q(x); t |x0) Given the initial sample x0, x t The probability distribution. 6.The diffusion model based power consumption anomaly detection method according to claim 3, characterized in that, In step S4, the noise predictor neural network ε θ The index parameter prediction for the future time is obtained, including the following steps: S41: input sample is feature data containing p records wherein the first p-1 records are historical records, and the pth record is a missing value; S42: filling the missing value part with Gaussian noise first to form a noisy sample; S43: Calculate X test Samples after adding noise by step t-1 The formula is as follows: In the above formula, represents X test z is a noisy sample to which noise of step t-1 is added; t-1 is a random Gaussian noise; is an initial state sample; S44: sample and X test Add random Gaussian noise of the same dimension and fill into X test Get noisy sample X T , X T Input the noise predictor neural network ε θ Get predicted noise Use predicted noise Calculate the mean of the T-1 step sample And variance Get the sample after denoising one step by the mean and variance of the T-1 step sample S45: binding and the contents of T-1 step of the sample X T-1 , S46: repeating the above steps S43 to S45 for T times to obtain a clean sample x0 conforming to the distribution of the training sample; the last record of the clean sample x0 is the prediction result. 7.The diffusion model based power consumption anomaly detection method according to claim 6, characterized in that, In step S45, the sample X T-1 The recombination formula is as follows: where m is an indicator matrix consisting of 0 and 1, with the same dimension as X test and ⊙ denotes element-wise multiplication.

8. A diffusion model-based power consumption anomaly detection system, characterized by, The method is applied to the power consumption abnormality detection method based on the diffusion model in any one of claims 1 to 7, and comprises: a collection module configured to collect original index parameters of the power consumption unit, and generate structured first-level data through normalization processing; a division module configured to divide the first-level data into second-level sample sets with time sequence dependence according to time sequence characteristics; a training module for training the neural network using the secondary sample set as a training set, injecting noise into the training set, and obtaining a noise predictor neural network ε θ ; a prediction module configured to utilize a noise predictor neural network ε θ a prediction of the indicator parameter at the future time instant, resulting in a prediction result; a discrimination module configured to perform abnormality discrimination on the prediction result to obtain the abnormality detection result of the power consumption unit.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium comprises a stored program, wherein the program controls the device where the computer-readable storage medium is located to execute the power consumption abnormality detection method based on the diffusion model in any one of claims 1 to 7 when the program is running.

10. A processor, comprising: The processor is configured to run a program, wherein the program executes the power consumption abnormality detection method based on the diffusion model in any one of claims 1 to 7 when the program is running.