Building abnormal power consumption data detection method, device and equipment and storage medium
By using a long short-term memory network prediction model and a sliding time window to detect abnormal electricity consumption data, this technology solves the problem of low detection accuracy in existing technologies, achieves more efficient detection of abnormal electricity consumption data, and supports the development of smart grids.
Patent Information
- Application Number
- CN202511058785.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-30
- Publication Date
- 2025-11-11
AI Technical Summary
Existing methods for detecting abnormal electricity consumption data are not very accurate in the power industry, and their on-site implementation is costly, requiring a lot of manpower and resources.
A building electricity consumption data prediction model based on long short-term memory network is adopted. By acquiring current and historical electricity consumption data, the electricity consumption data in the current time period is predicted. The root mean square residual and sliding time window are used to detect abnormal electricity consumption data, thereby improving the detection accuracy.
It improves the detection rate and accuracy of abnormal power consumption data, reduces the possibility of false alarms caused by single noise points, provides a data foundation for abnormal power consumption data, and contributes to the development of smart grids.
Smart Images

Figure CN120930018A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of intelligent power distribution technology, and in particular to a method, device, computer equipment, computer-readable storage medium, and computer program product for detecting abnormal power consumption data in buildings. Background Technology
[0002] With the continuous improvement of information technology, the era of big data has arrived. Extracting valuable information from massive amounts of low-density data has become a hot topic across various industries, accompanied by numerous data privacy and security issues. For the power industry, with the continuous improvement of the power system's informatization level and the rapid growth of power data, various devices and systems have a large amount of data to process. Big data and event information are diverse, making it difficult to extract useful information. At the same time, due to various communication failures, equipment malfunctions, grid fluctuations, abnormal user behavior, external attacks, and other reasons, a large amount of abnormal data has emerged. This abnormal data affects the accuracy, integrity, and security of the data, and also contains important event information from the power grid. Therefore, research on mining large-scale power data, establishing anomaly detection algorithms, and modeling, analyzing, identifying, and processing abnormal power information are of great significance for analyzing the development of the power industry, mining event information, and developing smart grids.
[0003] Traditional methods for detecting abnormal electricity usage involve installing detection equipment on suspected customers. While this method is highly accurate, it is costly to implement on-site, consuming significant manpower and resources. In recent years, with advancements in data science and the development of data mining in the internet industry, several anomaly detection methods based on data mining and intelligent optimization algorithms have been proposed. Due to the common characteristics of power safety issues, data mining methods in similar industries are largely similar, but the accuracy of anomaly detection data still remains a concern. Summary of the Invention
[0004] Therefore, it is necessary to provide a method, device, computer equipment, computer-readable storage medium, and computer program product for detecting abnormal power consumption data in buildings, which can improve the accuracy of abnormal power consumption data detection, in response to the above-mentioned technical problems.
[0005] Firstly, this application provides a method for detecting abnormal power consumption data in buildings, including:
[0006] Obtain building electricity consumption data for the current preset time period, as well as historical building electricity consumption data for the previous preset time period;
[0007] Using historical building electricity consumption data as input, the pre-trained building electricity consumption data prediction model is called to predict the building electricity consumption data in the current time period, thus obtaining the building electricity consumption prediction data. The building electricity consumption data prediction model is obtained by training the Long Short-Term Memory Network with building electricity consumption data in different historical time periods.
[0008] Determine the root mean square residual of building electricity consumption data and building electricity consumption prediction data at each data acquisition time. Based on the root mean square residual corresponding to the data acquisition time, detect whether the building electricity consumption data at the data acquisition time is abnormal. The root mean square residual at the data acquisition time is determined based on the error of building electricity consumption data and building electricity consumption prediction data at each time point within a continuous time window of a preset length of data acquisition time.
[0009] Secondly, this application also provides a building abnormal power consumption data detection device, comprising:
[0010] The electricity consumption data acquisition module is used to acquire building electricity consumption data within the current preset time period, as well as historical building electricity consumption data within the previous preset time period.
[0011] The electricity consumption data prediction module is used to take historical building electricity consumption data as input, call the trained building electricity consumption data prediction model, predict the building electricity consumption data in the current time period, and obtain the building electricity consumption prediction data. The building electricity consumption data prediction model is trained on the long short-term memory network through building electricity consumption data in different historical time periods.
[0012] The abnormal electricity consumption data detection module is used to determine the root mean square residual of building electricity consumption data and building electricity consumption prediction data at each data acquisition time. Based on the root mean square residual corresponding to the data acquisition time, it detects whether the building electricity consumption data at the data acquisition time is abnormal. The root mean square residual at the data acquisition time is determined based on the error between the building electricity consumption data and the building electricity consumption prediction data at each time point within a continuous time window of a preset length of the data acquisition time.
[0013] Thirdly, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in any of the above embodiments of the building abnormal power consumption data detection method.
[0014] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps in any of the above embodiments of the method for detecting abnormal building electricity consumption data.
[0015] Fifthly, this application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps in any of the above embodiments of the building abnormal power consumption data detection method.
[0016] The aforementioned methods, devices, computer equipment, computer-readable storage media, and computer program products for detecting abnormal building electricity consumption data, specifically addressing multi-platform interconnected data interaction (such as multi-platform interconnected data interaction between intelligent power distribution systems and public buildings), pre-train a long short-term memory network based on multi-dimensional historical building electricity consumption data to predict building electricity consumption data within the current time period. Because the trained building electricity consumption data prediction model can better fit data on normal electricity consumption behavior, the prediction error for abnormal electricity consumption behavior data increases. Based on this, a sliding time window method for detecting abnormal electricity consumption data is proposed: In the actual detection stage, firstly, multi-dimensional building electricity consumption data within the current preset time period, as well as historical building electricity consumption data from the previous preset time period, are acquired. Electricity consumption data is input into a trained building electricity consumption prediction model to predict building electricity consumption data for the current time period, thus obtaining building electricity consumption prediction data. Secondly, a series of regression residuals are generated during the model prediction process. A sliding time window detection method is introduced. For each data collection time of the building electricity consumption data, the error between the building electricity consumption data and the predicted building electricity consumption data is determined at each time point within a preset continuous time window. Based on the error at each time point, the root mean square residual of the building electricity consumption data and the predicted building electricity consumption data is obtained. The root mean square residual is used to detect whether the building electricity consumption data at the data collection time is abnormal, improving the detection rate and accuracy of abnormal electricity consumption data. Furthermore, this provides a data foundation for abnormal electricity consumption data mining and contributes to the development of smart grids. Attached Figure Description
[0017] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0018] Figure 1 This is an application environment diagram of a building abnormal power consumption data detection method in one embodiment;
[0019] Figure 2 This is a flowchart illustrating a method for detecting abnormal building power consumption data in one embodiment;
[0020] Figure 3This is a flowchart illustrating a method for detecting abnormal building power consumption data in another embodiment;
[0021] Figure 4 This is a flowchart illustrating a method for detecting abnormal building power consumption data in yet another embodiment;
[0022] Figure 5 This is a structural block diagram of a building abnormal power consumption data detection device in one embodiment;
[0023] Figure 6 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0024] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0025] The building abnormal power consumption data detection method provided in this application embodiment can be applied to, for example... Figure 1 In the application environment shown, terminal 102 communicates with server 104 via a network. A data storage system can store the data that server 104 needs to process. The data storage system can be integrated onto server 104, or it can be located in the cloud or on another network server.
[0026] Specifically, the operator can upload the collected building electricity consumption data for the current preset time period and the historical building electricity consumption data for the previous preset time period to the server 104 via terminal 102. Then, the operator can send an abnormal electricity consumption data detection message to the server 104 via terminal 102. The server 104 obtains the historical building electricity consumption data. Next, using the historical building electricity consumption data as input, it calls the trained building electricity consumption data prediction model to predict the building electricity consumption data for the current time period, thus obtaining the predicted building electricity consumption data. The predicted building electricity consumption data prediction model is obtained by training a long short-term memory network with building electricity consumption data from different historical time periods. Finally, the root mean square residual of the building electricity consumption data and the predicted building electricity consumption data at each data collection time is determined. Based on the root mean square residual corresponding to the data collection time, the operator detects whether the building electricity consumption data at the data collection time is abnormal. The root mean square residual at the data collection time is determined based on the error between the building electricity consumption data and the predicted building electricity consumption data at each time point within a continuous time window of a preset length of the data collection time.
[0027] The terminal 102 can be, but is not limited to, various personal computers, laptops, smartphones, tablets, IoT devices, and portable wearable devices. IoT devices can include smart speakers, smart TVs, smart air conditioners, smart in-vehicle systems, and projection devices. Portable wearable devices can include smartwatches, smart bracelets, and head-mounted displays. Head-mounted displays can be virtual reality (VR) devices, augmented reality (AR) devices, and smart glasses. The server 104 can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services.
[0028] In one exemplary embodiment, such as Figure 2 As shown, a method for detecting abnormal power consumption data in buildings is provided, and this method is applied to... Figure 1 Taking server 104 as an example, the explanation includes the following steps (hereinafter referred to as S): S100 to S300. Wherein:
[0029] S100: Obtain building electricity consumption data within the current preset time period, as well as historical building electricity consumption data within the previous preset time period.
[0030] The building's electricity consumption data includes, but is not limited to, building temperature, humidity, carbon dioxide concentration, electricity consumption data of electrical equipment, electricity loss data of electrical equipment, alarm data from electricity meter alarm indicators, and personnel access records. Temperature and humidity can be collected by temperature and humidity sensors deployed in the building. Carbon dioxide concentration can be collected by measuring indoor carbon dioxide concentration using carbon dioxide sensors deployed in the building. Electricity consumption data of electrical equipment can be obtained by monitoring the power consumption of various electrical devices in the building through smart meters and energy management systems. Electricity loss data can be collected by power analyzers or power loss monitoring systems. Alarm data from electricity meter alarm indicators can be alarms issued by electricity meter alarm indicators when overload, short circuit, or other problems are detected. Personnel access records can be obtained from data recorded by access control systems. Alternatively, each data acquisition device can send its collected data to the building control system, allowing the server to retrieve the building's electricity consumption data from the control system.
[0031] In practical implementation, the server first obtains the building's temperature, humidity, carbon dioxide concentration, power consumption data of electrical equipment, power loss data of electrical equipment, alarm data from electricity meter indicators, and personnel entry and exit records from the building control system for the current day, as well as the same data from the previous day. This data can be used to help determine whether abnormal behavior is caused by specific equipment or personnel, and to assist in determining the time and location of the abnormal behavior. Understandably, the preset time period is determined according to the detection requirements and can be any duration other than a single day; this application does not limit this.
[0032] In other implementations, the server may obtain the electricity consumption data of each user's electrical equipment for the current day and the previous day, the power loss data of the electrical equipment, and the alarm data of the electricity meter alarm indicator from the building automation system, so as to detect whether the user's electricity consumption behavior is abnormal based on these building electricity consumption data.
[0033] S200 takes historical building electricity consumption data as input, calls a trained building electricity consumption data prediction model, predicts building electricity consumption data for the current time period, and obtains building electricity consumption prediction data. The building electricity consumption data prediction model is trained on a long short-term memory network using building electricity consumption data from different historical time periods.
[0034] The building electricity consumption forecast data includes, but is not limited to, the predicted temperature, humidity, carbon dioxide concentration, power consumption data of electrical equipment, power loss data of electrical equipment, alarm data of electricity meter alarm indicators, and personnel entry and exit record data for the current time period.
[0035] Among them, the LSTM (Long Short-Term Memory) network is a variant of the recurrent neural network. It uses an innovative method to compute the state of the hidden layer, which includes multiple gate units. The LSTM network introduces parameters to control the memory state, and each unit can decide whether to pass the upstream state to the downstream state. Therefore, this model can identify patterns at different scales in time series and achieve long-distance propagation of information. The gate structure of the LSTM network also has a certain degree of noise resistance. This inherent characteristic of the LSTM network ensures the robustness of the long short-term memory residual algorithm proposed in this embodiment. In addition, numerous studies have found that the LSTM network has strong generalization ability and is suitable for regression and classification problems based on multivariate time series with large amounts of data. The computation process of each unit of the LSTM network is shown in the following formula:
[0036]
[0037]
[0038]
[0039]
[0040]
[0041]
[0042] Among them, f t i t and o t These are the outputs of the forget gate, input gate, and output gate at the current time; c t-1 and c t These are the unit states of the previous and current time points, respectively. It is C t Candidate values; h t-1 It is the output of the hidden layer at the previous moment; x t It is the input at the current moment; W f W i, W c and W o It is the weight matrix; b f , b i , b c and b o σ is the deviation vector; σ is the sigmoid function.
[0043] In practical applications, an initial building electricity consumption data prediction model can be pre-built based on a Long Short-Term Memory (LSTM) network. Subsequently, building electricity consumption data from different historical time periods (e.g., 5 years) are collected. The building electricity consumption data undergoes preprocessing such as data cleaning and feature extraction. The preprocessed building electricity consumption data is then input into the initial building electricity consumption data prediction model, and the model's hyperparameters are iteratively adjusted to obtain a trained building electricity consumption data prediction model. Understandably, the different historical time periods are determined according to the detection requirements and can be any length other than five years; this application does not impose any limitations on this.
[0044] In practice, the server performs preprocessing such as data cleaning and standardization on historical building electricity consumption data. The preprocessed historical building data from the previous day is then input into the trained building electricity consumption prediction model to predict the building electricity consumption data for the day.
[0045] S300 determines the root mean square residual of building electricity consumption data and building electricity consumption prediction data at each data acquisition time, and detects whether the building electricity consumption data at the data acquisition time is abnormal based on the root mean square residual corresponding to the data acquisition time. The root mean square residual at the data acquisition time is determined based on the error of historical building electricity consumption data and building electricity consumption prediction data at each time point within a continuous time window of a preset length of the data acquisition time.
[0046] Among them, abnormal power consumption data can be building power consumption data under abnormal power consumption behavior, including but not limited to current overload, current short circuit and leakage.
[0047] In this embodiment, after training a Long Short-Term Memory (LSTM) network based on building electricity consumption data within a historical time period, the resulting building electricity consumption prediction model tends to fit building electricity consumption data under normal consumption behavior. Therefore, it may generate large regression residuals at outliers, where the regression residuals represent the difference between the model's predicted values and the actual observed values. After regression modeling, a series of residuals are obtained. Furthermore, since the building electricity consumption data uses data from multiple features (such as temperature, humidity, carbon dioxide concentration, electricity consumption data of electrical equipment, electricity loss data of electrical equipment, alarm data from electricity meter indicators, and personnel entry and exit records), there will be multiple residuals at each time point. To integrate these residuals into a single scalar, an appropriate measurement method needs to be selected. Given that both the model input and output are standardized, this embodiment uses RMS (Root Mean Square) to quantify the regression residuals, as shown in the following formula:
[0048]
[0049] Among them, RMSR t The root mean square of the residual at time t; m represents the number of features; y t A truth vector representing time t; represents the fitted value vector at time t, and 2α represents the length of the continuous sliding window.
[0050] Given that abnormal electricity consumption behavior typically occurs continuously over a specific period of time, and the residual of a single noise point may be too high, thus affecting the detection results of abnormal electricity consumption data, this application proposes a continuous sliding window method to detect abnormal electricity consumption data. Specifically, in practical applications, the operator can predefine the sliding window length 2α, where the sliding window length 2α represents each preceding and following α time units. Furthermore, a root mean square residual threshold can be pre-set according to the detection requirements to detect abnormal electricity consumption data. In specific implementation, after the server obtains the building electricity consumption prediction data through the building electricity consumption data prediction model, it obtains a series of regression residuals (errors) based on the acquired building electricity consumption data within the current time period and the building electricity consumption prediction data. Then, for each data acquisition time t of the building electricity consumption data, the regression residuals of all time points within the sliding window [t-α, t+α] corresponding to time point t are determined. Finally, the root mean square residual corresponding to time point t is determined using the above formula. Subsequently, the root mean square residuals corresponding to each data acquisition time are compared with the preset root mean square residual thresholds to determine whether each root mean square residual is greater than or equal to the preset root mean square residual threshold. If a root mean square residual greater than or equal to the preset root mean square residual threshold is detected, the building electricity consumption data at time t is determined to be abnormal electricity consumption data, and the data acquisition time corresponding to the root mean square residual is marked.
[0051] In the aforementioned method for detecting abnormal building electricity consumption data, for situations involving multi-platform interconnected data interaction (such as multi-platform interconnected data interaction between intelligent power distribution systems and public buildings), a long short-term memory network is pre-trained based on multi-dimensional historical building electricity consumption data to predict building electricity consumption data within the current time period. Since the trained building electricity consumption data prediction model can better fit data on normal electricity consumption behavior, the prediction error for abnormal electricity consumption behavior data increases. Therefore, based on this, a sliding time window method for detecting abnormal electricity consumption data is proposed: In the actual detection stage, firstly, multi-dimensional building electricity consumption data within the current preset time period and historical building electricity consumption data from the previous preset time period are acquired. The historical building electricity consumption data is then input into the trained building electricity consumption data prediction model. The electricity data prediction model predicts building electricity consumption data for the current time period, obtaining predicted building electricity consumption data. Secondly, during the model prediction process, a series of regression residuals are generated. A sliding time window detection method is introduced. For each data collection time of the building electricity consumption data, the error between the actual building electricity consumption data and the predicted building electricity consumption data is determined at each time point within a preset continuous time window. Based on the error at each time point, the root mean square residual of the actual building electricity consumption data and the predicted building electricity consumption data is obtained. The root mean square residual is used to detect whether the building electricity consumption data at the data collection time is abnormal, improving the detection rate and accuracy of abnormal electricity consumption data. Furthermore, it provides a data foundation for abnormal electricity consumption data mining, contributing to the development of smart grids.
[0052] In one exemplary embodiment, such as Figure 3 As shown, based on the root mean square residuals corresponding to the data acquisition time, it is determined whether the building electricity consumption data at the data acquisition time is abnormal, including S320 to S380:
[0053] S320, determine the root mean square residual of the building electricity consumption data and the building electricity consumption prediction data at each time point in the preset neighborhood time window of the data acquisition time.
[0054] S340, determine the number of neighborhood root mean square residuals that are greater than or equal to a preset root mean square residual threshold.
[0055] S360, the ratio of the quantity to the length of the preset neighborhood time window is determined as the residual ratio.
[0056] S380: If the residual ratio is detected to be greater than or equal to the preset residual ratio threshold, the building electricity consumption data at the time of data collection is determined to be abnormal electricity consumption data.
[0057] Among them, the root mean square residual of the neighborhood is the root mean square residual between the historical building electricity consumption data and the predicted building electricity consumption data at the time of neighborhood data collection.
[0058] In practical applications, firstly, the operator can pre-set the length of the neighborhood time window according to the detection requirements. For example, the length of the neighborhood time window can be between 1 and 20 seconds. It is understood that in other embodiments, other values besides 1 to 20 seconds can also be used, and this application does not limit this. Secondly, a residual ratio threshold is pre-set according to the detection requirements to detect abnormal electricity consumption data. In specific implementation, following the above example, after the server obtains the root mean square residuals of building electricity consumption data and building electricity consumption prediction data at each data collection time t, for each data collection time t, it determines the neighborhood root mean square residuals of the building electricity consumption data and building electricity consumption prediction data at each time point within the neighborhood time window neigh of that data collection time t:
[0059]
[0060] Then, the root mean square residuals of the neighborhood are compared with the preset root mean square residual threshold. The number of neighborhood root mean square residuals num that are greater than or equal to the preset root mean square residual threshold is recorded. The ratio num / neigh of the number is calculated to the length of the preset neighborhood time window. This ratio is determined as the residual ratio. Finally, the residual ratio is compared with the preset residual ratio threshold. If the residual ratio is greater than or equal to the preset residual ratio threshold, the building electricity consumption data at data collection time t is determined to be abnormal electricity consumption data.
[0061] In this embodiment, abnormal power consumption data is detected based on sliding window and root mean square residual, which can improve the detection accuracy of abnormal power consumption data and reduce the possibility of false alarms caused by a single noise point.
[0062] In one exemplary embodiment, the building electricity consumption data prediction model is trained based on the following method:
[0063] Obtain historical building electricity consumption datasets with multiple feature dimensions.
[0064] Among these, multiple feature dimensions may include, but are not limited to, building temperature, humidity, carbon dioxide concentration, power consumption data of electrical equipment, power loss data of electrical equipment, alarm data of electricity meter alarm indicators, and personnel entry and exit record data.
[0065] In practical applications, the method for obtaining historical building electricity consumption data with multiple feature dimensions can refer to the implementation steps of the method for obtaining historical building electricity consumption data in the above embodiments, and will not be repeated here. After obtaining the historical building electricity consumption data with multiple feature dimensions, the data is aligned and integrated into a dataset to obtain the historical building electricity consumption dataset. The historical building electricity consumption dataset includes building electricity consumption data for both normal and abnormal electricity consumption behaviors.
[0066] Dimensionality reduction is performed on the historical building electricity consumption dataset with multiple feature dimensions to obtain historical building electricity consumption data with the target feature dimension.
[0067] The target feature dimension is the feature dimension after dimensionality reduction.
[0068] In practical applications, dimensionality reduction algorithms can be used to project high-dimensional historical building electricity consumption data into a low-dimensional space. For example, principal component analysis can be used to determine the correlations between features of the historical building electricity consumption data. Orthogonal transformations can then be applied to convert the original features into new features. These new features are then arranged in order of variance to obtain the historical building electricity consumption data under the target feature dimension (such as electricity consumption data, electricity loss data, and alarm data from electricity meter indicators).
[0069] Training samples are constructed based on historical building electricity consumption data under the target feature dimension.
[0070] In practical applications, to improve model learning efficiency, this embodiment modifies the dimensions of the training samples. For example, the target features include electrical load, user electricity consumption loss, alarm data from the user's electricity meter alarm indicator, temperature, and humidity. The dimensional modification of the training samples can be as follows: the electrical load recorded every 15 minutes per day is used as the first dimension vector; the user's electricity consumption loss recorded every 15 minutes per day is used as the second dimension vector; and the user's alarm data from the electricity meter alarm indicator recorded every 15 minutes per day is used as the third dimension vector. The data from other feature dimensions in the target feature dimension are concatenated onto the matrix as additional feature dimensions to obtain a multi-dimensional vector as the training sample and test single sample case of the building electricity consumption data prediction model. Then, each single sample is labeled with a one-dimensional vector label to characterize whether it is abnormal electricity consumption behavior.
[0071] In other implementations, before constructing training samples based on historical building electricity consumption data under the target feature dimension, considering that electricity consumption fluctuates greatly during holidays and may affect the judgment of electricity consumption trends, historical building electricity consumption data during holidays is filtered out from the historical building electricity consumption data under the target feature dimension. This facilitates the training of a building electricity consumption data prediction model based on the filtered historical building electricity consumption data under the target feature dimension, thereby improving the prediction accuracy of the building electricity consumption data prediction model.
[0072] The training samples are input into the constructed initial building electricity consumption data prediction model to determine the prediction error of the initial building electricity consumption data prediction model. The model parameters are iteratively adjusted based on the prediction error until the prediction error is less than the preset prediction error threshold, thus obtaining the trained building electricity consumption data prediction model.
[0073] In practical applications, during the model training phase, an initial building electricity consumption data prediction model is pre-built based on a long short-term memory network. A prediction error threshold is pre-set according to the detection requirements to evaluate the model's prediction performance. Subsequently, training samples are input into the initial building electricity consumption data prediction model. Based on the actual measured values of building electricity consumption and the predicted building electricity consumption data output by the model, the prediction error is calculated using a pre-set loss function (such as mean squared error). The model's hyperparameters are iteratively adjusted based on the prediction error and an optimizer (such as the Adam optimizer) to obtain the trained building electricity consumption data prediction model.
[0074] In one exemplary embodiment, such as Figure 4 As shown, dimensionality reduction processing is performed on the historical building electricity consumption dataset with multiple feature dimensions to obtain historical building electricity consumption data under the target feature dimension, including S420 to S460:
[0075] S420 determines the feature contribution of each feature dimension.
[0076] Among them, the feature contribution degree is used to characterize the degree of influence of the feature dimension on the target variable in the prediction of building electricity consumption data. The higher the contribution degree, the more helpful the model is to make accurate predictions.
[0077] In practical applications, for each feature dimension, its feature contribution can be calculated based on statistical methods to determine the correlation between the feature dimension and the target, using the correlation as the feature contribution. For example, statistical methods can include Pearson correlation coefficient and variance inflation factor. Feature contribution can also be calculated based on nonlinear split lines, such as using decision trees to calculate the information gain of a feature dimension as the feature contribution, or using random forests to calculate the degree of performance degradation after shuffling a certain feature dimension.
[0078] S440: Filter out feature dimensions whose feature contribution is lower than the preset feature contribution threshold from multiple feature dimensions, and determine the remaining feature dimensions after filtering as the first feature dimension.
[0079] The number of first feature dimensions can be multiple.
[0080] In practical applications, the operator can pre-set a feature contribution threshold (e.g., 0.6) based on the detection requirements. It is understood that in other implementations, the feature contribution threshold can be any value other than 0.6, such as 0.5 or 0.8, and this application does not limit this. In specific implementation, the feature contribution of each feature dimension is compared with the preset feature contribution threshold. Feature dimensions with a feature contribution lower than the preset threshold that have a relatively small impact on abnormal electricity consumption data detection are filtered out, and the remaining feature dimensions are determined as the first feature dimension.
[0081] S460, based on principal component analysis, performs feature dimensionality reduction on the historical building electricity consumption data under the first feature dimension to obtain the historical building electricity consumption data under the second feature dimension. The historical building electricity consumption data under the target feature includes the historical building electricity consumption data under the first feature and the second feature.
[0082] In practical applications, the server uses principal component analysis to analyze the correlation between historical building electricity consumption data under multiple first feature dimensions. It then transforms the original feature dimensions into new ones using orthogonal transformation, and arranges these new feature dimensions in order of variance to obtain historical building electricity consumption data under the second feature dimension. Subsequently, the server merges the first and second feature dimensions into the target feature dimension, obtaining historical building electricity consumption data under the target feature dimension, which is used for model training and anomaly detection.
[0083] In this embodiment, feature dimensions with low contribution are first filtered out based on feature contribution. Then, principal component analysis is used to reduce the dimensionality of the remaining feature dimensions. Finally, the dimensionality-reduced feature dimensions are merged with the filtered remaining feature dimensions. This hybrid feature dimensionality reduction method is beneficial to both reduce the data analysis pressure of building electricity consumption data prediction and improve prediction accuracy.
[0084] In one exemplary embodiment, determining the feature contribution of each feature dimension includes:
[0085] Determine the total entropy of a multi-feature dimension historical building electricity consumption dataset.
[0086] For each feature dimension, the conditional entropy of the feature dimension is determined, and the difference between the total entropy and the conditional entropy is determined as the information gain of the feature dimension. The feature contribution of the feature dimension is determined based on the information gain.
[0087] The total entropy is the expected value of the information contained in all possible values of all feature dimension categories in the historical building electricity consumption dataset. Conditional entropy measures the uncertainty of one random variable given the condition that another random variable is known; its mathematical definition is the expected value of the conditional probability distribution with respect to the property of the condition.
[0088] In this embodiment, the server determines the total entropy of the historical building electricity consumption dataset with multiple feature dimensions based on the following formula:
[0089]
[0090] Where n is the number of categories.
[0091] Subsequently, for each feature, the conditional entropy of the feature is determined, and the difference between the total entropy and the conditional entropy is calculated, which is then determined as the information gain of that feature. For example:
[0092] The information gain of feature dimension A can be represented by the difference between the amount of information contained in the system and the expected value of the information after feature partitioning the system.
[0093]
[0094] D* represents the proportion of samples in class i to the total number of samples, D* is the number of samples in class i, D is the total number of samples, m is the number of sample classes, and v represents the number of subsets Dj.
[0095] The higher the information gain, the greater the contribution of the feature dimension to the dataset, and the greater its role in the classification process. Therefore, calculating the feature contribution based on the information gain of the feature dimension can be achieved by normalizing the information gain to obtain the feature contribution.
[0096] In an exemplary embodiment, before performing dimensionality reduction processing on the multi-feature-dimensional historical building electricity consumption dataset, the method further includes:
[0097] The historical building electricity consumption dataset is preprocessed, including at least one of missing value imputation, normalization, and outlier removal.
[0098] In practical applications, outliers may be caused by sensor malfunctions or communication interference. Outlier removal can be achieved by the server removing outliers from historical building electricity consumption datasets based on the 3σ criterion. Missing value imputation can be performed by the server using interpolation to fill in missing values based on the data before and after the missing data. Normalization can be performed by the server transforming data from different sources and scales in the historical building electricity consumption dataset to the same scale. Normalization methods include, but are not limited to, min-max normalization and Z-score standardization.
[0099] In this embodiment, preprocessing the historical building electricity consumption dataset helps improve the accuracy of abnormal electricity consumption data detection.
[0100] To provide a clearer explanation of the building abnormal electricity consumption data detection method provided in this application, a specific embodiment is described below, which includes the following steps:
[0101] S1, obtain the building electricity consumption data within the current preset time period, as well as the historical building electricity consumption data within the previous preset time period.
[0102] S2 takes historical building electricity consumption data as input, calls the trained building electricity consumption data prediction model, predicts the building electricity consumption data in the current time period, and obtains the building electricity consumption prediction data. The building electricity consumption data prediction model is trained on the long short-term memory network using building electricity consumption data in different historical time periods.
[0103] S3, for each data acquisition time, determine the root mean square residual of the building electricity consumption data and the building electricity consumption prediction data at each time point in the preset neighborhood time window of the data acquisition time.
[0104] S4, determine the number of neighborhood root mean square residuals that are greater than or equal to a preset root mean square residual threshold.
[0105] S5, the ratio of the quantity to the length of the preset neighborhood time window is determined as the residual ratio.
[0106] S6. If the residual ratio is detected to be greater than or equal to the preset residual ratio threshold, the building electricity consumption data at the time of data collection is determined to be abnormal electricity consumption data.
[0107] During the model training phase, the building electricity consumption data prediction model is trained based on the following steps:
[0108] S101, Obtain a historical building electricity consumption dataset with multiple feature dimensions, and preprocess the historical building electricity consumption dataset. The preprocessing includes at least one of missing value imputation, normalization, and outlier removal.
[0109] S102, determine the total entropy of the historical building electricity consumption dataset with multiple feature dimensions.
[0110] S103, for each feature dimension, determine the conditional entropy of the feature dimension, and determine the information gain of the feature dimension by the difference between the total entropy and the conditional entropy. Determine the feature contribution of the feature dimension based on the information gain.
[0111] S104, filter out feature dimensions whose feature contribution is lower than the preset feature contribution threshold from multiple feature dimensions, determine the remaining feature dimensions after filtering as the first feature dimension, perform feature dimensionality reduction on the historical building electricity consumption data under the first feature dimension based on principal component analysis, and obtain the historical building electricity consumption data under the second feature dimension. The historical building electricity consumption data under the target feature dimension includes the historical building electricity consumption data under the first feature dimension and the second feature dimension.
[0112] S105, training samples are constructed based on historical building electricity consumption data under the target feature dimension.
[0113] S106. Input the training samples into the constructed initial building electricity consumption data prediction model, determine the prediction error of the initial building electricity consumption data prediction model, and iteratively adjust the model parameters based on the prediction error until the prediction error is less than the preset prediction error threshold, thereby obtaining the trained building electricity consumption data prediction model.
[0114] In practical applications, the process of the building abnormal electricity consumption data detection method based on the Long Short-Term Memory residual algorithm is as follows:
[0115]
[0116] The definitions, units, and value ranges of the parameters in the Long Short-Term Memory residual algorithm are shown in the table below:
[0117]
[0118] It is understood that the range of values for the above parameters is only an example and is not intended to be the only limitation.
[0119] To verify the accuracy of the Long Short-Term Memory Residual (LSTM-R) algorithm in detecting abnormal electricity consumption data, this embodiment selects three years of user and related data from a smart low-carbon building, randomly sampling 30,000 sets of data as training data and 10,000 sets of data as test data. The accuracy of linear regression (LR) and convolutional neural network (CNN) is compared, and the experimental results are recorded. As shown in the table below, the LSTM-R algorithm outperforms the LSTM-R algorithm in terms of accuracy on both the training and test sets.
[0120]
[0121] As the training time in the LSTM-R model increases, the error rate of the model gradually decreases and tends to stabilize. The final accuracy of LSTM can reach over 90%.
[0122] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0123] In one exemplary embodiment, such as Figure 5 As shown, a building abnormal electricity consumption data detection device 600 is provided, including: an electricity consumption data acquisition module 610, an electricity consumption data prediction module 620, and an abnormal electricity consumption data detection module 630, wherein:
[0124] The electricity consumption data acquisition module 610 is used to acquire building electricity consumption data within the current preset time period, as well as historical building electricity consumption data within the previous preset time period.
[0125] The electricity consumption data prediction module 620 is used to take historical building electricity consumption data as input, call the trained building electricity consumption data prediction model, predict the building electricity consumption data in the current time period, and obtain the building electricity consumption prediction data. The building electricity consumption data prediction model is trained on the long short-term memory network using building electricity consumption data in different historical time periods.
[0126] The abnormal electricity consumption data detection module 630 is used to determine the root mean square residual of building electricity consumption data and building electricity consumption prediction data at each data acquisition time, and to detect whether the building electricity consumption data at the data acquisition time is abnormal based on the root mean square residual corresponding to the data acquisition time. The root mean square residual at the data acquisition time is determined based on the error between the building electricity consumption data and the building electricity consumption prediction data at each time point within a continuous time window of a preset length of the data acquisition time.
[0127] In an exemplary embodiment, the abnormal electricity consumption data detection module 630 is further configured to determine the root mean square residual of the building electricity consumption data and the predicted building electricity consumption data at each time point within a preset neighborhood time window at the data acquisition time; determine the number of neighborhood root mean square residuals that are greater than or equal to a preset root mean square residual threshold; determine the ratio of the number to the length of the preset neighborhood time window as the residual ratio; and determine the building electricity consumption data at the data acquisition time as abnormal electricity consumption data if the residual ratio is detected to be greater than or equal to the preset residual ratio threshold.
[0128] In one exemplary embodiment, the building abnormal power consumption data detection device 600 further includes a dimensionality reduction processing module 640 and a module training module 650:
[0129] The electricity data acquisition module 610 is also used to acquire historical building electricity data sets with multiple feature dimensions;
[0130] The dimensionality reduction processing module 640 is used to perform dimensionality reduction processing on the historical building electricity consumption dataset with multiple feature dimensions to obtain the historical building electricity consumption data under the target feature dimension;
[0131] The module training module 650 is used to construct training samples based on historical building electricity consumption data under the target feature dimension; input the training samples into the constructed initial building electricity consumption data prediction model, determine the prediction error of the initial building electricity consumption data prediction model, iteratively adjust the model parameters based on the prediction error until the prediction error is less than the preset prediction error threshold, and obtain the trained building electricity consumption data prediction model.
[0132] In an exemplary embodiment, the dimensionality reduction processing module 640 is further configured to determine the feature contribution of each feature dimension; filter out feature dimensions whose feature contribution is lower than a preset feature contribution threshold from multiple feature dimensions, and determine the remaining feature dimensions after filtering as the first feature dimension; perform feature dimensionality reduction on the historical building electricity consumption data under the first feature dimension based on principal component analysis to obtain the historical building electricity consumption data under the second feature dimension; the historical building electricity consumption data under the target feature dimension includes the historical building electricity consumption data under the first feature dimension and the second feature dimension.
[0133] In an exemplary embodiment, the dimensionality reduction processing module 640 is further configured to determine the total entropy of the historical building electricity consumption dataset with multiple feature dimensions; for each feature dimension, determine the conditional entropy of the feature dimension, determine the difference between the total entropy and the conditional entropy as the information gain of the feature dimension, and determine the feature contribution of the feature dimension based on the information gain.
[0134] In an exemplary embodiment, the building abnormal electricity consumption data detection device 600 further includes a data preprocessing module for preprocessing the historical building electricity consumption dataset. The preprocessing includes at least one of missing value imputation, normalization, and outlier removal.
[0135] Each module in the aforementioned building abnormal power consumption data detection device 600 can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in the processor of a computer device in hardware form or independent of it, or stored in the memory of a computer device in software form, so that the processor can call and execute the corresponding operations of each module.
[0136] In one exemplary embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 6 As shown, this computer device includes a processor, memory, input / output (I / O) interfaces, and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operating system and computer programs stored in the non-volatile storage media. The database stores data. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network. When the computer program is executed by the processor, it implements a method for detecting abnormal building power consumption data.
[0137] Those skilled in the art will understand that Figure 6 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0138] In one exemplary embodiment, a computer device is provided, including a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the steps in any of the above embodiments of the building abnormal electricity consumption data detection method.
[0139] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored, which, when executed by a processor, implements the steps in any of the above embodiments of the building abnormal power consumption data detection method.
[0140] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in any of the above embodiments of the building abnormal electricity consumption data detection method.
[0141] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.
[0142] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.
[0143] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0144] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A method for detecting abnormal power consumption data in buildings, characterized in that, The method includes: Obtain building electricity consumption data for the current preset time period, as well as historical building electricity consumption data for the previous preset time period; Using the historical building electricity consumption data as input, the trained building electricity consumption data prediction model is called to predict the building electricity consumption data in the current time period, and the building electricity consumption prediction data is obtained. The building electricity consumption data prediction model is obtained by training a long short-term memory network with building electricity consumption data in different historical time periods. The root mean square residual of the building electricity consumption data and the building electricity consumption prediction data is determined at each data acquisition time. Based on the root mean square residual corresponding to the data acquisition time, it is detected whether the building electricity consumption data at the data acquisition time is abnormal. The root mean square residual at the data acquisition time is determined based on the error between the building electricity consumption data and the building electricity consumption prediction data at each time point within a continuous time window of a preset length of the data acquisition time.
2. The method according to claim 1, characterized in that, Based on the root mean square residual corresponding to the data acquisition time, detect whether the building electricity consumption data at the data acquisition time is abnormal electricity consumption data, including: The root mean square residual between the building electricity consumption data and the building electricity consumption prediction data is determined at each time point within a preset neighborhood time window of the data acquisition time. Determine the number of neighborhood root mean square residuals that are greater than or equal to a preset root mean square residual threshold. The ratio of the quantity to the length of the preset neighborhood time window is determined as the residual ratio; If the residual ratio is detected to be greater than or equal to a preset residual ratio threshold, the building electricity consumption data at the time of data collection is determined to be abnormal electricity consumption data.
3. The method according to claim 1, characterized in that, The building electricity consumption data prediction model was trained using the following method: Obtain historical building electricity consumption datasets with multiple feature dimensions; The historical building electricity consumption dataset with multiple feature dimensions is subjected to dimensionality reduction processing to obtain historical building electricity consumption data with the target feature dimension; Training samples are constructed based on historical building electricity consumption data under the aforementioned target feature dimensions; The training samples are input into the constructed initial building electricity consumption data prediction model, the prediction error of the initial building electricity consumption data prediction model is determined, and the model parameters are iteratively adjusted based on the prediction error until the prediction error is less than a preset prediction error threshold, thus obtaining the trained building electricity consumption data prediction model.
4. The method according to claim 3, characterized in that, The step of dimensionality reduction processing on the multi-feature-dimensional historical building electricity consumption dataset to obtain historical building electricity consumption data under the target feature dimension includes: Determine the feature contribution of each feature dimension; Filter out feature dimensions whose feature contribution is lower than a preset feature contribution threshold from multiple feature dimensions, and determine the remaining feature dimensions after filtering as the first feature dimension; Based on principal component analysis, the historical building electricity consumption data under the first feature dimension is reduced to obtain the historical building electricity consumption data under the second feature dimension. The historical building electricity consumption data under the target feature dimension includes historical building electricity consumption data under the first feature dimension and the second feature dimension.
5. The method according to claim 4, characterized in that, Determining the feature contribution of each feature dimension includes: Determine the total entropy of the historical building electricity consumption dataset with the multiple feature dimensions; For each feature dimension, the conditional entropy of the feature dimension is determined, and the difference between the total entropy and the conditional entropy is determined as the information gain of the feature dimension. The feature contribution of the feature dimension is determined based on the information gain.
6. The method according to any one of claims 3 to 5, characterized in that, Before performing dimensionality reduction processing on the multi-feature dimension historical building electricity consumption dataset, the method further includes: The historical building electricity consumption dataset is preprocessed, and the preprocessing includes at least one of missing value imputation, normalization, and outlier removal.
7. A device for detecting abnormal power consumption data in buildings, characterized in that, The device includes: The electricity consumption data acquisition module is used to acquire building electricity consumption data within the current preset time period, as well as historical building electricity consumption data within the previous preset time period. The electricity consumption data prediction module is used to take the historical building electricity consumption data as input, call the trained building electricity consumption data prediction model, predict the building electricity consumption data in the current time period, and obtain the building electricity consumption prediction data. The building electricity consumption data prediction model is obtained by training a long short-term memory network with building electricity consumption data in different historical time periods. The abnormal electricity consumption data detection module is used to determine the root mean square residual of the building electricity consumption data and the building electricity consumption prediction data at each data acquisition time, and to detect whether the building electricity consumption data at the data acquisition time is abnormal based on the root mean square residual corresponding to the data acquisition time. The root mean square residual at the data acquisition time is determined based on the error between the building electricity consumption data and the building electricity consumption prediction data at each time point within a continuous time window of a preset length of the data acquisition time.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.