Scientific research building room energy consumption anomaly detection method based on ensemble learning and deep learning

CN118606861BActive Publication Date: 2026-10-30SOUTH CHINA UNIV OF TECH
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202410697265.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-05-31
Publication Date
2026-10-30
Estimated Expiration
2044-05-31

AI Technical Summary

Technical Problem

有监督方法基于有异常标签的数据集进行异常检测,具有较高的检测精度,但是在实际工程中数据集往往是缺少标签的,获取准确标签的难度较大,这使其在许多场景中的应用受到限制

Benefits of technology

[0075](1)本发明提出了基于集成学习框架的异常数据标注方法,充分利用多种基分类器的优势互补,获取高质量数据标签;

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118606861B_ABST
    Figure CN118606861B_ABST
Patent Text Reader

Abstract

The application discloses a kind of based on integrated learning and deep learning's scientific research building room energy consumption anomaly detection method, including obtaining historical room energy consumption, outdoor meteorological and date attribute data and pre-processing;Adopt integrated learning framework to mark anomaly, obtain data label;Train auto-encoder model, select reconstruction error threshold according to data label;Reconstruction energy consumption sequence is obtained using auto-encoder model reconstruction room energy consumption sequence to be detected, and reconstruction error is calculated, finally obtain anomaly detection result.The application proposes the anomaly data annotation method based on integrated learning framework, make full use of the advantages of multiple base classifiers complement, obtain high-quality data label;While using double-layer GRU network to construct the encoder and decoder of auto-encoder, fully capture the long-term dependence of energy consumption data, improve the reconstruction effect of model to unstable, nonlinear data, and introduce self-attention mechanism in the encoder, improve the reconstruction effect of model at inflection point.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the technical field of building energy conservation, specifically relating to a method for detecting abnormal energy consumption in scientific research building rooms based on ensemble learning and deep learning. Background Technology

[0002] With the increasing investment and output in basic research and technological innovation in universities, the energy consumption of university research buildings is gradually increasing. Unreasonable electricity use by teachers and students in these rooms will cause a lot of electricity waste. Therefore, it is necessary to conduct abnormal detection of energy consumption in research building rooms.

[0003] Currently, energy consumption anomaly detection methods applied in the building field are mainly divided into supervised and unsupervised methods. Supervised methods rely on labeled datasets for anomaly detection and have high accuracy. However, in real-world engineering projects, datasets often lack labels, making it difficult to obtain accurate labels, which limits their application in many scenarios. Unsupervised methods, on the other hand, do not require labeled datasets and are more suitable for most task scenarios. However, existing unsupervised methods lack sufficient prior knowledge, perform poorly in detecting anomalies in nonlinear and non-stationary room energy consumption data, and have low computational efficiency when processing large-scale datasets, thus exhibiting certain limitations. Summary of the Invention

[0004] The main objective of this invention is to overcome the shortcomings and deficiencies of the prior art and provide a method for detecting abnormal energy consumption in scientific research building rooms based on ensemble learning and deep learning. This method aims to reduce the cost of acquiring high-quality data labels and achieve efficient detection of abnormal energy consumption in scientific research building rooms.

[0005] To achieve the above objectives, the present invention adopts the following technical solution:

[0006] One aspect of the present invention provides a method for detecting anomalies in energy consumption of rooms in scientific research buildings based on ensemble learning and deep learning, comprising the following steps:

[0007] Acquire historical room energy consumption data, outdoor weather data, and date attribute data;

[0008] Preprocessing of room energy consumption data includes cleaning distorted data, imputing missing values, and repairing abrupt changes;

[0009] An integrated learning framework was used to mark anomalies in the preprocessed room energy consumption data and obtain data labels.

[0010] An autoencoder model was trained using preprocessed room energy consumption data, and a reconstruction error threshold was selected based on the data labels.

[0011] The energy consumption sequence of the room to be detected is reconstructed using an autoencoder model to obtain the reconstructed energy consumption sequence, and the reconstruction error is calculated. The anomaly detection result is obtained based on the reconstruction error threshold.

[0012] As a preferred technical solution, the acquisition of historical room energy consumption data, outdoor meteorological data, and date attribute data specifically includes:

[0013] The system obtains hourly electricity consumption data for the most recent year from the building energy consumption monitoring platform and local meteorological stations, along with corresponding outdoor meteorological parameters and date attribute data. The outdoor meteorological parameters include dry-bulb temperature, wet-bulb temperature, and relative humidity. The date attribute data includes week attribute information, weekday attribute information, and time attribute information.

[0014] As a preferred technical solution, the distorted data cleaning specifically includes:

[0015] Distortion cleaning of room energy consumption data is performed, including missing value detection and processing, and cumulative mutation value detection and processing. Missing values ​​refer to the absence of data at a certain point in time within continuous data. Cumulative mutation values ​​refer to the cumulative energy consumption value that appears after multiple consecutive time points have shown missing or zero values. Distortion detection is performed using the quartile method, as shown in the following formula:

[0016]

[0017] In the formula, Q1 and Q3 are the lower and upper quartiles, respectively, IQR is the interquartile range, and Q... U and Q L These are the upper and lower bounds of the abnormal threshold, respectively;

[0018] The missing value imputation specifically involves:

[0019] For the detected missing values, imputation is performed using the mean value under the same operating conditions, and the calculation formula is as follows:

[0020]

[0021] In the formula, x kj Let x be the interpolated value of the energy consumption data at time j on day k to be interpolated. ij To select energy consumption data at time j on day i with similar recent date attributes and meteorological parameters, n is the number of days to be selected, and n = 3 is taken. Specifically, it means to take the average energy consumption at the same time on 3 days with similar recent energy consumption conditions to interpolate the electricity consumption at the missing time.

[0022] The mutation value repair specifically involves:

[0023] For the detected cumulative mutation values, a weighted substitution method is used for repair. Specifically, the normal energy consumption time series of the same period of the most recent day with similar energy consumption conditions is selected. The ratio of the total energy consumption of the abnormal series to the total energy consumption of the normal series is used as the weighting coefficient. The normal energy consumption time series is then weighted to obtain the repaired energy consumption time series. The calculation formula is as follows:

[0024]

[0025] In the formula, Y' is the repaired energy consumption time series, X is the normal energy consumption time series of the same period on the most recent day with similar date attributes and meteorological parameters, yi is the hourly energy consumption value of the abnormal time series, and xi is the hourly energy consumption value of the selected normal time series.

[0026] As a preferred technical solution, the step of using an integrated learning framework to mark anomalies in preprocessed room energy consumption data and obtain data labels specifically includes the following steps:

[0027] For the preprocessed room energy consumption data X={x1,x2,...,x k Feature extraction is performed to construct the input of the ensemble learning framework. The input features include energy consumption data, time, outdoor temperature at the corresponding time, and short-term and periodic features of the energy consumption data.

[0028] The input to the model is normalized, and the calculation formula is as follows:

[0029]

[0030] In the formula, x' is the normalized value, x is the original data, and x min x is the minimum value of this feature dimension. max This is the maximum value of this feature dimension;

[0031] Normalized data is input into the base classifier of the ensemble learning framework for outlier labeling. A voting method is used to determine the output of the base classifier. If the output of at least two base classifiers is outlier, the data is marked as outlier.

[0032] As a preferred technical solution, the preprocessed room energy consumption data X={x1,x2,...,x k Feature extraction includes the following steps:

[0033] The short-term characteristics of energy consumption data are represented by the first-order difference of hourly energy consumption, with intervals of 1 and 2.

[0034] The periodicity of energy consumption data is characterized by the difference between hourly energy consumption and the median energy consumption at the same time within a week. The calculation formula is as follows:

[0035] X = [X1, X2, ..., X] m ] T

[0036] X m =[x m,1 ,x m,2 …x m,n ]

[0037]

[0038] In the formula, X m Let x be the energy consumption time series for day m. m,n Let m be the energy consumption at hour n on day m, where m is 365 and n is 24. Let i be the median energy consumption at time j within a week, where i ∈ week;

[0039] The final model input is as follows:

[0040] Q i,j =(x i,j ,T i,j ,q i,j ,j,q′ i,j ,q″ i,j )

[0041] In the formula, x i,j For the energy consumption at hour j on day i, T i,j Let q′ be the outdoor temperature at the corresponding time, j be the corresponding time, and q′ be the outdoor temperature at the corresponding time. i,j Let q″ be the first-order difference of energy consumption at intervals of 1 at the corresponding time. i,j The first-order difference is the energy consumption interval of 2 at the corresponding time.

[0042] As a preferred technical solution, the normalized data is input into the base classifier of the integrated learning framework, and the anomaly labeling specifically includes the following steps:

[0043] Select at least 3 base classifiers, and each base classifier performs anomaly identification on the normalized data and outputs the corresponding results;

[0044] The output results are voted on, and when at least half of the output results are abnormal, they are marked as abnormal data, and the final data labels are obtained.

[0045] The base classifiers include the COPOD algorithm, CBLOF algorithm, Isolation Forest algorithm, KNN algorithm, LOF algorithm, COF algorithm, and DBSCAN algorithm.

[0046] As a preferred technical solution, the step of training an autoencoder model using preprocessed room energy consumption data and selecting a reconstruction error threshold based on data labels specifically includes the following steps:

[0047] The room energy consumption conditions are divided using outdoor temperature to obtain non-cooling and cooling conditions. The room energy consumption data under different conditions are normalized, and the input of the autoencoder is constructed in the form of a three-dimensional tensor, including the batch number of samples, the number of time steps, and the input features at each time step, as shown in the following formula:

[0048]

[0049] In the formula, The value is the normalized value, and q is the original data. min q is the minimum value of this feature dimension. max The maximum value of this feature dimension is t, where t is the time step dimension, n is the total number of samples, and n-(tk) is the batch processing dimension.

[0050] The autoencoder model was trained using data from two different operating conditions, and an early stopping strategy was set up. Training was stopped when the loss on the model validation set no longer decreased. The encoder and decoder of the autoencoder were both constructed using a two-layer GRU network, and a self-attention mechanism was embedded after the last GRU network layer of the encoder.

[0051] Data from two different operating conditions are input into the trained autoencoder model to reconstruct the sequence. The reconstruction error is calculated, and histograms of the reconstruction error distribution for different energy consumption periods are plotted. Based on the acquired data labels, the proportion of normal data in the dataset is determined, and this proportion is used as the quantile for selecting the reconstruction error threshold. The reconstruction error calculation formula is as follows:

[0052]

[0053] In the formula, q i This is the raw energy consumption data; To reconstruct energy consumption data.

[0054] As a preferred technical solution, the step of training the autoencoder model using data from two different working conditions also includes the tuning and determination of the autoencoder model's hyperparameters. The hyperparameters that need to be tuned include the number of neurons (units) in the GRU layer, the Dropout rate, and the batch size. The tuning is performed using a grid search method, and the specific tuning method is as follows:

[0055] Initialize hyperparameter values ​​and set the hyperparameter variation range: Train the model under different hyperparameter combinations, compare the loss values ​​on the validation set at the end of model training, and select the hyperparameter combination with the smallest loss value as the debugging result; the loss value is selected as the MSE (Mean Sequence of Excess) as the evaluation metric, and the calculation method is as follows:

[0056]

[0057] In the formula, y i The actual value; The values ​​are the reconstructed values ​​of the model; n is the number of samples.

[0058] The training steps for the autoencoder are as follows:

[0059] 1) Divide the dataset into a training set and a validation set;

[0060] 2) Initialize the model hyperparameters and set the early stopping strategy;

[0061] 3) Input the training set and validation set into the model for training, and plot the loss curve of the training process;

[0062] 4) Update the model's weights and biases using the Adam optimizer;

[0063] 5) When the early stopping condition is met, stop training and retain the result with the minimum loss. After training is completed, write the parameters to the folder for saving.

[0064] As a preferred technical solution, the method of reconstructing the energy consumption sequence of the room to be detected using an autoencoder model to obtain a reconstructed energy consumption sequence, calculating the reconstruction error, and obtaining the anomaly detection result based on the reconstruction error threshold specifically includes the following steps:

[0065] Determine the energy consumption condition based on the outdoor temperature corresponding to the data to be detected, and select the appropriate self-encoder model;

[0066] The data to be detected is constructed into a three-dimensional tensor, input into the autoencoder model of the corresponding working condition, and the reconstruction sequence is obtained and the reconstruction error is calculated.

[0067] By comparing the reconstruction error with the threshold, data exceeding the threshold is identified as abnormal energy consumption.

[0068] Another aspect of the present invention provides a scientific research building room energy consumption anomaly detection system based on ensemble learning and deep learning, applied to the above-mentioned scientific research building room energy consumption anomaly detection method based on ensemble learning and deep learning, including a data acquisition module, a data preprocessing module, an anomaly data labeling module, a model training module, and an anomaly detection module.

[0069] The data acquisition module is used to acquire historical room energy consumption data, outdoor meteorological data, and date attribute data;

[0070] The data preprocessing module is used to preprocess room energy consumption data, including distorted data cleaning, missing value imputation, and abrupt value repair.

[0071] The abnormal data marking module is used to mark anomalies in the preprocessed room energy consumption data using an integrated learning framework and obtain data labels.

[0072] The model training module is used to train an autoencoder model using preprocessed room energy consumption data and select a reconstruction error threshold based on the data labels.

[0073] The anomaly detection module is used to reconstruct the energy consumption sequence of the room to be detected using an autoencoder model to obtain the reconstructed energy consumption sequence, calculate the reconstruction error, and obtain the anomaly detection result based on the reconstruction error threshold.

[0074] Compared with the prior art, the present invention has the following advantages and beneficial effects:

[0075] (1) This invention proposes an anomaly data labeling method based on an integrated learning framework, which makes full use of the complementary advantages of multiple base classifiers to obtain high-quality data labels;

[0076] (2) The present invention uses a two-layer GRU network to construct the encoder and decoder of the autoencoder, fully capturing the long-term dependency relationship of energy consumption data and improving the model’s reconstruction effect on non-stationary and nonlinear data;

[0077] (3) The present invention introduces a self-attention mechanism in the encoder to improve the reconstruction effect of the model at the inflection point. Attached Figure Description

[0078] Figure 1 This is a flowchart of a method for detecting abnormal energy consumption in a research building room based on ensemble learning and deep learning, according to an embodiment of the present invention.

[0079] Figure 2 This is a flowchart of the abnormal data annotation method according to an embodiment of the present invention;

[0080] Figure 3 This is a structural diagram of the GRU-AE model based on the self-attention mechanism according to an embodiment of the present invention;

[0081] Figure 4 This is a flowchart of the early stopping strategy for training an autoencoder according to an embodiment of the present invention;

[0082] Figure 5 This is a schematic diagram illustrating the reconfiguration error distribution under non-cooling conditions according to an embodiment of the present invention. Figure 5 -a) is a schematic diagram showing the reconstructed error distribution during the rest period under non-cooling conditions. Figure 5 -b) is a schematic diagram showing the reconfiguration error distribution under non-cooling operating conditions during the working period;

[0083] Figure 6 This is a schematic diagram of the error distribution of the refrigeration condition reconstruction according to an embodiment of the present invention, wherein... Figure 6 -a) is a schematic diagram showing the reconstructed error distribution of the cooling operation during the rest period. Figure 6 -b) is a schematic diagram showing the distribution of reconstructed errors under cooling conditions during the working period;

[0084] Figure 7 This is a schematic diagram of a scientific research building room energy consumption anomaly detection system based on ensemble learning and deep learning according to an embodiment of the present invention.

[0085] Figure 8 This is a schematic diagram of the structure of the storage medium according to an embodiment of the present invention. Detailed Implementation

[0086] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present application, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments of the present application without creative effort are within the scope of protection of the present application.

[0087] Example

[0088] like Figure 1 As shown, this embodiment provides a method for detecting anomalies in energy consumption of rooms in scientific research buildings based on ensemble learning and deep learning. It obtains high-quality data labels through an ensemble learning framework, constructs an autoencoder using a two-layer GRU network, and introduces a self-attention mechanism to improve reconstruction performance. Simultaneously, it selects a reconstruction error threshold for the autoencoder based on the data labels to improve the model's anomaly detection accuracy. The method includes the following steps:

[0089] S1. Obtain historical room energy consumption data, outdoor weather data, and date attribute data;

[0090] Further, step S1 specifically involves: obtaining the room energy consumption data, corresponding outdoor meteorological parameters, and date attribute data of a research building's rooms at time t within the most recent year from the building energy consumption monitoring platform; the outdoor meteorological parameters include the dry-bulb temperature, wet-bulb temperature, and relative humidity at time t. If the energy consumption monitoring platform cannot obtain the outdoor meteorological data, it can be obtained through a local meteorological station; the date attribute data includes week attribute information, weekday attribute information, and time attribute information. In this embodiment, data from April 1, 2023 to December 31, 2023, for rooms whose energy consumption level is at the median level of the building are selected as the sample.

[0091] S2. Perform data preprocessing on the room energy consumption data to obtain preprocessed room energy consumption data X = {x1, x2, ..., x}. k};

[0092] Further, step S2 includes the following steps:

[0093] S21. Perform data cleaning on the room energy consumption data to remove distortion, including missing value detection and processing, and cumulative mutation value detection and processing. Missing values ​​refer to data missing at a certain point in time within continuous data. Cumulative mutation values ​​refer to the cumulative energy consumption value that appears after multiple consecutive time points have missing or zero values. Distortion data is detected using the quartile method, as shown in the following formula:

[0094]

[0095] In the formula, Q1 and Q3 are the lower quartile and upper quartile, respectively, IQR is the interquartile range, and QU and QL are the upper and lower bounds of the anomaly threshold, respectively.

[0096] S22. For the detected missing values, interpolation is performed using the mean value under the same operating conditions. The calculation formula is as follows:

[0097]

[0098] In the formula, x kj The interpolated value is the energy consumption data at time j on day k to be interpolated. The energy consumption data at time j on day i is selected from those with similar recent date attributes and meteorological parameters. n is the number of days selected, and n=3 is taken. Specifically, it means that the average energy consumption at the same time on 3 days with similar recent energy consumption conditions is used to interpolate the electricity consumption at the missing time.

[0099] S23. For the detected cumulative mutation values, a weighted substitution method is used for repair, and the calculation formula is as follows:

[0100]

[0101] In the formula, Y' represents the repaired energy consumption time series, X represents the normal energy consumption time series for the same period on the most recent day with similar date attributes and meteorological parameters, yi represents the hourly energy consumption value of the abnormal time series, and xi represents the hourly energy consumption value of the selected normal time series. Specifically, the normal energy consumption time series for the same period on the most recent day with similar energy consumption conditions is selected. The ratio of the total energy consumption of the abnormal series to the normal series is used as a weighting coefficient to weight the normal energy consumption time series, thus obtaining the repaired energy consumption time series.

[0102] S3. Use an integrated learning framework to mark anomalies in the preprocessed room energy consumption data to obtain high-quality data labels;

[0103] Further, step S3 includes the following steps:

[0104] S31. For the preprocessed room energy consumption data X={x1,x2,...,x k Feature extraction is performed to construct the input for the ensemble learning framework; the input features include energy consumption data x. i,jTime j, corresponding outdoor temperature T i,j And the short-term and periodic characteristics of energy consumption data:

[0105] Furthermore, the feature extraction in step S31 includes the following steps:

[0106] S311. The short-term characteristics of energy consumption data are represented by the first-order difference of hourly energy consumption, with intervals of 1 and 2, to obtain q′. i,j and q″ i,j ;

[0107] S312. The periodicity of energy consumption data is characterized by the difference between hourly energy consumption and the median energy consumption at the same time within a week, resulting in q. i,j The calculation formula is as follows:

[0108] X = [X1, X2, ..., X] m ] T

[0109] X m =[x m,1 ,x m,2 …x m,n ]

[0110]

[0111] In the formula, X m Let x be the energy consumption time series for day m. m,n Let m be the energy consumption at hour n on day m, where m is 365 and n is 24. Let i be the median energy consumption at time j within a week, where i ∈ week.

[0112] S313. The input to the final ensemble learning framework is as follows:

[0113] Q i,j =(x i,j ,T i,j ,q i,j ,j,q′ i,j ,q″ i,j )

[0114] In the formula, x i,j For the energy consumption at hour j on day i, T i,j Let q′ be the outdoor temperature at the corresponding time, j be the corresponding time, and q′ be the outdoor temperature at the corresponding time. i,j Let q″ be the first-order difference with an interval of 1 corresponding to the energy consumption at that time. i,j为 The energy consumption interval at the corresponding moment is a first-order difference of 2.

[0115] S32. Normalize the model input using the following formula:

[0116]

[0117] In the formula, x' is the normalized value, x is the original data, and x min x is the minimum value of this feature dimension. max This is the maximum value of this feature dimension.

[0118] S33. Input the normalized data into the base classifier of the ensemble learning framework, label outlier data, and use a voting method to determine the output results of the base classifiers. If the outputs of at least two base classifiers are outliers, then the data is marked as outlier.

[0119] Furthermore, the abnormal data annotation in step S33 includes the following steps:

[0120] S331. Select at least 3 base classifiers, each of which performs anomaly identification on the normalized data and outputs the corresponding results; the base classifiers include the COPOD algorithm, CBLOF algorithm, isolated forest algorithm, KNN algorithm, LOF algorithm, COF algorithm and DBSCAN algorithm.

[0121] S332. Perform a vote on the output results. When at least half of the output results are abnormal, they are marked as abnormal data, and the final data labels are obtained.

[0122] like Figure 2 As shown in this embodiment, the steps for anomaly data labeling are explained by selecting three base classifiers: the COPOD algorithm, the CBLOF algorithm, and the isolated forest algorithm.

[0123] The COPOD algorithm uses the copular function to jointly model the distribution of all features, fully considering the correlation between all features, merging the anomaly levels of the data across all features, and outputting anomaly scores. The higher the anomaly score, the greater the likelihood of the sample data being anomalous. The algorithm's anomaly detection rate is set to 10%. Normalized data is input into the COPOD model, resulting in output 1.

[0124] The CBLOF algorithm first clusters the dataset, dividing the clustering results into large and small clusters based on the data size. Then, it calculates the outlier factor for each data point, determining whether it is an anomaly based on its magnitude; a larger value indicates a higher probability of anomaly. The algorithm uses KMeans++ as the clustering algorithm, sets the number of clusters to 8, and the anomaly detection rate to 10%. The normalized data is input into the CBLOF model, yielding output result 2.

[0125] The Isolation Forest algorithm constructs an isolated forest, calculates anomaly scores for each data point, and determines anomaly based on the score. The shorter the path length of a data point within the isolated forest, the higher its anomaly score, indicating a greater likelihood of an anomaly. The algorithm uses 256 samples, 100 isolated trees, and a 10% anomaly detection rate. Normalized data is input into the CBLOF model, yielding output result 3.

[0126] A vote is taken among the outputs 1, 2, and 3. If at least two outputs are abnormal, they are marked as abnormal data, and the final data labels are obtained.

[0127] S4. Train an autoencoder model using the preprocessed room energy consumption data, and select a reconstruction error threshold based on the data labels.

[0128] Further, step S4 includes the following steps:

[0129] S41. Based on the room energy consumption characteristics and the questionnaire, an outdoor daily average temperature of 25℃ is determined as the threshold for energy consumption conditions. Temperatures below 25℃ are classified as non-cooling conditions, and temperatures above or equal to 25℃ are classified as cooling conditions. The room energy consumption data for different conditions are then normalized, and the input to the autoencoder is constructed. The input for the non-cooling condition is... The input for cooling mode is It takes the form of a three-dimensional tensor, including the batch size of samples, the number of time steps, and the input features at each time step, as follows:

[0130]

[0131] In the formula, The value is the normalized value, and q is the original data. min q is the minimum value of this feature dimension. max t is the maximum value of this feature dimension, t is the time step dimension, n is the total number of samples, and n-(tk) is the batch processing dimension.

[0132] S42. Train the autoencoder model using data from two different operating conditions, and set an early stopping strategy. The autoencoder structure is as follows: Figure 3 As shown, both the encoder and decoder of the autoencoder are constructed using two-layer GRU networks, with a self-attention mechanism embedded after the last GRU layer of the encoder to improve the model's reconstruction performance at inflection points. The early stopping strategy is as follows: Figure 4 As shown, training stops when the loss on the model validation set no longer decreases.

[0133] The training steps for the autoencoder are as follows:

[0134] 1) Divide the dataset into a training set and a validation set;

[0135] 2) Initialize the model hyperparameters and set the early stopping strategy;

[0136] 3) Input the training set and validation set into the model for training, and plot the loss curve of the training process;

[0137] 4) Update the model's weights and biases using the Adam optimizer;

[0138] 5) When the early stopping condition is met, stop training and retain the result with the minimum loss. After training is completed, write the parameters to the folder for saving.

[0139] Further, step S42 also includes hyperparameter tuning and determination of the autoencoder model. The grid search range is set to units = {32, 64, 128, 256}, dropout rate = {0.01, 0.02, 0.03, 0.04, 0.05}, and batch size = {16, 32.64, 128}. The grid search result is: units = 128, dropout rate = 0.02, batch size = 32. The hyperparameters that need to be tuned are the number of neurons in the GRU layer (units), the dropout rate, and the batch size. Tuning is performed using a grid search method, specifically as follows:

[0140] Initialize hyperparameter values ​​and set hyperparameter variation ranges: Train models with different hyperparameter combinations, compare the loss values ​​on the validation set at the end of model training, and select the hyperparameter combination with the smallest loss value as the debugging result; the loss value is selected as the MSE (Mean Sequence of Error) as the evaluation metric, and the calculation method is as follows:

[0141]

[0142] In the formula, y i The actual value; The reconstructed values ​​are the model values; n is the number of samples.

[0143] S43, Combine the data from the two working conditions ( and Input the pre-trained autoencoder model reconstruction sequence, calculate the reconstruction error sequences E1 and E2, and plot the histogram of reconstruction error distribution for different energy consumption periods, as shown below. Figure 5 , Figure 6As shown. Based on the data labels obtained in step S3, the proportion of normal data in the dataset is determined, and this proportion is used as the quantile for selecting the reconstruction error threshold. The reconstruction error thresholds for non-cooling non-working periods are θ′1, θ′2, θ″1, and θ″2, respectively.

[0144] The formula for calculating reconstruction error is as follows:

[0145]

[0146] In the formula, q i This is the raw energy consumption data; To reconstruct energy consumption data.

[0147] S5. The energy consumption sequence of the room to be detected is reconstructed using an autoencoder model to obtain the reconstructed energy consumption sequence, and the reconstruction error is calculated. The anomaly detection result is obtained based on the reconstruction error threshold.

[0148] Further, step S5 includes the following steps:

[0149] S51. Determine the energy consumption condition based on the outdoor temperature corresponding to the data to be detected, and select the appropriate self-encoder model;

[0150] S52. Construct the data to be detected into a three-dimensional tensor. Input the autoencoder model corresponding to the working condition, obtain the reconstruction sequence, and calculate the reconstruction error E;

[0151] S53. Compare the reconstruction error E with the threshold θ, and determine the data exceeding the threshold as abnormal energy consumption.

[0152] like Figure 7 As shown, in another embodiment of this application, a scientific research building room energy consumption anomaly detection system based on ensemble learning and deep learning is provided. The system includes a data acquisition module, a data preprocessing module, an anomaly data labeling module, a model training module, and an anomaly detection module.

[0153] The data acquisition module is used to acquire historical room energy consumption data, outdoor meteorological data, and date attribute data;

[0154] The data preprocessing module is used to preprocess room energy consumption data, including distorted data cleaning, missing value imputation, and abrupt value repair.

[0155] The abnormal data marking module is used to mark anomalies in the preprocessed room energy consumption data using an integrated learning framework and obtain data labels.

[0156] The model training module is used to train an autoencoder model using preprocessed room energy consumption data and select a reconstruction error threshold based on the data labels.

[0157] The anomaly detection module is used to reconstruct the energy consumption sequence of the room to be detected using an autoencoder model to obtain the reconstructed energy consumption sequence, calculate the reconstruction error, and obtain the anomaly detection result based on the reconstruction error threshold.

[0158] It should be noted that the system provided in the above embodiments is only an example of the division of the above functional modules. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure can be divided into different functional modules to complete all or part of the functions described above. This system is applied to the method for detecting abnormal energy consumption in scientific research building rooms based on ensemble learning and deep learning in the above embodiments.

[0159] like Figure 8 As shown, in another embodiment of this application, a storage medium is also provided, storing a program that, when executed by a processor, implements a method for detecting abnormal energy consumption in research building rooms based on ensemble learning and deep learning, specifically:

[0160] Acquire historical room energy consumption data, outdoor weather data, and date attribute data;

[0161] Preprocessing of room energy consumption data includes cleaning distorted data, imputing missing values, and repairing abrupt changes;

[0162] An integrated learning framework was used to mark anomalies in the preprocessed room energy consumption data and obtain data labels.

[0163] An autoencoder model was trained using preprocessed room energy consumption data, and a reconstruction error threshold was selected based on the data labels.

[0164] The energy consumption sequence of the room to be detected is reconstructed using an autoencoder model to obtain the reconstructed energy consumption sequence, and the reconstruction error is calculated. The anomaly detection result is obtained based on the reconstruction error threshold.

[0165] It should be understood that various parts of this application can be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented using software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.

[0166] The above embodiments are preferred embodiments of the present invention, but the embodiments of the present invention are not limited to the above embodiments. Any changes, modifications, substitutions, combinations, or simplifications made without departing from the spirit and principle of the present invention shall be considered equivalent substitutions and shall be included within the protection scope of the present invention.

Claims

1. A method for detecting anomalies in energy consumption of rooms in scientific research buildings based on ensemble learning and deep learning, characterized in that, Includes the following steps: Acquire historical room energy consumption data, outdoor weather data, and date attribute data; Preprocessing of room energy consumption data includes cleaning distorted data, imputing missing values, and repairing abrupt changes; The distorted data cleaning specifically involves: Distortion cleaning of room energy consumption data is performed, including missing value detection and processing, and cumulative mutation value detection and processing. Missing values ​​refer to the absence of data at a certain point in time within continuous data. Cumulative mutation values ​​refer to the cumulative energy consumption value that appears after multiple consecutive time points have shown missing or zero values. Distortion detection is performed using the quartile method, as shown in the following formula: ; In the formula, Q1 and Q3 are the lower and upper quartiles, respectively, IQR is the interquartile range, and Q... U and Q L These are the upper and lower bounds of the abnormal threshold, respectively; The missing value imputation specifically involves: For the detected missing values, imputation is performed using the mean value under the same operating conditions, and the calculation formula is as follows: ; In the formula, The interpolated value is the energy consumption data at time j on the k-th day to be interpolated. To select energy consumption data at time j on day i with similar recent date attributes and meteorological parameters, n is the number of days to be selected, and n = 3 is taken. Specifically, it means to take the average energy consumption at the same time on 3 days with similar recent energy consumption conditions to interpolate the electricity consumption at the missing time. The mutation value repair specifically involves: For the detected cumulative mutation values, a weighted substitution method is used for repair. Specifically, the normal energy consumption time series of the same period of the most recent day with similar energy consumption conditions is selected. The ratio of the total energy consumption of the abnormal series to the total energy consumption of the normal series is used as the weighting coefficient. The normal energy consumption time series is then weighted to obtain the repaired energy consumption time series. The calculation formula is as follows: ; In the formula, The restored energy consumption time series is shown, where X is a normal energy consumption time series for the same period of the most recent day with similar date attributes and meteorological parameters. The hourly energy consumption values ​​for the abnormal time series. The hourly energy consumption values ​​for the selected normal time series; An integrated learning framework was used to mark anomalies in the preprocessed room energy consumption data and obtain data labels. The autoencoder model is trained using preprocessed room energy consumption data, and the reconstruction error threshold is selected based on the data labels. The specific steps include: The room energy consumption conditions are divided using outdoor temperature to obtain non-cooling and cooling conditions. The room energy consumption data under different conditions are normalized, and the input of the autoencoder is constructed in the form of a three-dimensional tensor, including the batch number of samples, the number of time steps, and the input features at each time step, as shown in the following formula: ; ; In the formula, The value is the normalized value. The original data, This is the minimum value of this feature dimension. The maximum value of this feature dimension is t, where t is the time step dimension, n is the total number of samples, and n-(tk) is the batch processing dimension. The autoencoder model was trained using data from two different operating conditions, and an early stopping strategy was set up. Training was stopped when the loss on the model validation set no longer decreased. The encoder and decoder of the autoencoder were both constructed using a two-layer GRU network, and a self-attention mechanism was embedded after the last GRU network layer of the encoder. Data from two different operating conditions are input into the trained autoencoder model to reconstruct the sequence. The reconstruction error is calculated, and histograms of the reconstruction error distribution for different energy consumption periods are plotted. Based on the acquired data labels, the proportion of normal data in the dataset is determined, and this proportion is used as the quantile for selecting the reconstruction error threshold. The reconstruction error calculation formula is as follows: ; In the formula, This is the raw energy consumption data; To reconstruct energy consumption data; The energy consumption sequence of the room to be detected is reconstructed using an autoencoder model to obtain the reconstructed energy consumption sequence, and the reconstruction error is calculated. The anomaly detection result is obtained based on the reconstruction error threshold.

2. The method for detecting abnormal energy consumption in research building rooms based on ensemble learning and deep learning according to claim 1, characterized in that, The acquisition of historical room energy consumption data, outdoor meteorological data, and date attribute data specifically includes: Historical hourly electricity consumption data of rooms, corresponding outdoor meteorological parameters, and date attribute data are obtained from the building energy consumption monitoring platform and local meteorological stations. The outdoor meteorological parameters include dry-bulb temperature, wet-bulb temperature, and relative humidity. The date attribute data includes week attribute information, weekday attribute information, and time attribute information.

3. The method for detecting abnormal energy consumption in research building rooms based on ensemble learning and deep learning according to claim 1, characterized in that, The step of using an integrated learning framework to mark anomalies in preprocessed room energy consumption data and obtain data labels includes the following steps: Preprocessed room energy consumption data Feature extraction is performed to construct the input of the ensemble learning framework. The input features include energy consumption data, time, outdoor temperature at the corresponding time, and short-term and periodic features of the energy consumption data. The input to the model is normalized, and the calculation formula is as follows: ; In the formula, Here are the normalized values, and x is the original data. This is the minimum value of this feature dimension. This is the maximum value of this feature dimension; Normalized data is input into the base classifier of the ensemble learning framework for outlier labeling. A voting method is used to determine the output of the base classifier. If the output of at least two base classifiers is outlier, the data is marked as outlier.

4. The method for detecting abnormal energy consumption in research building rooms based on ensemble learning and deep learning according to claim 3, characterized in that, The preprocessed room energy consumption data Feature extraction includes the following steps: The short-term characteristics of energy consumption data are represented by the first-order difference of hourly energy consumption, with intervals of 1 and 2. The periodicity of energy consumption data is characterized by the difference between hourly energy consumption and the median energy consumption at the same time within a week. The calculation formula is as follows: ; ; ; In the formula, Let m be the energy consumption time series for day m. Let m be the energy consumption at hour n on day m, where m is 365 and n is 24. Let be the median energy consumption at time j within a week, and ; The final model input is as follows: ; In the formula, Energy consumption at hour j on day i. Let j represent the outdoor temperature at the corresponding time. For the energy consumption interval of 1 at the corresponding time, it is the first-order difference. The first-order difference is the energy consumption interval of 2 at the corresponding time.

5. The method for detecting abnormal energy consumption in research building rooms based on ensemble learning and deep learning according to claim 3, characterized in that, The normalized data is input into the base classifier of the ensemble learning framework. The anomaly labeling process specifically includes the following steps: Select at least 3 base classifiers, and each base classifier performs anomaly identification on the normalized data and outputs the corresponding results; The output results are voted on, and when at least half of the output results are abnormal, they are marked as abnormal data, and the final data labels are obtained. The base classifiers include the COPOD algorithm, CBLOF algorithm, Isolation Forest algorithm, KNN algorithm, LOF algorithm, COF algorithm, and DBSCAN algorithm.

6. The method for detecting abnormal energy consumption in research building rooms based on ensemble learning and deep learning according to claim 1, characterized in that, The process of training the autoencoder model using data from two different operating conditions also includes the tuning and determination of the autoencoder model's hyperparameters. The hyperparameters that need tuning include the number of neurons (units) in the GRU layer, the Dropout rate, and the batch size. The tuning is performed using a grid search method, and the specific tuning method is as follows: Initialize hyperparameter values ​​and set the hyperparameter variation range: Train the model under different hyperparameter combinations, compare the loss values ​​on the validation set at the end of model training, and select the hyperparameter combination with the smallest loss value as the debugging result; the loss value is selected as the MSE (Mean Sequence of Excess) as the evaluation metric, and the calculation method is as follows: ; In the formula, The actual value; Reconstruct values ​​for the model; The number of samples; The training steps for the autoencoder are as follows: 1) Divide the dataset into a training set and a validation set; 2) Initialize the model hyperparameters and set the early stopping strategy; 3) Input the training set and validation set into the model for training, and plot the loss curve of the training process; 4) Update the model's weights and biases using the Adam optimizer; 5) When the early stopping condition is met, stop training and retain the result with the minimum loss. After training is completed, write the parameters to the folder for saving.

7. The method for detecting abnormal energy consumption in research building rooms based on ensemble learning and deep learning according to claim 1, characterized in that, The process of reconstructing the energy consumption sequence of the room to be detected using an autoencoder model to obtain a reconstructed energy consumption sequence, calculating the reconstruction error, and obtaining the anomaly detection result based on the reconstruction error threshold specifically includes the following steps: Determine the energy consumption condition based on the outdoor temperature corresponding to the data to be detected, and select the appropriate self-encoder model; The data to be detected is constructed into a three-dimensional tensor, input into the autoencoder model of the corresponding working condition, and the reconstruction sequence is obtained and the reconstruction error is calculated. By comparing the reconstruction error with the threshold, data exceeding the threshold is identified as abnormal energy consumption.

8. A system for detecting abnormal energy consumption in research building rooms based on ensemble learning and deep learning, characterized in that, The method for detecting abnormal energy consumption in rooms of scientific research buildings based on ensemble learning and deep learning, as described in any one of claims 1-7, includes a data acquisition module, a data preprocessing module, an abnormal data labeling module, a model training module, and an abnormal detection module; The data acquisition module is used to acquire historical room energy consumption data, outdoor meteorological data, and date attribute data; The data preprocessing module is used to preprocess room energy consumption data, including distorted data cleaning, missing value imputation, and abrupt value repair. The abnormal data marking module is used to mark anomalies in the preprocessed room energy consumption data using an integrated learning framework and obtain data labels. The model training module is used to train an autoencoder model using preprocessed room energy consumption data and select a reconstruction error threshold based on the data labels. The anomaly detection module is used to reconstruct the energy consumption sequence of the room to be detected using an autoencoder model to obtain the reconstructed energy consumption sequence, calculate the reconstruction error, and obtain the anomaly detection result based on the reconstruction error threshold.

Citation Information

Patent Citations

  • Unsupervised energy consumption anomaly detection method and device and storage medium

    CN114781779A