Unsupervised energy consumption anomaly detection method, device and storage medium
The energy consumption sequence is preprocessed and feature extracted through unsupervised methods, the density clustering algorithm is used to generate pseudo-labels, and abnormal detection is performed in combination with the autoencoder reconstruction error, which solves the high cost and high cost of existing supervised energy consumption anomaly detection methods. The problem of low accuracy achieves more efficient and accurate detection of energy consumption abnormalities.
Patent Information
- Application Number
- CN202210181399.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-02-25
- Publication Date
- 2025-02-11
- Estimated Expiration
- 2042-02-25
AI Technical Summary
Existing supervised energy consumption abnormality detection methods are costly and have low accuracy, especially when data labeling costs are high and abnormal electricity usage probability is low.
Unsupervised methods are adopted to pre-process the energy consumption sequence, extract three-dimensional fusion features, and use density clustering algorithm to generate pseudo-labels, and abnormal detection is performed in combination with the autoencoder reconstruction error.
It reduces the cost of manual labeling, improves detection accuracy, is suitable for scenarios with unknown energy consumption mode clusters, and improves the ability to generalize different energy consumption scenarios.
Smart Images

Figure CN114781779B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data mining, and in particular to an unsupervised energy consumption anomaly detection method, equipment, device and computer storage medium. Background Art
[0002] With the improvement of people's living standards, building energy consumption in a narrow sense, that is, the operating energy consumption of buildings, which is people's daily energy consumption, such as heating, air conditioning, lighting, cooking, laundry, etc., has risen rapidly. It can be seen that it is very necessary for us to detect abnormal household electricity energy consumption.
[0003] At present, the main method for detecting anomalies in electricity consumption behavior is a supervised method. The problem with this method is that it requires the use of labeled data sets to train the model. However, in many real-world scenarios, the cost of manually labeling data is too high. In addition, the probability of abnormal electricity consumption behavior is low, and energy consumption data that has not been preprocessed is usually interfered by some redundant information, making the anomaly detection model insensitive to abnormal electricity consumption behavior and the accuracy of anomaly detection low.
[0004] Therefore, how to provide a low-cost and more accurate unsupervised energy consumption anomaly detection method is a problem that needs to be solved at present. Summary of the invention
[0005] To this end, the technical problem to be solved by the present invention is to overcome the problems of high cost and low precision of supervised anomaly detection methods in the prior art.
[0006] In order to solve the above technical problems, the present invention provides an unsupervised energy consumption anomaly detection method, device, apparatus and computer storage medium, including:
[0007] Preprocess the input original energy consumption sequence to obtain a completed energy consumption sequence;
[0008] Calculating the three-dimensional fusion features of each energy consumption data in the completed energy consumption sequence, wherein the three-dimensional fusion features include first-order difference features, second-order difference features, and regularity features;
[0009] A k-dist graph is obtained by using the three-dimensional fusion features of each energy consumption data in the completed energy consumption sequence, and an adaptive parameter of a density clustering algorithm is calculated according to the k-dist graph;
[0010] Based on the adaptive parameters, the density clustering algorithm is used to cluster the three-dimensional fusion features of each energy consumption data in the completed energy consumption sequence to generate an energy consumption pseudo label sequence;
[0011] Reconstructing the completed energy consumption sequence using an autoencoder to obtain a reconstructed energy consumption sequence, and calculating a data difference between the completed energy consumption sequence and the reconstructed energy consumption sequence to obtain an energy consumption sequence reconstruction error;
[0012] The energy consumption sequence reconstruction error input is classified by a classifier trained with the energy consumption pseudo-label sequence to obtain an anomaly detection result.
[0013] Preferably, the training of a classifier using the energy consumption pseudo-label sequence comprises:
[0014] Dividing the energy consumption sequence reconstruction error into an energy consumption sequence reconstruction error training set according to a preset ratio;
[0015] The SMOTE algorithm is used to resample the abnormal samples in the energy consumption series reconstruction error training set;
[0016] The resampled energy consumption sequence reconstruction error training set is input into the classifier, and the classifier is trained using the energy consumption pseudo label sequence.
[0017] Preferably, the step of preprocessing the input original energy consumption sequence to obtain the completed energy consumption sequence includes:
[0018] Set a sliding window with a length of k, and calculate the original energy consumption sequence {x i ,x i+1 ,…,x i+k The mean of Using μ to complete the missing values of the original energy consumption sequence;
[0019] The completed original energy consumption sequence is normalized to obtain the completed energy consumption sequence X={x 1 ,x 2 ,…,x n}, n is the number of energy consumption data points.
[0020] Preferably, the calculating of the three-dimensional fusion features of the completed energy consumption sequence includes:
[0021] Extract the energy consumption value x at time i in the completed energy consumption sequence X respectively i The first-order difference characteristic f id1 , second-order difference feature f id2 , regularity characteristics ir , forming the three-dimensional fusion feature (f id1 ,f id2 ,f ir ).
[0022] Preferably, the method of obtaining a k-dist graph by utilizing the three-dimensional fusion features of each energy consumption data in the completed energy consumption sequence, and calculating the adaptive parameters of the density clustering algorithm according to the k-dist graph includes:
[0023] Calculate the distance d between the three-dimensional fusion feature of each energy consumption data in the completed energy consumption sequence and its kth nearest neighbor fusion feature point, and obtain the k-dist sequence {d 1 ,d 2 ,…,d n};
[0024] Sort the k-dist sequence in ascending order to obtain a k-dist graph;
[0025] The adaptive parameter Eps of the DBSCAN algorithm is calculated through the k-dist graph.
[0026] Preferably, clustering the three-dimensional fusion features of each energy consumption data in the completed energy consumption sequence using the density clustering algorithm based on the adaptive parameters to generate an energy consumption pseudo label sequence includes:
[0027] Based on the adaptive parameters, the DBSCAN algorithm is used to cluster the three-dimensional fusion features of each energy consumption data in the completed energy consumption sequence to obtain multiple energy consumption pattern clusters;
[0028] The outlier 3D fusion feature points that do not belong to any of the energy consumption pattern clusters after clustering are marked as abnormal points, and other 3D fusion feature points are marked as normal points, to generate the energy consumption pseudo label sequence:
[0029]
[0030] Preferably, the step of reconstructing the completed energy consumption sequence using an autoencoder to obtain a reconstructed energy consumption sequence, and calculating a data difference between the completed energy consumption sequence and the reconstructed energy consumption sequence to obtain an energy consumption sequence reconstruction error includes:
[0031] Using a sliding window mechanism, an autoencoder model is constructed based on an LSTM network to reconstruct the completed energy consumption sequence to obtain a reconstructed energy consumption sequence;
[0032] The data difference between the completed energy consumption sequence and the reconstructed energy consumption sequence is calculated to obtain the energy consumption sequence reconstruction error.
[0033] The present invention also provides an unsupervised energy consumption anomaly detection device, comprising:
[0034] The preprocessing module preprocesses the input original energy consumption sequence to obtain a completed energy consumption sequence;
[0035] A three-dimensional fusion feature calculation module calculates the three-dimensional fusion features of each energy consumption data in the completed energy consumption sequence, wherein the three-dimensional fusion features include first-order difference features, second-order difference features, and regularity features;
[0036] An adaptive parameter calculation module, which uses the three-dimensional fusion features of each energy consumption data in the completed energy consumption sequence to obtain a k-dist graph, and calculates the adaptive parameters of the density clustering algorithm according to the k-dist graph;
[0037] A pseudo label sequence generation module, which clusters the three-dimensional fusion features of each energy consumption data in the completed energy consumption sequence using the density clustering algorithm based on the adaptive parameters to generate an energy consumption pseudo label sequence;
[0038] A reconstruction error calculation module, which uses an autoencoder to reconstruct the completed energy consumption sequence to obtain a reconstructed energy consumption sequence, and calculates a data difference between the completed energy consumption sequence and the reconstructed energy consumption sequence to obtain an energy consumption sequence reconstruction error;
[0039] The anomaly detection module classifies the energy consumption sequence reconstruction error input into a classifier trained with the energy consumption pseudo-label sequence to obtain an anomaly detection result.
[0040] The present invention also provides an unsupervised energy consumption anomaly detection device, comprising:
[0041] Memory for storing computer programs;
[0042] A processor is used to implement the steps of the above-mentioned unsupervised energy consumption anomaly detection method when executing the computer program.
[0043] The present invention also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned method for unsupervised energy consumption anomaly detection are implemented.
[0044] The above technical solution of the present invention has the following advantages compared with the prior art:
[0045] The present invention calculates three-dimensional fusion features, extracts differential features and regularity features of energy consumption data, more accurately describes the energy consumption data sequence, avoids the interference of redundant features, improves the calculation speed and effectively improves the accuracy of anomaly detection; extracts pseudo labels of energy consumption sequences through an adaptive density clustering algorithm, avoids the problem of supervised anomaly detection model relying on labeled data; does not need to set the number of clustering categories, which makes the present invention suitable for scenarios when the number of energy consumption pattern clusters is unknown; the adaptive parameter mechanism makes full use of the various features of energy consumption data, enhances the generalization ability of different energy consumption scenarios, and makes the method of the present invention more suitable for real tasks; uses pseudo labels to guide the classification of reconstruction errors, overcomes the difficulty of setting thresholds for classifying reconstruction errors, and the anomaly detection accuracy of the present invention is also better than setting fixed thresholds to classify reconstruction errors. The present invention adopts an unsupervised anomaly detection method, reduces labor costs, is more suitable for real scenarios, and improves anomaly detection accuracy and speed. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] In order to make the content of the present invention more clearly understood, the present invention is further described in detail below according to specific embodiments of the present invention in conjunction with the accompanying drawings, wherein:
[0047] Figure 1 It is a flow chart of the implementation of the unsupervised energy consumption anomaly detection method of the present invention;
[0048] Figure 2 It is the algorithm flow chart of the present invention;
[0049] Figure 3 is the k-dist graph of the present invention;
[0050] Figure 4 This is the LSTM autoencoder model diagram;
[0051] Figure 5 A structural block diagram of an unsupervised energy consumption anomaly detection device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0052] The core of the present invention is to provide an unsupervised energy consumption anomaly detection method, device, equipment and computer storage medium, which reduces labor costs and improves detection accuracy.
[0053] In order to enable those skilled in the art to better understand the scheme of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific implementation methods. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0054] Please refer to Figure 1 , Figure 1 The following is a flowchart of the unsupervised energy consumption anomaly detection method provided by the present invention; the specific operation steps are as follows:
[0055] S101: preprocessing the input original energy consumption sequence to obtain a completed energy consumption sequence;
[0056] Set a sliding window with a length of k, and calculate the original energy consumption sequence {x i ,x i+1 ,…,x i+k The mean of Using μ to complete the missing values of the original energy consumption sequence;
[0057] The completed original energy consumption sequence is normalized to obtain the completed energy consumption sequence X={x 1,x 2 ,…,x n}, n is the number of energy consumption data points.
[0058] S102: Calculating the three-dimensional fusion features of each energy consumption data in the completed energy consumption sequence, wherein the three-dimensional fusion features include first-order difference features, second-order difference features, and regularity features;
[0059] Extract the energy consumption value x at time i in the completed energy consumption sequence X respectively i The first-order difference characteristic f id1 , second-order difference feature f id2 , regularity characteristics ir , forming the three-dimensional fusion feature (f id1 ,f id2 ,f ir ).
[0060] S103: obtaining a k-dist graph using the three-dimensional fusion features of each energy consumption data in the completed energy consumption sequence, and calculating adaptive parameters of a density clustering algorithm according to the k-dist graph;
[0061] Calculate the distance d between the three-dimensional fusion feature of each energy consumption data in the completed energy consumption sequence and its kth nearest neighbor fusion feature point, and obtain the k-dist sequence {d 1 ,d 2 ,…,d n};
[0062] Sort the k-dist sequence in ascending order to obtain a k-dist graph;
[0063] The adaptive parameter Eps of the DBSCAN algorithm is calculated through the k-dist graph.
[0064] S104: clustering the three-dimensional fusion features of each energy consumption data in the completed energy consumption sequence using the density clustering algorithm based on the adaptive parameters to generate an energy consumption pseudo label sequence;
[0065] Based on the adaptive parameters, the DBSCAN algorithm is used to cluster the three-dimensional fusion features of each energy consumption data in the completed energy consumption sequence to obtain multiple energy consumption pattern clusters;
[0066] The outlier 3D fusion feature points that do not belong to any of the energy consumption pattern clusters after clustering are marked as abnormal points, and other 3D fusion feature points are marked as normal points, to generate the energy consumption pseudo label sequence:
[0067]
[0068] S105: reconstructing the completed energy consumption sequence using an autoencoder to obtain a reconstructed energy consumption sequence, and calculating a data difference between the completed energy consumption sequence and the reconstructed energy consumption sequence to obtain an energy consumption sequence reconstruction error;
[0069] Using a sliding window mechanism, an autoencoder model is constructed based on an LSTM network to reconstruct the completed energy consumption sequence to obtain a reconstructed energy consumption sequence;
[0070] The data difference between the completed energy consumption sequence and the reconstructed energy consumption sequence is calculated to obtain the energy consumption sequence reconstruction error.
[0071] S106: Input the energy consumption sequence reconstruction error into a classifier trained with the energy consumption pseudo-label sequence for classification to obtain an anomaly detection result.
[0072] Dividing the energy consumption sequence reconstruction error into an energy consumption sequence reconstruction error training set according to a preset ratio;
[0073] The SMOTE algorithm is used to resample the abnormal samples in the energy consumption series reconstruction error training set;
[0074] The resampled energy consumption sequence reconstruction error training set is input into the classifier, and the classifier is trained using the energy consumption pseudo label sequence.
[0075] Figure 2 The diagram represents the algorithm model of the present invention. The algorithm is an unsupervised framework and is suitable for unlabeled data in real application scenarios. The model includes four key parts: a three-dimensional fusion feature extraction module, a DBSCAN clustering module for obtaining pseudo labels, an LSTM autoencoder module for reconstructing energy consumption data, and an anomaly classifier module. Among them, the upper left block diagram includes three-dimensional fusion feature extraction and pseudo label acquisition, and the pseudo label acquisition module adopts the DBSCAN algorithm with adaptive parameters. The lower block diagram contains an LSTM autoencoder, and this reconstructed energy consumption data network is constructed using LSTM. Finally, the pseudo labels are used to guide the classification task of the reconstruction error and realize the anomaly detection function.
[0076] The present invention calculates three-dimensional fusion features, extracts differential features and regularity features of energy consumption data, describes the energy consumption data sequence more accurately, avoids the interference of redundant features, improves the calculation speed and effectively improves the accuracy of anomaly detection; extracts pseudo labels of energy consumption sequences through adaptive density clustering algorithm, avoids the problem of supervised anomaly detection model relying on labeled data; does not need to set the number of clustering categories, which makes the present invention suitable for scenarios when the number of energy consumption pattern clusters is unknown; the adaptive parameter mechanism makes full use of the various features of energy consumption data, enhances the generalization ability of different energy consumption scenarios, and makes the method of the present invention more suitable for real tasks; uses SMOTE to resample abnormal samples, balances positive and negative samples, and improves the sensitivity of the model to power consumption anomalies; uses LSTM autoencoder to reconstruct energy consumption data and fully extracts time series information; uses pseudo labels to guide the classification of reconstruction errors, overcomes the difficulty of setting thresholds for classifying reconstruction errors, and the anomaly detection accuracy of the present invention is also better than setting fixed thresholds to classify reconstruction errors. The present invention uses pseudo labels to guide the classification of reconstruction errors, realizes unsupervised anomaly detection, and overcomes the dependence on label data. In particular, the key features of energy consumption data are extracted, and an adaptive parameter DBSCAN algorithm is used to generate pseudo labels for energy consumption data to avoid the problem of difficult parameter selection in different scenarios. The energy consumption data is reconstructed using LSTM autoencoders, which fully extracts the time series information, balances the positive and negative samples, and uses pseudo labels to guide the classification of reconstruction errors, making the classification effect better and achieving higher anomaly detection accuracy.
[0077] Based on the above embodiments, the present invention further describes the above steps in detail, as follows:
[0078] S201: Assume x i-1 For missing values, a sliding window with a length of k is set, and the original energy consumption sequence {x i ,x i+1 ,…,x i+k The mean of Use μ to replace the missing value x of the original energy consumption sequence i-1 To complete;
[0079] In this embodiment, K=8;
[0080] This step can also be replaced by other missing value filling methods, such as maximum likelihood estimation, multiple interpolation and other methods.
[0081] S202: Extract the energy consumption value x at time i in the completed energy consumption sequence X respectively i The first-order difference feature f of (i∈1,2,…,n) id1 =x i -x i-1, Second-order difference feature f id2 = x i - x i-2 , Regularity feature f ir = x i , constituting the three-dimensional fusion feature (f id1 , f id2 , f ir );
[0082] Among them, the extraction steps of the regularity feature f ir are as follows: First, divide the original data into p subsequences, and its set S can be expressed as S = {s 1 , s 2 , …, s p}, where the calculation method of the m-th sequence is s m = {x m , x m+p , …, x m+k*p}, m ∈ 1, 2, …, p, m + k * p ≤ n < m + (k + 1) * p. Secondly, calculate the median of each subsequence x i 's regularity feature is expressed as f ir = x i ;
[0083] In this embodiment, p = 24.
[0084] S203: Using the three-dimensional fusion feature as the input, based on the Euclidean distance, calculate the distance d from each fusion feature (f id1 , f id2 , f ir ) to its k-th nearest neighbor fusion feature point, and obtain the k-dist sequence {d 1 , d 2 , …, d n}. Sort the k-dist in ascending order to obtain the k-dist graph, and calculate the parameter Eps for defining the neighborhood radius of DBSCAN based on the inflection points in the k-dist graph;
[0085] The k-dist graph is as Figure 3 shown;
[0086] In this embodiment, k is 5, and the DBSCAN threshold Minpts is also set to 5;
[0087] The specific implementation of calculating the inflection points in the present invention is as follows: For other points i in the LSTM graph except the start point S and the end point E, it is expressed as The vector from point i to the start point S is expressed as The vector from point i to the end point E is expressed as The cosine of the angle between the two vectors is expressed as Calculate the k-dist graph for all points except the start and end points Vector Sum The cosθ value of the vector. The point with the smallest cosθ value is defined as the inflection point d turning , get the k-dist value of the inflection point In addition, the value of the median point in the k-dist plot is expressed as The method for calculating the adaptive parameter Eps is expressed as
[0088] In this embodiment, α=2, β=1.
[0089] S204: Based on the obtained adaptive parameter Eps, the DBSCAN clustering algorithm is used to cluster the three-dimensional fusion features of each energy consumption data in the completed energy consumption sequence to obtain different energy consumption pattern clusters, and the outlier three-dimensional fusion feature points that do not belong to any pattern cluster are marked as abnormal points, and other three-dimensional fusion feature points are marked as normal points to obtain an energy consumption pseudo label sequence;
[0090] In this embodiment, the density clustering algorithm adopts the DBSCAN algorithm, which can be transformed into other density clustering algorithms, for example, the Maximum Density Clustering Algorithm (MDCA) and the like.
[0091] S205: Using the sliding window mechanism, extract the energy consumption sequence {x i ,x i+1 ,…,x i+u}, where u is the length of the sliding window, the energy consumption sequence is fed into the LSTM autoencoder model to extract the timing information, and the output of the last unit is used Reconstruction energy consumption x′ i , and obtain the reconstructed energy consumption sequence {x′ i ,x′ i+1 ,…,x′ i+u}, calculate the data difference between the completed energy consumption sequence and the reconstructed energy consumption sequence to obtain the reconstructed error sequence {x′ i ,x′ i+1 ,…,x′ i+u}{x′ i ,x′ i+1 ,…,x′ i+u};
[0092] The LSTM autoencoder model is shown in the figure Figure 4 As shown, in this embodiment, u is set to 128;
[0093] For reconstruction error, SMOTE is used to resample abnormal samples to balance positive and negative samples;
[0094] In this embodiment, the ratio of normal samples to abnormal samples after resampling is set to 1:1.
[0095] S206: Using the energy consumption pseudo-label sequence to guide the training of the reconstruction error classifier, and using the trained classifier to perform anomaly detection.
[0096] In this embodiment, a single-layer neural network is used as a classifier, whose input is a reconstruction error sequence. The acquired energy consumption pseudo-label sequence is used to guide the training of the neural network, and a trained classifier is obtained to classify the reconstruction errors and perform anomaly detection.
[0097] Based on the above embodiments, in order to verify the accuracy and robustness of the present invention, the present invention conducted experiments on a certain university energy consumption data set, as follows:
[0098] This energy consumption dataset contains energy consumption data of 12 buildings with different uses, including accommodation, scientific research, teaching, and canteen. The data start and end time is 2020.6.1-2020.12.31, with a sampling rate of one data point per hour, totaling 157,248 sampling points.
[0099] In the experiment, the data set is divided into two parts, as a training set and a test set. The abnormality ratio in the training set is 0.09%, and the abnormality ratio in the test set is 0.06%. In the experiment, precision, recall and F1 score are selected as evaluation indicators.
[0100] In this embodiment, the parameters of the single-layer neural network for training the LSTM autoencoder and training the reconstruction error classification are shown in Table 1:
[0101] Table 1 Experimental parameter settings
[0102] Model Number of training samples Number of test samples Learning Rate Iterations LSTM Autoencoder 1 / 2 1 / 2 0.0003 50 Reconstruction Error Classification Network 1 / 2 1 / 2 0.001 50
[0103] In order to verify the advantages of the proposed unsupervised framework for pseudo-label anomaly detection PLAD, the comparative experiments conducted in this paper are shown in Table 2. The comparison objects are unsupervised anomaly detection models based on KNN, CBLOF, IF, HBOS, and PCA. The present invention achieves the best performance in all indicators:
[0104] Table 2 Comparative experimental results
[0105] method Precision Recall F1 score PLAD 0.9998 0.9838 0.9918 KNN 0.9995 0.9092 0.9522 CBLOF 0.9997 0.8965 0.9453 IF 0.9998 0.8940 0.9440 HBOS 0.9997 0.9602. 0.9795 PCA 0.9998 0.8972 0.9457
[0106] The present invention discloses an unsupervised energy consumption anomaly detection method PLAD that utilizes pseudo labels to guide the classification of reconstruction errors. The method proposes an adaptive pseudo label anomaly detection framework, which utilizes pseudo labels to guide the classification of energy consumption data reconstruction errors, thereby overcoming the dependence of supervised anomaly detection methods on label data. The anomaly detection framework designed by the present invention comprises two parts: an adaptive pseudo label part and an LSTM autoencoder part. The adaptive pseudo label part first extracts differential features and regularity features from energy consumption data, and obtains a K-dist graph through these features, and then uses the K-dist graph to obtain the adaptive parameters of the DBSCAN algorithm, generates pseudo labels for energy consumption data, and solves the problem of difficult parameter selection in different scenarios. The LSTM autoencoder part reconstructs the energy consumption data to obtain the reconstruction error of the energy consumption data. Finally, the present invention combines the two parts, utilizes pseudo labels to guide the classification of energy consumption data reconstruction errors, and obtains the result of energy consumption data anomaly detection.
[0107] Please refer to Figure 5 , Figure 5 A structural block diagram of an unsupervised energy consumption anomaly detection device provided by an embodiment of the present invention; the specific device may include:
[0108] The preprocessing module 100 is used to preprocess the input original energy consumption sequence to obtain a completed energy consumption sequence;
[0109] A three-dimensional fusion feature calculation module 200 is used to calculate the three-dimensional fusion features of each energy consumption data in the completed energy consumption sequence, wherein the three-dimensional fusion features include first-order difference features, second-order difference features, and regularity features;
[0110] An adaptive parameter calculation module 300, used to obtain a k-dist graph using the three-dimensional fusion features of each energy consumption data in the completed energy consumption sequence, and calculate the adaptive parameters of the density clustering algorithm according to the k-dist graph;
[0111] A pseudo label sequence generating module 400 is used to cluster the three-dimensional fusion features of each energy consumption data in the completed energy consumption sequence using the density clustering algorithm based on the adaptive parameters to generate an energy consumption pseudo label sequence;
[0112] The reconstruction error calculation module 500 is used to reconstruct the completed energy consumption sequence using an autoencoder to obtain a reconstructed energy consumption sequence, and calculate the data difference between the completed energy consumption sequence and the reconstructed energy consumption sequence to obtain an energy consumption sequence reconstruction error;
[0113] The anomaly detection module 600 is used to input the energy consumption sequence reconstruction error into a classifier trained with the energy consumption pseudo-label sequence for classification to obtain an anomaly detection result.
[0114] The unsupervised energy consumption anomaly detection device of this embodiment is used to implement the aforementioned unsupervised energy consumption anomaly detection method. Therefore, the specific implementation method of the unsupervised energy consumption anomaly detection device can be seen in the embodiment part of the unsupervised energy consumption anomaly detection method in the previous text. For example, the preprocessing module 100, the three-dimensional fusion feature calculation module 200, the adaptive parameter calculation module 300, the pseudo-label sequence generation module 400, the reconstruction error calculation module 500, and the anomaly detection module 600 are respectively used to implement steps S101, S102, S103, S104, S105 and S106 in the above-mentioned unsupervised energy consumption anomaly detection method. Therefore, its specific implementation method can refer to the description of the corresponding various parts of the embodiment, which will not be repeated here.
[0115] A specific embodiment of the present invention further provides a device for unsupervised energy consumption anomaly detection, comprising: a memory for storing a computer program; and a processor for implementing the steps of the above-mentioned method for unsupervised energy consumption anomaly detection when executing the computer program.
[0116] A specific embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned method for unsupervised energy consumption anomaly detection are implemented.
[0117] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0118] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0119] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0120] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0121] Obviously, the above embodiments are merely examples for the purpose of clear explanation and are not intended to limit the implementation methods. For those skilled in the art, other different forms of changes or modifications can be made based on the above description. It is not necessary and impossible to list all the implementation methods here. The obvious changes or modifications derived therefrom are still within the scope of protection of the present invention.
Claims
1. An unsupervised energy consumption anomaly detection method for electricity consumption behavior, characterized in that: include: Preprocess the input original energy consumption sequence to obtain a completed energy consumption sequence; Specifically include: Set a sliding window of length k and calculate the original energy consumption sequence {xi, xi+1, ,xi+k} , use μ to complete the missing values of the original energy consumption sequence; The completed original energy consumption sequence is normalized to obtain the completed energy consumption sequence X = {x1, x2, ,xn}, n is the number of energy consumption data points; Calculating the three-dimensional fusion features of each energy consumption data in the completed energy consumption sequence, wherein the three-dimensional fusion features include first-order difference features, second-order difference features, and regularity features; wherein calculating the three-dimensional fusion features of each energy consumption data in the completed energy consumption sequence includes: Extract the energy consumption value at time i in the completed energy consumption sequence X respectively The first-order difference characteristics of , second-order difference characteristics , regularity characteristics , constituting the three-dimensional fusion feature ; The k-dist graph is obtained by using the three-dimensional fusion features of each energy consumption data in the completed energy consumption sequence, and the adaptive parameters of the density clustering algorithm are calculated according to the k-dist graph; which specifically includes: Calculate the distance d between the three-dimensional fusion feature of each energy consumption data in the completed energy consumption sequence and its kth nearest neighbor fusion feature point, and obtain the k − dist sequence {d1, d2, , dn}; sorting the k − dist sequence in ascending order to obtain a k − dist graph; The adaptive parameter Eps of the DBSCAN algorithm is calculated through the k-dist graph, which specifically includes: Get the vector representation of other points i in the k-dist graph except the starting point S and the ending point E to the starting point S , and the vector representation from point i to the end point E ; where point i is represented by ; Calculate the k-dist value for all points in the graph except the start and end points. Vector Sum Vector value, the minimum The point corresponding to the value is taken as the inflection point, and the k-dist value of the inflection point is obtained; Based on the k-dist value of the inflection point and the k-dist value of the median point of the k − dist graph, the adaptive parameter Eps is calculated. The calculation formula of the adaptive parameter Eps is: , in, The k-dist value representing the inflection point; k-dist value representing the median point of the k − dist plot; ; ; Based on the adaptive parameters, the density clustering algorithm is used to cluster the three-dimensional fusion features of each energy consumption data in the completed energy consumption sequence to generate an energy consumption pseudo label sequence; which specifically includes: Based on the adaptive parameters, the DBSCAN algorithm is used to cluster the three-dimensional fusion features of each energy consumption data in the completed energy consumption sequence to obtain multiple energy consumption pattern clusters; The outlier 3D fusion feature points that do not belong to any of the energy consumption pattern clusters after clustering are marked as abnormal points, and other 3D fusion feature points are marked as normal points, to generate the energy consumption pseudo label sequence: Y = { , , ⋯ , } , ∈ {0,1}; The completed energy consumption sequence is reconstructed by using an autoencoder to obtain a reconstructed energy consumption sequence, and the data difference between the completed energy consumption sequence and the reconstructed energy consumption sequence is calculated to obtain an energy consumption sequence reconstruction error; which specifically includes: Using a sliding window mechanism, an autoencoder model is constructed based on an LSTM network to reconstruct the completed energy consumption sequence to obtain a reconstructed energy consumption sequence; Calculating the data difference between the completed energy consumption sequence and the reconstructed energy consumption sequence to obtain the energy consumption sequence reconstruction error; The energy consumption sequence reconstruction error input is classified by a classifier trained with the energy consumption pseudo label sequence to obtain an abnormality detection result; wherein, training the classifier with the energy consumption pseudo label sequence includes: Dividing the energy consumption sequence reconstruction error into an energy consumption sequence reconstruction error training set according to a preset ratio; Resampling the abnormal samples in the energy consumption sequence reconstruction error training set using the SMOTE algorithm; The resampled energy consumption sequence reconstruction error training set is input into the classifier, and the classifier is trained using the energy consumption pseudo label sequence.
2. A device for unsupervised energy consumption anomaly detection for electricity consumption behavior, characterized in that: include: The preprocessing module preprocesses the input original energy consumption sequence to obtain a completed energy consumption sequence; Specifically include: Set a sliding window of length k and calculate the original energy consumption sequence {xi, xi+1, , the mean of xi+k} , use μ to complete the missing values of the original energy consumption sequence; The completed original energy consumption sequence is normalized to obtain the completed energy consumption sequence X = {x1, x2, ,xn}, n is the number of energy consumption data points; A three-dimensional fusion feature calculation module calculates the three-dimensional fusion features of each energy consumption data in the completed energy consumption sequence, wherein the three-dimensional fusion features include first-order difference features, second-order difference features, and regularity features; wherein calculating the three-dimensional fusion features of each energy consumption data in the completed energy consumption sequence includes: Extract the energy consumption value at time i in the completed energy consumption sequence X respectively The first-order difference characteristics of , second-order difference characteristics , regularity characteristics , constituting the three-dimensional fusion feature ; The adaptive parameter calculation module uses the three-dimensional fusion features of each energy consumption data in the completed energy consumption sequence to obtain a k-dist graph, and calculates the adaptive parameters of the density clustering algorithm according to the k-dist graph; it specifically includes: Calculate the distance d between the three-dimensional fusion feature of each energy consumption data in the completed energy consumption sequence and its kth nearest neighbor fusion feature point, and obtain the k − dist sequence {d1, d2, , dn}; sorting the k − dist sequence in ascending order to obtain a k − dist graph; The adaptive parameter Eps of the DBSCAN algorithm is calculated through the k-dist graph, which specifically includes: Get the vector representation of other points i in the k-dist graph except the starting point S and the ending point E to the starting point S , and the vector representation from point i to the end point E ; where point i is represented by ; Calculate the k-dist value for all points in the graph except the start and end points. Vector Sum Vector value, the minimum The point corresponding to the value is taken as the inflection point, and the k-dist value of the inflection point is obtained; Based on the k-dist value of the inflection point and the k-dist value of the median point of the k − dist graph, the adaptive parameter Eps is calculated. The calculation formula of the adaptive parameter Eps is: , in, The k-dist value representing the inflection point; k-dist value representing the median point of the k − dist plot; ; ; The pseudo label sequence generation module clusters the three-dimensional fusion features of each energy consumption data in the completed energy consumption sequence using the density clustering algorithm based on the adaptive parameters to generate an energy consumption pseudo label sequence; it specifically includes: Based on the adaptive parameters, the DBSCAN algorithm is used to cluster the three-dimensional fusion features of each energy consumption data in the completed energy consumption sequence to obtain multiple energy consumption pattern clusters; The outlier 3D fusion feature points that do not belong to any of the energy consumption pattern clusters after clustering are marked as abnormal points, and other 3D fusion feature points are marked as normal points, to generate the energy consumption pseudo label sequence: Y = { , , ⋯ , } , ∈ {0,1}; The reconstruction error calculation module reconstructs the completed energy consumption sequence using an autoencoder to obtain a reconstructed energy consumption sequence, and calculates the data difference between the completed energy consumption sequence and the reconstructed energy consumption sequence to obtain an energy consumption sequence reconstruction error; it specifically includes: Using a sliding window mechanism, an autoencoder model is constructed based on an LSTM network to reconstruct the completed energy consumption sequence to obtain a reconstructed energy consumption sequence; Calculating the data difference between the completed energy consumption sequence and the reconstructed energy consumption sequence to obtain the energy consumption sequence reconstruction error; The anomaly detection module inputs the energy consumption sequence reconstruction error into a classifier trained with the energy consumption pseudo label sequence to obtain an anomaly detection result; wherein, training the classifier with the energy consumption pseudo label sequence includes: Dividing the energy consumption sequence reconstruction error into an energy consumption sequence reconstruction error training set according to a preset ratio; Resampling the abnormal samples in the energy consumption sequence reconstruction error training set using the SMOTE algorithm; The resampled energy consumption sequence reconstruction error training set is input into the classifier, and the classifier is trained using the energy consumption pseudo label sequence.
3. A device for unsupervised energy consumption anomaly detection for electricity consumption behavior, characterized in that: include: Memory for storing computer programs; A processor is used to implement the steps of the method for unsupervised energy consumption anomaly detection for electricity usage behavior as claimed in claim 1 when executing the computer program.
4. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by the processor, the steps of the method for unsupervised energy consumption anomaly detection for electricity consumption behavior as claimed in claim 1 are implemented.
Citation Information
Patent Citations
Self-adaptive unsupervised online network anomaly detection method based on KPI mutation
CN110995508A
Iterative clustering network traffic anomaly detection method
CN113242207A