Power loop energy consumption detection method and device based on joint error stacking model
By constructing a joint error stacking model, combining an LSTM network and an adversarial autoencoder to learn energy consumption characteristics and distribution patterns, and combining it with an OCSVM single classifier, the problem of difficulty in determining abnormal thresholds in power circuit energy consumption detection is solved, and efficient and accurate abnormal energy consumption detection is achieved.
Patent Information
- Application Number
- CN202311075326.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-24
- Publication Date
- 2025-11-25
- Estimated Expiration
- 2043-08-24
AI Technical Summary
Existing power circuit energy consumption monitoring systems are unable to effectively detect abnormal power consumption states of power circuits, especially abnormal energy consumption that combines unnecessary energy consumption with time characteristics. Traditional methods are unable to take into account both data characteristics and global distribution patterns, and lack the ability to automatically determine abnormal thresholds.
A joint error stacking model is constructed, including a multivariate temporal prediction network and an adversarial autoencoder model. Combined with the OCSVM single classifier, abnormal energy consumption is determined by prediction error and reconstruction error. The LSTM network is used for multivariate energy consumption prediction, the autoencoder learns the energy consumption distribution law, and the OCSVM is used for final determination.
It enables accurate detection of abnormal energy consumption in power circuits, avoids manually setting thresholds, improves detection efficiency and accuracy, and is suitable for diverse and highly correlated power circuit energy consumption detection tasks.
Smart Images

Figure CN117113202B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the technical field of power loop energy consumption detection, and particularly relates to a power loop energy consumption detection method and device based on a joint error stacking model. BACKGROUND
[0002] The power loop energy consumption monitoring system: power loop energy consumption monitoring is of great significance to building energy consumption control and electrical safety. Abnormal energy consumption detection of the power loop mainly detects abnormal power consumption states of the power loop. In addition to the extreme value abnormality of the energy consumption of the electrical equipment itself, it also includes unnecessary energy consumption of the electrical equipment, such as continuous energy consumption of indoor lighting loop at night and continuous energy consumption of office loop during off-work period. These all cause energy waste phenomenon of the building. Serious abnormal energy consumption may even cause safety accidents. Detecting abnormal energy consumption of abnormal power consumption states of the power loop can not only achieve precise energy saving of electrical appliances to a certain extent, but also prolong the physical service life of the power loop, reduce the possibility of disasters, and improve the energy consumption control ability and electrical safety of public buildings.
[0003] The detection of abnormal energy consumption of the power loop belongs to the technical field of time series anomaly detection. Common time series anomaly detection methods mostly find anomalies from data distribution, ignoring the individual characteristics and business fluctuations of the data, and are difficult to balance data features and global distribution rules. Most of them can only detect some mutation points of time series data. Although part of the abnormal energy consumption has certain differences with the distribution rule of normal energy consumption, however, part of the abnormal energy consumption such as idle energy consumption needs to be combined with time and other characteristics to determine whether it is abnormal. In addition, the traditional time series anomaly detection method is difficult to determine the abnormal threshold.
[0004] Stacking model: The stacking model is composed of multiple layers of models, mostly two layers. By using the output results from multiple models in the upper layer, the final judgment is made on the next layer of models, which can play the advantages of different models. The stacking model often performs better than a single model.
[0005] Prediction model: The prediction model uses multiple feature data to predict the dependent variable. In time series data, recurrent neural networks such as LSTM are commonly used multivariate prediction models, which can solve the problem of long sequence input that cannot be handled by traditional RNN models.
[0006] Reconstruction model: The reconstruction model is a kind of deep generative model. In time series data, the reconstruction of time series data is realized by learning the global distribution rule of time series data. AAE (Adversarial Autoencoder) is a commonly used generative reconstruction model.
[0007] OCSVM: OCSVM is a single classifier model based on the idea of semi-supervised, which only requires single sample data for training input data, and OCSVM single classifier can classify samples that meet the class and abnormal samples that do not meet the class through learning of single sample, the classifier outputs 1 to represent that the sample meets the class of training data, and outputs -1 to represent that the detection sample is an abnormal sample, and the OCSVM single classifier has the detection ability of singular value. SUMMARY
[0008] The present application is aimed at the real-time monitoring of the power hour energy consumption data of the energy consumption monitoring system, and combines the historical energy consumption data of the loop and the energy consumption influence characteristics of the loop. The present application proposes a power loop abnormal energy consumption detection method based on a joint error stacking model to detect the abnormal power consumption state of the power loop. And based on the prediction idea and the reconstruction idea of the time series anomaly detection method, a joint error stacking model is proposed. The upper layer of the stacking model respectively constructs a multivariate time series prediction network and an adversarial autoencoder model, and calculates the prediction error and reconstruction error of the loop hour energy consumption. Since the loop has diversity, it is difficult to determine the abnormal threshold value by simply using the error or abnormal score based method. The present application uses an OCSVM single classifier as the lower layer model of the stacking model, and finally determines the abnormal energy consumption according to the prediction error and reconstruction error data output by the upper layer model. Including the following steps:
[0009] Collect data and perform pretreatment; construct standard loop energy consumption time series data with an interval of one hour;
[0010] Construct a multivariate energy consumption prediction network to predict the loop hour energy consumption value at the detection time point using the historical energy consumption data;
[0011] Construct an adversarial autoencoder reconstruction model to learn the global distribution rule of the energy consumption time series data and reconstruct the detection time series window;
[0012] Calculate the prediction error according to the predicted value, calculate the hour energy consumption reconstruction error using the reconstructed time series window, and jointly train the OCSVM single classifier;
[0013] Input the prediction error and reconstruction error of the energy consumption at the detection time into the trained OCSVM single classifier to detect the loop abnormal energy consumption.
[0014] Further, data collection and preprocessing, first of all, the historical energy consumption data stored in the energy consumption monitoring platform is collected and preprocessed by using python, 24 months of historical hourly energy consumption data are pulled from the detection date to the past two years, and the standard energy consumption time series data is transformed according to the energy consumption record time and hourly energy consumption value. For the missing part in the energy consumption time series, the mean of the non-empty hourly energy consumption data of the adjacent two days is used for preliminary missing filling, and finally the standard hourly loop energy consumption time series data is constructed.
[0015] Further, in order to better utilize the prediction network to capture the energy consumption characteristics, a multivariate energy consumption prediction network is constructed, including:
[0016] 2.1) Analysis and mining of energy consumption influence characteristics. The selection of characteristics determines the upper limit of the prediction accuracy. The model only constantly approaches this upper limit, so the feature analysis and mining of energy consumption influencing factors are beneficial to improve the prediction accuracy and reduce the prediction error. The hourly energy consumption of the power loop is affected by many factors, among which the most important ones are time factor and weather factor. The time factor mainly includes date characteristics such as year, month, day, season, week, hour and holiday characteristics such as whether it is a holiday or a working day. The above characteristics are constructed by using the recorded time stamp. The weather factors mainly include maximum temperature, minimum temperature, humidity, weather, pollution index and wind force, and the multivariate influence characteristics constructed in step 2.1 are spliced with the standard hourly energy consumption time series data to serve as the training data of the multivariate energy consumption prediction network.
[0017] 2.2) Construction of LSTM multivariate energy consumption prediction network. LSTM is a kind of recurrent neural network, which can solve the problem that traditional RNN network cannot process long sequence input data. The present application uses LSTM network as the basic network of multivariate energy consumption prediction network, and constructs a double-layer bidirectional LSTM energy consumption prediction network on the basis of the basic network. The multivariate characteristic energy consumption time series data obtained in step 2.1 is divided by using time sequence window, so as to convert each prediction sample into a two-dimensional matrix containing historical data. In the process of network construction, the divided two-dimensional matrix time sequence window data is input into the first layer bidirectional LSTM neural network, and the output thereof is taken as the input of the second layer bidirectional LSTM neural network. The final output hidden layer state is taken as the feature vector of hourly energy consumption prediction, and the final prediction value is output through the full connection network.
[0018] 2.3) Training the Multivariate Energy Consumption Prediction Network. First, abnormal energy consumption data in the training and validation sets are standardized and corrected using a missing-filling algorithm to simulate normal energy consumption hourly time-series data. The data in the test set remains unchanged. Before model training, the corresponding hyperparameters need to be set: the sliding window size for splitting the original dataset, the time step and feature dimension of the LSTM neural network input layer, the number of neurons in each LSTM layer (the number of neurons in both directions is consistent), and the optimizer, batch size, and loss function. Considering prediction accuracy, the MSE (L1 paradigm) loss function is chosen. The error loss decrease curves of the training and validation sets are observed. Model training is stopped when the validation set loss no longer decreases, while the model parameters are retained.
[0019] Furthermore, the prediction model is built upon multi-feature energy consumption data, which can well take into account external factors and has high accuracy in hourly single-step prediction. It can also consider the business data characteristics of loop energy consumption itself. However, it lacks the ability to capture the global distribution pattern of energy consumption time series data. Since the prediction model is a single-point prediction and relies on historical data, the predicted value is easily affected by nearby abnormal time series when facing sequence anomalies. Therefore, it is necessary to consider the global distribution of the data. Thus, an adversarial autoencoder reconstruction model is constructed to learn the potential distribution pattern of energy consumption time series. The specific steps are as follows:
[0020] 3.1) Training Data Preprocessing. Unlike the data processing for the prediction model, the reconstruction model only uses energy consumption time series data. Define the loop energy consumption time series X = {x1, x2, ..., x...} n |x n ∈R}, where x represents the hourly energy consumption of the circuit, and n represents the total time series length of the hourly energy consumption of the power circuit. Consistent with the sliding window data processing method in the prediction model, considering the time dependency between hourly energy consumption, the energy consumption time series data is divided into time windows of length w, i.e., the time window W at time t. t Defined as W t ={x t-w+1 ,x t-w+2 ,…,x t |x t ∈R}. The window data is divided into training and test sets. Since the model needs to learn the normal potential distribution model of energy consumption data, the abnormal energy consumption data in the training set is standardized and corrected, and the missing imputation algorithm is used to simulate it as normal energy consumption hourly time series data. The data in the test set is not changed.
[0021] 3.2) Constructing the adversarial autoencoder. The present application uses an adversarial autoencoder network as a reconstruction model for energy time series data. The autoencoder network is used to learn the normal distribution pattern of hourly energy consumption data, while two discriminators are added to assist the reconstruction learning ability of the autoencoder. The encoder network structure of the autoencoder adopts a multi-layer one-dimensional convolutional layer stack structure. In order to prevent overfitting, a batch normalization layer and an activation function layer are added after each one-dimensional convolutional layer. The decoder structure adopts a one-dimensional transpose convolutional layer to reconstruct the hidden vector of the encoder into hourly energy consumption sample data. The encoder and the decoder are a symmetrical structure.
[0022] The two discriminator networks adopt the same network structure, both of which adopt a one-dimensional convolutional layer stack structure as the encoder structure. Since the output result of the discriminator is 0 or 1, a convolutional layer with a convolution kernel number of 1 is added at the end of the basic network, and the output result of the sigmoid function is finally used as the discrimination result of the discriminator.
[0023] 3.3) Adversarial autoencoder training. The normal energy consumption hourly time series window data in the training set are input into the adversarial autoencoder model for training. The adversarial training idea is integrated into the training process of the autoencoder by adding two discriminators. The autoencoder and the two discriminator networks are optimized synchronously in the training stage. Therefore, the training of the entire autoencoder depends on three objective loss functions, which are the reconstruction error of the autoencoder and the adversarial error loss functions of the two discriminators.
[0024] Before the model training starts, the hyperparameters required by the adversarial autoencoder network are set, including the batch size, the sliding window size, the number of iterations, the optimizer, the learning rate of the discriminator and the autoencoder, the number of convolution kernels in the autoencoder convolutional layer, and the weight of the adversarial loss. The final optimization objective loss of the adversarial autoencoder is defined as follows:
[0025]
[0026] Among them, the loss of the decoder is and are the adversarial regularization losses that ensure the robustness of the autoencoder reconstruction, λ E and λ D are weight coefficients used to adjust the influence of different adversarial regularization losses on the overall optimization objective function.
[0027] Further, the OCSVM single classifier as a secondary model of the stacked model, the training data is derived from the output of the LSTM multivariate prediction model and the adversarial autoencoder reconstruction model. The OCSVM single classifier is a kind of semi-supervised classifier, and the training data only needs to input the prediction error and reconstruction error of normal hourly energy consumption of power loop, since the LSTM multivariate energy consumption prediction network and the adversarial autoencoder reconstruction model are trained using the training set of modified normal energy consumption, therefore, the prediction error and reconstruction error of the training set are directly used as the training sample of the OCSVM single classifier.
[0028] The training error is calculated according to the training set prediction value output by the LSTM multivariate prediction network, since the reconstruction error in the training stage of the adversarial autoencoder is the reconstruction error of all hourly energy consumption samples in the entire reconstruction window, considering the actual demand of detection, only the reconstruction energy consumption of the last time is taken to calculate the reconstruction error. The training error and the reconstruction error are spliced to form a joint error, and the training parameters of the OCSVM single classifier, the kernel function and the training error are set, and the trained OCSVM single classifier model is saved.
[0029] Further, the detection of abnormal energy consumption needs prediction error data and reconstruction error data, in order to improve the efficiency of abnormal detection, in the prediction error calculation part, after obtaining the hourly energy consumption data in history, the historical time window data is constructed in advance, the LSTM multivariate prediction network considers the influence relationship of energy consumption influence features on current time energy consumption from the perspective of energy consumption influence features, and the data characteristics and individual fluctuations of loop energy consumption are considered, and the predicted energy consumption value is output. After the system receives the energy consumption value of the detection time, first, the prediction error is calculated according to the prediction value, then the hourly energy consumption time window is constructed, and the global distribution learning ability of the adversarial autoencoder is used to reconstruct the time window and calculate the hourly energy consumption reconstruction error. Finally, the prediction error and the reconstruction error are input into the trained OCSVM single classifier for abnormal judgment.
[0030] The application also provides an electronic device, which comprises a memory, a processor and a computer program stored in the memory and executable on the processor, and the processor implements the power loop abnormal energy consumption detection method based on the joint error stacked model when executing the program.
[0031] A non-transitory computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement the power loop abnormal energy consumption detection method based on the joint error stacked model.
[0032] A computer program product, comprising a computer program, and the computer program is executed by a processor to implement the power loop abnormal energy consumption detection method based on the joint error stacked model.
[0033] The beneficial effects of the present application are: the present application constructs a double-layer stacked model based on joint error, and judges whether the circuit is in an abnormal power consumption state by using power loop historical energy consumption data and loop energy consumption related influence features. The present application constructs a multivariate prediction model and a time series reconstruction model as the primary model of the stacked model, and the learning focuses of the two models are different. The prediction model uses multivariate feature data to consider energy consumption influence features to accurately predict the energy consumption of the next time step, and the reconstruction model obtains the reconstructed energy consumption of the next time step from the global distribution rule of energy consumption. Finally, the predicted energy consumption and the reconstructed energy consumption are input into the secondary model OCSVM single classifier for abnormal energy consumption judgment. The present application integrates the learning advantages of different primary models by using the idea of stacked model, provides more comprehensive judgment data sources for the secondary model, and finally realizes abnormal judgment by using the secondary model, avoiding the setting of artificial abnormal threshold in the traditional abnormal detection algorithm. BRIEF DESCRIPTION OF DRAWINGS
[0034] In order to more clearly illustrate the technical solutions in the present application or prior art, the following will briefly introduce the drawings needed to be used in the embodiments or prior art description. Obviously, the drawings in the following description are some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.
[0035] Figure 1 is a flowchart of the power loop abnormal energy consumption detection method based on the joint error stacked model provided by the embodiment of the present application;
[0036] Figure 2 is a structural schematic diagram of an electronic device provided by the embodiment of the present application;
[0037] Among them: 810-processor, 820-communication interface, 830-memory, 840-communication bus. DETAILED DESCRIPTION
[0038] In order to make the purpose, technical scheme and advantages of the present application clearer, the technical scheme in the present application will be described clearly and completely in the following combined with the drawings in the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor belong to the scope of protection of the present application.
[0039] The embodiment is based on the angle of energy consumption influence characteristics to construct a prediction model, and a energy consumption time series data reconstruction model is constructed, so as to fully exert the learning ability of the two models on data characteristics and global distribution of data respectively. The OCSVM single classifier introducing the semi-supervised idea judges the anomaly on the basis of the prediction and reconstruction model, so as to avoid the complex selection of threshold, and finally an abnormal energy consumption detection method of power loop based on joint error stacking model is proposed by using the idea of stacked model of ensemble learning. The method process is as shown in Figure 1
[0040] The data of the embodiment uses the loop energy consumption historical data collected by the sensor of the power loop of a public building. First, the python is used to pull the historical hourly energy consumption data of two years from the detection date to the front, and the energy consumption time series data of the standard time interval is converted according to the energy consumption record time and the hourly energy consumption value. For the missing part in the energy consumption time series, the invention uses the mean value of the non-empty hourly energy consumption data of the adjacent two days to preliminarily fill the missing part, and finally the standard loop energy consumption time series data with hourly interval is constructed.
[0041] A multivariate energy consumption prediction network is constructed. The multivariate loop hourly energy consumption influence factors are analyzed and extracted, the influence degree of different influence factors on energy consumption is learned, and the next hour loop energy consumption value is accurately predicted.
[0042] Analysis and mining of energy consumption influence characteristics. The energy consumption influence characteristics mainly include time characteristics and weather characteristics. The time characteristics are extracted and constructed by using the recorded time stamp data, including year, month, day, season, week, hour date characteristics, whether it is a holiday, whether it is a working day and holiday information characteristics. The weather characteristics use weather API interface to obtain historical weather information, mainly including maximum temperature, minimum temperature, humidity, weather, pollution index and wind force grade, and the characteristics are constructed. The multivariate influence characteristics constructed in step 2.1 are spliced with the standard hourly energy consumption data constructed in step 1 as the training data of the multivariate energy consumption prediction network, and finally the maximum and minimum value normalization method is used for normalization operation of the energy consumption influence characteristics and the energy consumption, and the normalization scaling factor is recorded. The normalization calculation method is as follows:
[0043]
[0044] The LSTM multivariate energy consumption prediction network is constructed. The LSTM is a kind of recurrent neural network, which can solve the problem that the traditional RNN network cannot process long sequence input data. The LSTM network is used as the basic network of the multivariate energy consumption prediction network, and a double-layer bidirectional LSTM energy consumption prediction network is constructed based on the LSTM network. The multivariate feature energy consumption time series data obtained in step 2.1 is divided by using a time sequence window, so that each prediction sample is converted into a two-dimensional matrix containing historical data. In the network construction process, the divided two-dimensional matrix time sequence window data is input into the first layer bidirectional LSTM neural network, and the output thereof is taken as the input of the second layer bidirectional LSTM neural network. The hidden layer features output by the bidirectional LSTM are as follows:
[0045]
[0046] The hidden layer state output by the last layer bidirectional LSTM neural network at the last time step is taken as the feature vector of the hourly energy consumption prediction, and the final prediction value is output through a fully connected network.
[0047] The multivariate energy consumption prediction network is trained. First, the abnormal energy consumption data in the training set and the validation set are corrected by using a missing filling algorithm to simulate normal energy consumption hourly time series data, and the data in the test set is not changed. Before model training, the corresponding hyperparameters need to be set, the size of the sliding window is set to segment the original data set, the time step and feature dimension of the input layer of the LSTM neural network are set, the number of neurons of each layer of the LSTM neural network is set, the number of bidirectional neurons is consistent, the optimizer, batch size, optimizer and loss function of the model training are set. Considering the prediction accuracy, the loss function selects MSE, that is, L1 norm, and the optimization loss is defined as follows:
[0048]
[0049] In the training process, the error loss curve of the training set and the validation set is observed, and when the validation set loss no longer decreases, the model training is stopped, and the model parameters are retained.
[0050] The reconstruction model of the adversarial autoencoder is constructed. The prediction model is based on the multivariate energy consumption data, and can well learn the influence of different energy consumption influencing factors on the loop hourly energy consumption, but lacks the capture of the global distribution of the energy consumption time series data. When facing sequence anomalies, the prediction value is easily affected by the adjacent abnormal time series, and the global distribution of the data needs to be considered, therefore, the reconstruction model of the adversarial autoencoder is constructed to learn the potential distribution of the energy consumption time series.
[0051] Training data preprocessing. Considering the time dependence between hourly energy consumption, the energy time series data is divided into time windows of length w, i.e. the time window W of time t t is defined as W t = {x t-w+1 ,x t-w+2 ,…,x t |x t ∈R}. Finally, the single-variable energy hourly time series data is converted into individual time series windows, the entire window data is defined as X, and X is divided into a training set and a test set. Since the model needs to learn the normal potential distribution model of energy consumption data, the abnormal energy consumption data in the training set is modified by standard correction, and the missing filling algorithm is used to simulate it as normal energy hourly time series data. The data in the test set is not changed. The processed energy hourly time series window data X is as follows:
[0052]
[0053] Construction of adversarial autoencoder. In this embodiment, an adversarial autoencoder network is used as a reconstruction model for energy time series data. The autoencoder network is used to learn the normal distribution pattern of hourly energy consumption data, and two discriminators are added to assist the reconstruction learning ability of the autoencoder. The encoder network structure of the autoencoder adopts a stack of multiple one-dimensional convolutional layers; the decoder structure adopts a one-dimensional transpose convolutional layer to reconstruct the hidden vector of the encoder into hourly energy sample data. The encoder and the decoder are a symmetrical structure.
[0054] The two discriminator networks adopt the same network structure, both of which adopt a stack of one-dimensional convolutional layers with the same structure as the encoder. Since the output result of the discriminator is 0 or 1, a convolutional layer with a convolution kernel number of 1 is added at the end of the basic network, and the output result of the sigmoid function is used as the discrimination result of the discriminator.
[0055] Adversarial autoencoder training. The normal energy hourly time series window data in the training set is input into the adversarial autoencoder model for training. The idea of adversarial training is incorporated into the training process of the autoencoder by adding two discriminators. The autoencoder and the two discriminator networks are optimized synchronously in the training stage, so the training of the entire autoencoder depends on three objective loss functions, which are the reconstruction error L rec of the autoencoder and the adversarial error loss functions and of the two discriminators, respectively, which are defined as follows:
[0056]
[0057]
[0058]
[0059] Before the model training starts, the hyperparameters required for the adversarial autoencoder network are set: batch size, sliding window size, number of iterations, optimizer, discriminator and autoencoder learning rate, the number of convolution kernels in the autoencoder convolution layer and the weight of the adversarial loss. The final optimization objective loss of the adversarial autoencoder is defined as follows:
[0060]
[0061] wherein, and are the adversarial regularization losses that ensure the robustness of the autoencoder reconstruction, respectively corresponding to and the right half of the formula definition, λ E and λ D are weight coefficients used to adjust the influence of different adversarial regularization losses on the overall optimization objective function.
[0062] OCSVM single classifier training. The OCSVM single classifier as the secondary model of the stacked model, its training data comes from the output of the LSTM multivariate prediction model and the adversarial autoencoder reconstruction model. As a semi-supervised classifier, the OCSVM single classifier only needs to input the prediction error and reconstruction error of the normal hourly energy consumption of the power loop. The calculation method of the prediction error and the reconstruction error is as follows:
[0063] τ = |x t -x′ t |
[0064] Since the LSTM multivariate energy consumption prediction network and the adversarial autoencoder reconstruction model are trained using the training set of the modified normal energy consumption, the prediction error and the reconstruction error of the training set are directly used as the training samples of the OCSVM single classifier. The training error is calculated based on the training set prediction value output by the LSTM multivariate prediction network. Since the reconstruction error in the adversarial autoencoder training stage considers the reconstruction error of all hourly energy consumption samples in the entire reconstruction window, considering the actual needs of detection, the reconstruction error of the last time is taken to calculate the reconstruction error. The joint error is formed by splicing the training error and the reconstruction error, and the training parameters of the OCSVM single classifier such as the kernel function, the kernel parameter and the training error are set. The trained OCSVM single classifier model is saved.
[0065] The detection of abnormal energy consumption of the loop requires prediction error data and reconstruction error data. In order to improve the efficiency of abnormal detection, in the prediction error calculation part, after obtaining the energy consumption data of the last hour in history, the historical time window data is constructed in advance, and the LSTM multivariate prediction network outputs the predicted energy consumption value according to the constructed historical energy consumption multi-feature data. After the system receives the energy consumption value at the detection time, firstly, the prediction error is calculated according to the predicted value, secondly, the hour energy consumption time window is constructed, and the time window is reconstructed by using the adversarial autoencoder and the hour energy consumption reconstruction error is calculated. Finally, the prediction error and the reconstruction error are input into the trained OCSVM single classifier for abnormality determination.
[0066] Based on the above embodiment data and method, the present application carries out experiments, adopts the precision, recall and F1 score commonly used in binary classification experiments as the evaluation indexes of the loop abnormal energy consumption detection, and the evaluation results are shown in Table 1 as follows:
[0067] Table 1 Evaluation results of loop abnormal energy consumption detection
[0068]
[0069] Compared with the traditional single model baseline method LOF abnormal detection algorithm and the VAE variational autoencoder reconstruction algorithm, the stacked model based on joint error proposed in the present application has great improvement in the three evaluation indexes, which shows that for the power loop energy consumption which is easily affected by the outside world, has large fluctuation and has unclear distribution rule, the stacked model proposed in the present application has certain advantages and feasibility by integrating the advantages of different primary models and performing abnormal detection based on joint error, and has high detection precision for the diversified and strongly correlated power loop abnormal energy consumption detection task.
[0070] Figure 2 An entity structure diagram of an electronic device is shown, which can include a processor 810, a communications interface 820, a memory 830 and a communications bus 840, wherein the processor 810, the communications interface 820 and the memory 830 complete mutual communication through the communications bus 840. The processor 810 can call the logical instructions in the memory 830 to execute the power loop abnormal energy consumption detection method based on the joint error stacked model.
[0071] In addition, the logic instructions in the memory 830 described above can be implemented in the form of software functional units and sold or used as independent products, and can be stored in a computer readable storage medium. Based on such understanding, the technical solutions of the present application essentially or the parts that contribute to the prior art or parts 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 a number of 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 various embodiments of the present application. The foregoing storage medium includes various media that can store program codes, such as a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0072] In another aspect, the present application also provides a computer program product, which comprises a computer program, the computer program can be stored on a non-transitory computer readable storage medium, and the computer program can be executed by a processor to enable a computer to execute the power loop abnormal energy consumption detection method based on the joint error stacking model provided by the above-mentioned methods.
[0073] In another aspect, the present application also provides a non-transitory computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement the power loop abnormal energy consumption detection method based on the joint error stacking model provided by the above-mentioned methods.
[0074] The device embodiments described above are only schematic, wherein the units described as separate components can or can not be physically separate, and the components displayed as units can or can not be physical units, i.e. they can be located in one place, or distributed on multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the present embodiment. Those skilled in the art can understand and implement without creative labor.
[0075] From the above description of the embodiments, those skilled in the art can clearly understand that the embodiments can be implemented by means of software plus necessary general hardware platforms, and of course can also be implemented by hardware. Based on such understanding, the technical solutions described above essentially or the parts that contribute to the prior art can be embodied in the form of a software product. The computer software product can be stored in a computer readable storage medium, such as a ROM / RAM, a magnetic disk, an optical disk, etc., and includes a number of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in various embodiments or some parts of the embodiments.
[0076] Finally, it should be noted that the above examples are only used to illustrate the technical solutions of the present application, and are not intended to limit the same; although the present application has been described in detail with reference to the foregoing examples, those of ordinary skill in the art should understand that they can still modify the technical solutions recorded in the foregoing examples, or make equivalent replacements for some of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A method for detecting abnormal energy consumption in power circuits based on a joint error stacking model, characterized in that, include: Collect and preprocess data; construct standard loop energy consumption time-series data with hourly intervals; Construct a multivariate energy consumption prediction network and use historical energy consumption data to predict the hourly energy consumption of the loop at the time to be detected. An adversarial autoencoder reconstruction model is constructed to learn the global distribution pattern of energy consumption time series data and reconstruct the time series window to be detected. The prediction error is calculated based on the predicted value, and the hourly energy consumption reconstruction error is calculated using the reconstructed time series window. An OCSVM single classifier is then jointly trained. The joint training of the OCSVM single classifier includes the following steps: The prediction error and reconstruction error of the normal hourly energy consumption of the input power circuit are used as training data, and the prediction error and reconstruction error of the training set are used as training samples for the OCSVM single classifier. Calculate the reconstruction error by taking the reconstruction energy consumption at the last moment; concatenate the training error and reconstruction error to form the joint error; set the training parameters, kernel function, kernel parameters and training error of the OCSVM single classifier; and save the trained OCSVM single classifier model. The prediction error and reconstruction error of the energy consumption at the time to be detected are input into the trained OCSVM single classifier for loop abnormal energy consumption detection.
2. The method for detecting abnormal energy consumption in power circuits based on a joint error stacking model according to claim 1, characterized in that, The construction of the standard hourly loop energy consumption time-series data includes the following steps: Python was used to collect and preprocess historical energy consumption data stored in the energy consumption monitoring platform. Historical hourly energy consumption data for two years (24 months) were retrieved from the monitoring date and converted into standard energy consumption time series data according to the energy consumption record time and hourly energy consumption value. For missing parts in the energy consumption time series, the average of the non-empty hourly energy consumption data of the two consecutive days before and after was used for preliminary missing filling, and standard loop energy consumption time series data with hourly intervals was constructed.
3. The method for detecting abnormal energy consumption in power circuits based on a joint error stacking model according to claim 1, characterized in that, The single-point prediction of the loop hourly energy consumption value at the time to be detected based on the historical energy consumption data includes the following steps: S2.
1. Construct date features, holiday features, and weather features respectively; Date features include year, month, day, season, weekday, and hour; holiday features include whether it is a holiday and whether it is a working day. The date features and holiday features are constructed using the recorded timestamps. Weather characteristics include maximum temperature, minimum temperature, humidity, weather conditions, pollution index, and wind force; the multivariate influence features constructed in S2.1 are concatenated with the constructed standard hourly energy consumption time series data as training data for the multivariate energy consumption prediction network; S2.
2. Utilize the LSTM network as the base network for the multivariate energy consumption prediction network, and construct a two-layer bidirectional LSTM energy consumption prediction network on it; divide the energy consumption time series data with multivariate features obtained in S2.1 using a time series window, transforming each prediction sample into a two-dimensional matrix containing historical data; during the network construction process, input the divided two-dimensional matrix time series window data into the first-layer bidirectional LSTM neural network, and use its output as the input of the second-layer bidirectional LSTM neural network, using the hidden state of the final output as the feature vector for hourly energy consumption prediction, and output the final predicted value through a fully connected network; S2.
3. Train the multivariate energy consumption prediction network; standardize the abnormal energy consumption data in the training and validation sets, and use the missing imputation algorithm to simulate them as normal energy consumption hourly time series data, while keeping the data in the test set unchanged; set the corresponding hyperparameters before model training, set the sliding window size to segment the original dataset, set the time step and feature dimension of the LSTM neural network input layer, set the number of neurons in each layer of the LSTM neural network (the number of neurons in both directions is consistent), set the optimizer, batch size, and loss function for model training; select MSE as the loss function; observe the error loss decrease curves of the training and validation sets, and stop model training when the validation set loss no longer decreases, while retaining the model parameters.
4. The method for detecting abnormal energy consumption in power circuits based on a joint error stacking model according to claim 1, characterized in that, The aforementioned construction of an adversarial autoencoder reconstruction model learns the distribution pattern of energy consumption time series and reconstructs the time series window to be detected. Includes the following steps: S3.
1. Training data preprocessing; Define the loop energy consumption time series X={x1, x2, …, x n | x n ∈R}, where x represents the hourly energy consumption of the circuit, and n represents the total time series length of the hourly energy consumption of the power circuit. The energy consumption time series data is divided into time windows of length w, and the time window W at time t is... t Defined as W t ={x t-w+1 , x t-w+2 , …, x t | x t ∈R}; Divide the window data into training and test sets, standardize the abnormal energy consumption data in the training set, and use the missing filling algorithm to simulate it as normal energy consumption hourly time series data, while keeping the data in the test set unchanged; S3.
2. Construct an adversarial autoencoder; use the adversarial autoencoder network as a reconstruction model for energy consumption time series data, and use the autoencoder network to learn the normal distribution pattern of hourly energy consumption data. Add two discriminators to assist the autoencoder's reconstruction learning ability; the encoder network structure of the autoencoder is composed of multiple stacked one-dimensional convolutional layers, and a batch normalization layer and an activation function layer are added after each one-dimensional convolutional layer; the decoder structure uses a one-dimensional transposed convolutional layer to reconstruct the encoder's latent vectors into hourly energy consumption sample data. The encoder and decoder are symmetrical structures; the two discriminator networks have the same structure, both using the encoder network structure; add a convolutional layer with 1 kernel at the end of the basic network, and use the output of the sigmoid function as the discriminator's discrimination result; S3.
3. Adversarial Autoencoder Training: Input the normal energy consumption hourly time-series window data from the training set into the adversarial autoencoder model for training. The training of the autoencoder depends on three objective loss functions: the reconstruction error of the autoencoder and the adversarial error loss functions of the two discriminators. Before model training begins, the hyperparameters required for the adversarial autoencoder network are set: batch size, sliding window size, number of iterations, optimizer, discriminator, and autoencoder learning rate, the number of convolutional kernels in the autoencoder convolutional layers, and the weights of the adversarial loss. The final optimization objective loss of the adversarial autoencoder is defined as follows: The loss of the decoder is , and These are, respectively, the adversarial regularization loss that ensures the robustness of autoencoder reconstruction. and These are weighting coefficients used to adjust the impact of different adversarial regularization losses on the overall optimization objective function.
5. An electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the power circuit abnormal energy consumption detection method based on the joint error stacking model as described in any one of claims 1 to 4.
6. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the power circuit abnormal energy consumption detection method based on the joint error stacking model as described in any one of claims 1 to 4.
7. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the power circuit abnormal energy consumption detection method based on the joint error stacking model as described in any one of claims 1 to 4.
Citation Information
Patent Citations
Industrial internet time series data anomaly detection method and device
CN116522265A
Method and system for defending against adversarial sample in image classification, and data processing terminal
US20230022943A1