CNN-Transform and LightGBM fusion-based building energy consumption prediction method and system
By using a fusion model of CNN-Transformer and LightGBM, combined with the MAPE-RW weighting strategy, the nonlinearity and temporal dependence of building energy consumption data are solved, achieving higher accuracy and more stable energy consumption prediction.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-29
- Publication Date
- 2026-04-03
AI Technical Summary
Existing technologies struggle to effectively capture the nonlinear characteristics and complex time-series dependencies of building energy consumption data, resulting in insufficient accuracy in predicting building electricity load.
The CNN-Transformer model is used to capture the complex temporal dependencies of building energy consumption data, and the LightGBM model is combined to capture the nonlinear characteristics of energy consumption data. The results are then fused using the MAPE-RW weighting strategy to improve prediction accuracy and stability.
It improves the accuracy and stability of building energy consumption prediction, reduces the risk of overfitting of a single model, and enhances generalization ability.
Smart Images

Figure CN121787655A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of energy consumption prediction technology, and in particular to a building energy consumption prediction method and system based on the fusion of CNN-Transformer and LightGBM. Background Technology
[0002] Building electrical load forecasting is a crucial component of modern building energy management systems. However, due to the nonlinear, non-stationary, and multi-scale characteristics of building electrical loads, achieving high-accuracy forecasting still faces numerous technical challenges.
[0003] Traditional statistical methods (such as Autoregressive Integrated Moving Average (ARIMA) and Lightweight Gradient Boosting Machine (LightGBM)) perform well in predicting stationary time series, but they struggle to capture the nonlinear characteristics and complex temporal dependencies of energy consumption data. While single machine learning models (such as Support Vector Machine (SVM) and Random Forest) are stable in specific scenarios, their limitation lies in their limited ability to jointly represent long-term trends and short-term high-frequency fluctuations. Summary of the Invention
[0004] The purpose of this application is to provide a building energy consumption prediction method and system based on the fusion of CNN-Transformer and LightGBM. The CNN-Transformer model captures the complex temporal dependencies of building energy consumption data, the LightGBM model captures the nonlinear characteristics of energy consumption data, and the MAPE-RW weighting strategy is combined to improve the accuracy and stability of prediction.
[0005] To achieve the above objectives, this application provides the following solution: Firstly, this application provides a building energy consumption prediction method based on the fusion of CNN-Transformer and LightGBM, including: Obtain historical building electricity consumption data and historical influencing factor data; historical building energy consumption data includes building electricity consumption data at different times; historical influencing factor data includes time-series weather temperature data and building category data.
[0006] Historical building electricity consumption data and historical influencing factor data are preprocessed to obtain preprocessed building electricity consumption data and preprocessed influencing factor data.
[0007] The CNN-Transformer model is trained by taking preprocessed influencing factor data as input and preprocessed building electricity consumption data as output, and the trained CNN-Transformer model is obtained; the CNN-Transformer model includes a CNN module and a Transformer module.
[0008] The LightGBM model is trained by taking preprocessed influencing factor data as input and preprocessed building electricity consumption data as output, and the trained LightGBM model is obtained.
[0009] The data of influencing factors to be predicted are input into the trained CNN-Transformer model and the trained LightGBM model, respectively, and the first and second prediction results of building electricity consumption data are output.
[0010] The MAPE-RW algorithm is used to weight and fuse the first and second prediction results to obtain the target prediction result.
[0011] Secondly, this application provides a building energy consumption prediction system based on the fusion of CNN-Transformer and LightGBM, including: a data acquisition module, a preprocessing module, a CNN-Transformer model training module, a LightGBM model training module, a prediction module, and a weighted fusion module.
[0012] The data acquisition module is used to acquire historical building electricity consumption data and historical influencing factor data; historical building energy consumption data is building electricity consumption data at different times; historical influencing factor data includes time-series weather temperature data and building category data.
[0013] The preprocessing module is used to preprocess historical building electricity consumption data and historical influencing factor data to obtain preprocessed building electricity consumption data and preprocessed influencing factor data.
[0014] The CNN-Transformer model training module is used to train the CNN-Transformer model with preprocessed influencing factor data as input and preprocessed building electricity consumption data as output, so as to obtain the trained CNN-Transformer model; the CNN-Transformer model includes a CNN module and a Transformer module.
[0015] The LightGBM model training module is used to train the LightGBM model by taking preprocessed influencing factor data as input and preprocessed building electricity consumption data as output, and obtain the trained LightGBM model.
[0016] The prediction module is used to input the data of the influencing factors to be predicted into the trained CNN-Transformer model and the trained LightGBM model respectively, and output the first prediction result and the second prediction result of the building's electricity consumption data.
[0017] The weighted fusion module is used to perform weighted fusion of the first prediction result and the second prediction result using the MAPE-RW algorithm to obtain the target prediction result.
[0018] Thirdly, this application provides a computer device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the building energy consumption prediction method based on the fusion of CNN-Transformer and LightGBM as described above.
[0019] Fourthly, this application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the building energy consumption prediction method based on the fusion of CNN-Transformer and LightGBM as described above.
[0020] Fifthly, this application provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the building energy consumption prediction method based on the fusion of CNN-Transformer and LightGBM as described above.
[0021] According to the specific embodiments provided in this application, the following technical effects are disclosed: This application provides a building energy consumption prediction method and system based on the fusion of CNN-Transformer and LightGBM. By acquiring historical building electricity consumption data and historical influencing factor data and performing preprocessing, the data quality is improved. The CNN-Transformer model combines the advantages of local feature extraction of the convolutional architecture and global temporal dependency of the Transformer architecture, and more accurately captures the complex temporal dependencies of building energy consumption data. The LightGBM model can improve the fitting ability of nonlinear relationships. Based on the MAPE-RW algorithm, the first prediction result of the CNN-Transformer model and the second prediction result of the LightGBM model are weighted and fused. Through fusion and complementarity, the risk of overfitting of a single model is reduced, the generalization ability is improved, and the overall prediction accuracy is improved. Attached Figure Description
[0022] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0023] Figure 1 This is an application environment diagram of a building energy consumption prediction method based on the fusion of CNN-Transformer and LightGBM in one embodiment of this application; Figure 2 A flowchart illustrating a building energy consumption prediction method based on the fusion of CNN-Transformer and LightGBM, provided as an embodiment of this application; Figure 3 A flowchart of a model algorithm based on the fusion of CNN-Transformer and LightGBM is provided for one embodiment of this application; Figure 4 This is a schematic diagram of the functional structure of a CNN-Transformer model provided in an embodiment of this application; Figure 5 A comparison chart of predicted and actual values of three models—CNN-Transformer, LightGBM, and CNN-Transformer-LightGBM—provided for an embodiment of this application; Figure 6 A schematic diagram of the functional modules of a building energy consumption prediction system based on the fusion of CNN-Transformer and LightGBM provided in an embodiment of this application; Figure 7 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application.
[0024] Figure label: 1-Data acquisition module, 2-Preprocessing module, 3-CNN-Transformer model training module, 4-LightGBM model training module, 5-Prediction module, 6-Weighted fusion module. Detailed Implementation
[0025] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0026] To make the above-mentioned objectives, features and advantages of this application more apparent and understandable, the application will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0027] First, the technical terms involved in the embodiments of this application will be introduced.
[0028] Deep learning models (such as Long Short-Term Memory (LSTM) and Gated Recurrent Units (GRUs)) have advantages in temporal modeling, but they still have significant shortcomings in practical applications. First, they are prone to the vanishing gradient problem when processing extremely long sequences, leading to insufficient learning of long-term dependencies. Second, the serial computation characteristic limits training efficiency. Existing hybrid models and fusion strategies also have room for improvement. While the CNN-LSTM hybrid model can combine the advantages of spatial feature extraction and temporal modeling, it is insufficient in capturing global dependencies. Although the pure Transformer architecture can model global dependencies through self-attention mechanisms, it lacks the local feature extraction advantages of convolutional architectures and is difficult to deploy in real time in large-scale data scenarios. In addition, traditional model fusion methods (such as fixed-weighted averaging) usually determine the fusion coefficients based on historical data statistics, which cannot be dynamically adjusted according to load characteristics and is difficult to cope with pattern drift caused by seasonal changes. More seriously, when there are large differences in the predictive performance of the base models, simple weighted averaging may actually reduce the overall prediction accuracy.
[0029] Therefore, a more reliable and accurate method for predicting building energy consumption is needed to address the technical problems associated with the aforementioned technologies.
[0030] The building energy consumption prediction method based on the fusion of CNN-Transformer and LightGBM provided in this application embodiment can be applied to, for example... Figure 1In the application environment shown, terminal 101 communicates with server 102 via a network. A data storage system can store the data that server 102 needs to process. The data storage system can be set up independently, integrated into server 102, or placed in the cloud or on another server. Terminal 101 can send historical building energy consumption data and historical influencing factor data to be processed to server 102. After receiving the historical building energy consumption data and historical influencing factor data, server 102 preprocesses the historical building energy consumption data and historical influencing factor data to obtain preprocessed building energy consumption data and preprocessed influencing factor data. Using the preprocessed influencing factor data as input and the preprocessed building energy consumption data as output, a CNN-Transformer model is trained to obtain the trained CNN-Transformer model. The system employs a Mer model; the CNN-Transformer model includes a CNN module and a Transformer module; a LightGBM model is trained using preprocessed influencing factor data as input and preprocessed building electricity consumption data as output, resulting in a trained LightGBM model; the influencing factor data to be predicted is input into the trained CNN-Transformer model and the trained LightGBM model respectively, outputting a first prediction result and a second prediction result for the building electricity consumption data; the MAPE-RW algorithm is used to weight and fuse the first and second prediction results to obtain the target prediction result. The server 102 can feed back the obtained target prediction result to the terminal 101. Furthermore, in some embodiments, the building energy consumption prediction method based on the fusion of CNN-Transformer and LightGBM can also be implemented separately by the server 102 or the terminal 101. For example, the terminal 101 can directly perform building energy consumption prediction based on the fusion of CNN-Transformer and LightGBM on the historical building electricity consumption data and historical influencing factor data to be processed. Alternatively, the server 102 can obtain the historical building electricity consumption data and historical influencing factor data to be processed from the data storage system and perform building energy consumption prediction based on the fusion of CNN-Transformer and LightGBM on the historical building electricity consumption data and historical influencing factor data to be processed.
[0031] The terminal 101 can be, but is not limited to, various desktop computers, laptops, smartphones, tablets, IoT devices, and portable wearable devices. IoT devices can include smart speakers, smart TVs, smart air conditioners, and smart in-vehicle devices. Portable wearable devices can include smartwatches, smart bracelets, and head-mounted devices. The server 102 can be implemented using a standalone server or a server cluster composed of multiple servers, or it can be a cloud server.
[0032] In one exemplary embodiment, such as Figures 2-3 As shown, a building energy consumption prediction method based on the fusion of CNN-Transformer and LightGBM is provided. This method is executed by a computer device, specifically by a terminal or server alone, or by both a terminal and a server. In this embodiment, the method is applied to... Figure 1 Taking server 102 as an example, the explanation includes the following steps 201 to 206. Wherein: Step 201: Obtain historical building electricity consumption data and historical influencing factor data; historical building energy consumption data refers to building electricity consumption data at different times; historical influencing factor data includes time-series weather temperature data and building category data.
[0033] Step 202: Preprocess the historical building electricity consumption data and historical influencing factor data to obtain preprocessed building electricity consumption data and preprocessed influencing factor data.
[0034] Step 203: Using preprocessed influencing factor data as input and preprocessed building electricity consumption data as output, train the CNN-Transformer model to obtain the trained CNN-Transformer model; the CNN-Transformer model includes a CNN module and a Transformer module.
[0035] Step 204: Using preprocessed influencing factor data as input and preprocessed building electricity consumption data as output, train the LightGBM model to obtain the trained LightGBM model.
[0036] Step 205: Input the data of the influencing factors to be predicted into the trained CNN-Transformer model and the trained LightGBM model respectively, and output the first prediction result and the second prediction result of the building electricity consumption data.
[0037] Step 206: The MAPE-RW algorithm is used to perform weighted fusion of the first prediction result and the second prediction result to obtain the target prediction result.
[0038] By implementing steps 201 to 206 above, this application improves data quality by acquiring historical building electricity consumption data and historical influencing factor data and performing preprocessing; the CNN-Transformer model combines the advantages of local feature extraction of convolutional architecture and global temporal dependency of Transformer architecture, and more accurately captures the complex temporal dependency of building energy consumption data; the LightGBM model can improve the fitting ability of nonlinear relationships; based on the MAPE-RW algorithm, the first prediction result of the CNN-Transformer model and the second prediction result of the LightGBM model are weighted and fused, and the overfitting risk of a single model is reduced, the generalization ability is improved, and the overall prediction accuracy is improved through fusion and complementarity.
[0039] In step 201, the historical building energy consumption data includes building electricity consumption data at different times (i.e., historical building electricity consumption data), which is used to describe how electricity demand changes over time. The historical building electricity consumption data and historical influencing factor data together describe the dynamic characteristics of electricity demand changes over time.
[0040] In another exemplary embodiment of this application, the preprocessing includes steps 301 to 302.
[0041] Step 301: For historical data, replace missing values or delete duplicate values using the average value of the grouping conditions, and delete or replace outliers and invalid values using the quantile truncation method to obtain the processed data.
[0042] Step 302, apply the formula to the processed data. The processed data is then subjected to min-max normalization to obtain normalized data, where... The actual values in the processed data. The maximum value in the processed data. The minimum value in the processed data. This is the data after normalization.
[0043] In this application, missing and duplicate data are replaced by the average value of the grouping conditions or duplicate values are deleted. Abnormal and invalid data are deleted or replaced by the quantile truncation method. Then, the data is normalized to the maximum and minimum to make it fall into the [0, 1] interval. The preprocessed building energy consumption dataset is divided into training set, validation set and test set according to the preset ratio.
[0044] In another exemplary embodiment of this application, the CNN module includes a first convolutional layer and a second convolutional layer. The first convolutional layer includes a Conv1D layer, a BatchNorm layer, a GELU activation function, and a max pooling layer connected in sequence. The second convolutional layer includes a Conv1D layer and an adaptive average pooling layer connected in sequence.
[0045] The first convolution operation is as follows: in, The feature tensor after the first convolutional layer is... For max pooling, Let Gaussian error be the activation function of the linear unit. Perform batch normalization on the convolution output. It is a one-dimensional convolutional layer. Let B be a three-dimensional tensor, T be the batch size, F be the time step, and R be the feature dimension.
[0046] The second convolution operation is as follows: in, This is the feature tensor after the second convolutional layer. For adaptive average pooling operation, For the compressed time step, For feature dimensions.
[0047] This application employs two one-dimensional convolutional layers to extract local temporal features. The first convolutional layer consists of a Conv1D layer, a BatchNorm layer, a GELU activation function, and a max pooling layer connected in sequence. The second convolutional layer (adaptive average pooling dimensionality reduction) consists of a Conv1D layer and an adaptive average pooling layer connected in sequence. The feature tensor obtained after processing the second convolutional layer is the feature (or temporal feature) output by the convolutional network (CNN).
[0048] In another exemplary embodiment of this application, the Transformer module includes a position encoding module and a multi-head attention module, wherein the calculation formula for the multi-head self-attention is: Where Q, K, and V are the query matrix, key matrix, and value matrix, respectively. is the dimension of the key vector.
[0049] Specifically, the steps for building a CNN-Transformer model from training data (or training set) are as follows: Step 401: Represent the building energy consumption time series data (i.e., preprocessed building electricity consumption data and preprocessed influencing factor data; the building energy consumption dataset undergoes multiple preprocessing steps, including but not limited to time feature extraction, lag feature generation, and data normalization) as a three-dimensional tensor. Where B is the batch size, T represents the time step, and F represents the feature dimension.
[0050] Step 402: Use two one-dimensional convolutional layers to extract local temporal features.
[0051] The first convolution operation is: .
[0052] The second convolutional layer (adaptive average pooling dimensionality reduction) operation is as follows: .
[0053] Step 403, process the features output by the convolutional network. The location encoding is performed using the following formula: .
[0054] in, To incorporate the features after position encoding, A pre-defined position encoding matrix is used, containing position information generated by sine and cosine functions. The association weights between features at each time step are calculated using a multi-head self-attention mechanism, with the following formula: Where Q, K, and V represent the query, key, and value matrices, respectively, obtained through a linear transformation of the input features. is the dimension of the key vector.
[0055] The features after positional encoding are processed through a multi-head self-attention mechanism to capture global dependencies. This mechanism linearly projects the input features onto multiple subspaces, calculates attention weights in each subspace, and focuses on different feature interaction patterns. Finally, the outputs of all heads are merged to obtain the output features of the Transformer module. .
[0056] Step 404: Calculate the weights for each time step using an attention pooling layer, using the following formula: .
[0057] The features are aggregated as follows: Step 405: Finally, the prediction result is output after passing through a fully connected layer and the Softplus activation function. The calculation formula is as follows: .
[0058] in, .
[0059] The CNN-Transformer model constructed in this application, such as Figure 4 As shown, Conv1D is first used to extract local temporal features, and BatchNorm layer and GELU activation function are used to enhance the feature expression ability. Then, the feature dimension is reduced by max pooling layer. The feature sequence output by CNN is input into Transformer module, and multi-head self-attention mechanism is used to capture global temporal dependencies. Finally, the temporal features are weighted and aggregated by softmax-based attention pooling layer to output the preliminary prediction result of building energy consumption (i.e. the first prediction result).
[0060] This application trains a LightGBM model by aggregating the features of time series data (i.e., preprocessed building electricity consumption data and preprocessed influencing factor data) after sliding window processing, using the gradient boosting decision tree algorithm of LightGBM for training, and finally outputting the prediction results.
[0061] Time series data is processed by a sliding window to obtain continuous time series features. The sliding window processing procedure is as follows: for a feature sequence of length N, a sliding window of size L and step size 1 is used to generate N-L+1 continuous subsequences of length L, each subsequence containing feature data of L consecutive time steps.
[0062] The time series features (i.e., the features after the time series data has been processed by a sliding window) are aggregated by mean to obtain the feature matrix used for LightGBM training. The mean aggregation formula is as follows: in, For the original time series feature tensor, n For the sample size, L The sequence length (sliding window size) is the value of the sequence. For feature dimension, The aggregated feature matrix, For time step index, Let represent all features of all samples at time step j.
[0063] In this application, the gradient decision tree algorithm of LightGBM is used for training, and its objective function is composed of the loss function. L and regularization terms Ω composition.
[0064] In another exemplary embodiment of this application, the objective function of the LightGBM model is: in, The overall objective function includes a loss term. L and regularization terms Ω , For the first k A tree, K The total number of trees, and the regularization term. Used to control model complexity T A leaf node tree, Leaf weight, The threshold for leaf splitting. The L2 regularization coefficient is... For the first i The actual energy consumption value of each sample For the first i The predicted energy consumption value for each sample.
[0065] In each iteration, the objective function is optimized using the gradient boosting algorithm, and the first and second gradients are calculated: in, The first gradient is the first derivative of the loss function with respect to the predicted value. The second gradient is the second derivative of the loss function with respect to the predicted value. For the first t- In the first iteration i The predicted value for each sample.
[0066] The splitting is performed based on gradient information, and the splitting scheme with the maximum gain is selected. The gain calculation formula is as follows: in, and These are the left and right node sample sets after the split, respectively. The sample set of the parent node. The sum of the first-order gradients of the left node. The sum of the second-order gradients of the left node. This is a complexity control parameter.
[0067] The predicted building energy consumption is obtained by weighted summing of the prediction results from all trees. The formula for weighted summation is as follows: in, This represents the final predicted building energy consumption value under the LightGBM model. For the first i The input feature vector of each sample.
[0068] This application uses the statistical feature matrix obtained by mean aggregation of the original time series features (i.e., the features of time series data after sliding window processing) to train the LightGBM model. The gradient boosting decision tree algorithm of LightGBM is used for training. An early stopping strategy is adopted to terminate training when the performance on the validation set no longer improves. The gradient boosting decision tree is optimized based on the mean squared error loss function. Finally, the supplementary prediction result of building energy consumption (i.e., the second prediction result) is output.
[0069] This application leverages the complementary predictive advantages of two models by employing a MAPE-RW-based weighted fusion strategy, combining the prediction results of CNN-Transformer and LightGBM to obtain the final predicted building energy consumption value. For example, the CNN-Transformer model takes into account the time series features of the most recent 14 days (constructed from multi-dimensional data of the past 14 days, including historical data on building electricity consumption as well as data on influencing factors such as time and weather) and outputs the first prediction result; the LightGBM model takes into account the mean vector of the 14-day features (constructed from multi-dimensional data of the past 14 days, including historical data on building electricity consumption as well as data on influencing factors such as time and weather) and outputs the second prediction result.
[0070] In another exemplary embodiment of this application, step 206 is replaced by steps 501-502: Step 501: Calculate the weights of the CNN-Transformer model and the LightGBM model based on their mean absolute percentage error (MAS) and mean absolute percentage error (MAS) respectively. The formulas for calculating the weights of the CNN-Transformer model and the LightGBM model are as follows: . . in, The weights of the LightGBM model, The mean absolute percentage error of the LightGBM model. The mean absolute percentage error of the CNN-Transformer model. These are the weights of the CNN-Transformer model.
[0071] Step 502: Based on the weights of the CNN-Transformer model and the LightGBM model, the first prediction result and the second prediction result are weighted and fused to obtain the target prediction result. The calculation formula for the target prediction result is as follows: .
[0072] in, The target prediction result.
[0073] In another exemplary embodiment of this application, the formula for calculating the mean absolute percentage error is: in, n This represents the total number of samples (number of samples in the test set). For the first i The actual energy consumption value of each sample For the first i The predicted energy consumption value for each sample.
[0074] The weights are dynamically allocated based on the prediction errors (i.e. average absolute percentage error) of each model, and the predicted building energy consumption (target prediction result) is obtained through weighted fusion.
[0075] This application is based on the MAPE-RW weighted fusion strategy. First, the mean absolute percentage error of the CNN-Transformer model and the LightGBM model are calculated on the validation set respectively. Then, the model weights are dynamically determined (i.e., the weights are dynamically calculated based on the prediction errors of the two models on the validation set). Finally, the final building energy consumption prediction value is obtained through linear weighted fusion, so as to achieve the complementary prediction advantages of the two models.
[0076] Training of the fusion model of CNN-Transformer and LightGBM: The epoch number was set to 100, the batch size to 64, and the ratio of training set, validation set and test set to 6:2:2. The training set had 107,177 data points, the validation set had 26,794 data points and the test set had 33,493 data points. Sliding window prediction was used, the window size was set to 14, the loss function was Huber Loss, the optimizer was AdamW, the initial learning rate was 1e-4, and the learning rate scheduler was cosine annealing.
[0077] Output prediction results: The prediction results are the energy consumption data for the next day. The evaluation index is the coefficient of determination. The root mean square error (RMSE), mean absolute error (MAE), and other metrics are used to comprehensively evaluate the model's fit. The formulas for calculating these four metrics are shown below: A comparison of the fusion models of CNN-Transformer and LightGBM is shown in the figure below. Figure 5As shown, there are four curves: the true value, the CNN-Transformer predicted value, the LightGBM predicted value, and the CNN-Transformer-LightGBM predicted value.
[0078] This application uses a novel fusion prediction model of CNN-Transformer and LightGBM to predict building energy consumption, such as... Figure 4 As shown, the CNN-Transformer-LightGBM prediction model exhibits high accuracy and stability in data fitting and prediction, with its prediction curve closely matching the actual values and accurately tracking energy consumption fluctuations. Furthermore, the fusion model effectively smooths out the prediction fluctuations of individual models, maintaining a smooth and reliable prediction trajectory even in peak and abrupt change regions. Therefore, the intelligent building energy consumption method based on the fusion of CNN-Transformer and LightGBM proposed in this application can effectively reduce the prediction error of building models and improve their predictive performance.
[0079] Based on the same inventive concept, this application also provides a building energy consumption prediction system based on the fusion of CNN-Transformer and LightGBM for implementing the aforementioned building energy consumption prediction method based on the fusion of CNN-Transformer and LightGBM. The solution provided by this system is similar to the implementation described in the above method. Therefore, the specific limitations of one or more embodiments of the building energy consumption prediction system based on the fusion of CNN-Transformer and LightGBM provided below can be found in the limitations of the building energy consumption prediction method based on the fusion of CNN-Transformer and LightGBM described above, and will not be repeated here.
[0080] In one exemplary embodiment, a building energy consumption prediction system based on the fusion of CNN-Transformer and LightGBM is provided, such as... Figure 6 As shown, it includes: data acquisition module 1, preprocessing module 2, CNN-Transformer model training module 3, LightGBM model training module 4, prediction module 5, and weighted fusion module 6.
[0081] Data acquisition module 1 is used to acquire historical building electricity consumption data and historical influencing factor data; historical building energy consumption data are building electricity consumption data at different times; historical influencing factor data include time-series weather temperature data and building category data.
[0082] Preprocessing module 2 is used to preprocess historical building electricity consumption data and historical influencing factor data to obtain preprocessed building electricity consumption data and preprocessed influencing factor data.
[0083] The CNN-Transformer model training module 3 is used to train the CNN-Transformer model with preprocessed influencing factor data as input and preprocessed building electricity consumption data as output, so as to obtain the trained CNN-Transformer model; the CNN-Transformer model includes a CNN module and a Transformer module.
[0084] LightGBM model training module 4 is used to train the LightGBM model with preprocessed influencing factor data as input and preprocessed building electricity consumption data as output, so as to obtain the trained LightGBM model.
[0085] Prediction module 5 is used to input the data of influencing factors to be predicted into the trained CNN-Transformer model and the trained LightGBM model respectively, and output the first prediction result and the second prediction result of building electricity consumption data.
[0086] The weighted fusion module 6 is used to perform weighted fusion of the first prediction result and the second prediction result using the MAPE-RW algorithm to obtain the target prediction result.
[0087] In one exemplary embodiment, a computer device is provided, which may be a server or a terminal, and its internal structure diagram may be as follows. Figure 7 As shown, the 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 in the non-volatile storage media to run. The database stores building energy consumption prediction data based on the fusion of CNN-Transformer and LightGBM. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communication with external terminals via a network connection. When the computer program is executed by the processor, it implements a building energy consumption prediction method based on the fusion of CNN-Transformer and LightGBM.
[0088] Those skilled in the art will understand that Figure 7The 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.
[0089] In one exemplary embodiment, a computer device is also provided, 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 the above-described method embodiments.
[0090] In one exemplary embodiment, a computer-readable storage medium is provided storing a computer program that, when executed by a processor, implements the steps in the above-described method embodiments.
[0091] In one exemplary embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above-described method embodiments.
[0092] 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.
[0093] Those skilled in the art will understand that all or part of the processes in 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. When executed, the computer program can include the processes of the embodiments described above. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile 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).
[0094] 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, etc., and are not limited to these.
[0095] 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 specification.
[0096] This document uses specific examples to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the methods and core ideas of this application. Furthermore, those skilled in the art will recognize that, based on the ideas of this application, there will be changes in the specific implementation methods and application scope. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A building energy consumption prediction method based on the fusion of CNN-Transformer and LightGBM, characterized in that, include: Obtain historical building electricity consumption data and historical influencing factor data; Historical building energy consumption data includes building electricity consumption data at different times; historical influencing factor data includes time-series weather and temperature data, and building category data. Historical building electricity consumption data and historical influencing factor data are preprocessed to obtain preprocessed building electricity consumption data and preprocessed influencing factor data; A CNN-Transformer model is trained by taking preprocessed influencing factor data as input and preprocessed building electricity consumption data as output, resulting in a trained CNN-Transformer model; the CNN-Transformer model includes a CNN module and a Transformer module. The LightGBM model is trained by taking preprocessed influencing factor data as input and preprocessed building electricity consumption data as output. The data of influencing factors to be predicted are input into the trained CNN-Transformer model and the trained LightGBM model respectively, and the first and second prediction results of building electricity consumption data are output. The MAPE-RW algorithm is used to weight and fuse the first and second prediction results to obtain the target prediction result.
2. The building energy consumption prediction method based on the fusion of CNN-Transformer and LightGBM as described in claim 1, characterized in that, The CNN module includes a first convolutional layer and a second convolutional layer. The first convolutional layer includes a Conv1D layer, a BatchNorm layer, a GELU activation function, and a max pooling layer connected in sequence. The second convolutional layer includes a Conv1D layer and an adaptive average pooling layer connected in sequence. The first convolution operation is as follows: in, The feature tensor after the first convolutional layer is... For max pooling, Let Gaussian error be the activation function of the linear unit. Perform batch normalization on the convolution output. It is a one-dimensional convolutional layer. Let B be a three-dimensional tensor, T be the batch size, F be the time step, and R be the feature dimension. The second convolution operation is as follows: in, This is the feature tensor after the second convolutional layer. For adaptive average pooling operation, For the compressed time step, For feature dimensions.
3. The building energy consumption prediction method based on the fusion of CNN-Transformer and LightGBM as described in claim 1, characterized in that, The Transformer module includes a position encoding module and a multi-head attention module, wherein the calculation formula for the multi-head self-attention is: Where Q, K, and V are the query matrix, key matrix, and value matrix, respectively. is the dimension of the key vector.
4. The building energy consumption prediction method based on the fusion of CNN-Transformer and LightGBM as described in claim 1, characterized in that, The objective function of the LightGBM model is: in, The overall objective function includes a loss term. L and regularization terms Ω , For the first k A tree, K The total number of trees, and the regularization term. , T A leaf node tree, Leaf weight, The threshold for leaf splitting. The L2 regularization coefficient is... For the first i The actual energy consumption value of each sample For the first i The predicted energy consumption value for each sample.
5. The building energy consumption prediction method based on the fusion of CNN-Transformer and LightGBM as described in claim 1, characterized in that, The MAPE-RW algorithm is used to weight and fuse the first and second prediction results to obtain the target prediction result, which includes: Based on the mean absolute percentage error (MAS) of the CNN-Transformer model and the LightGBM model, the weights of the CNN-Transformer model and the LightGBM model are calculated respectively. The formulas for calculating the weights of the CNN-Transformer model and the LightGBM model are as follows: in, The weights of the LightGBM model, The mean absolute percentage error of the LightGBM model. The mean absolute percentage error of the CNN-Transformer model. These are the weights of the CNN-Transformer model; Based on the weights of the CNN-Transformer model and the LightGBM model, the first prediction result and the second prediction result are weighted and fused to obtain the target prediction result. The calculation formula for the target prediction result is as follows: ; in, The target prediction result.
6. The building energy consumption prediction method based on the fusion of CNN-Transformer and LightGBM as described in claim 5, characterized in that, The formula for calculating the mean absolute percentage error is: in, n The total number of samples, For the first i The actual energy consumption value of each sample For the first i The predicted energy consumption value for each sample.
7. A building energy consumption prediction system based on the fusion of CNN-Transformer and LightGBM, characterized in that, include: The data acquisition module is used to acquire historical building electricity consumption data and historical influencing factor data; Historical building energy consumption data includes building electricity consumption data at different times; historical influencing factor data includes time-series weather and temperature data, and building category data. The preprocessing module is used to preprocess historical building electricity consumption data and historical influencing factor data to obtain preprocessed building electricity consumption data and preprocessed influencing factor data. The CNN-Transformer model training module is used to train the CNN-Transformer model with preprocessed influencing factor data as input and preprocessed building electricity consumption data as output, so as to obtain the trained CNN-Transformer model; the CNN-Transformer model includes a CNN module and a Transformer module. The LightGBM model training module is used to train the LightGBM model with preprocessed influencing factor data as input and preprocessed building electricity consumption data as output, so as to obtain the trained LightGBM model. The prediction module is used to input the data of the influencing factors to be predicted into the trained CNN-Transformer model and the trained LightGBM model respectively, and output the first prediction result and the second prediction result of the building's electricity consumption data. The weighted fusion module is used to perform weighted fusion of the first prediction result and the second prediction result using the MAPE-RW algorithm to obtain the target prediction result.
8. A computer device, comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that the processor executes the computer program to implement the building energy consumption prediction method based on the fusion of CNN-Transformer and LightGBM as described in any one of claims 1-6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by a processor, the computer program implements the building energy consumption prediction method based on the fusion of CNN-Transformer and LightGBM as described in any one of claims 1-6.
10. A computer program product, comprising a computer program, characterized in that, When executed by a processor, the computer program implements the building energy consumption prediction method based on the fusion of CNN-Transformer and LightGBM as described in any one of claims 1-6.