Building energy consumption prediction method based on Bayesian regression and thermal inertia correction

. The accurate prediction of building energy consumption is a crucial prerequisite for demand response (DR) and energy efficiency management of buildings. Nevertheless, the thermal inertia and probability distribution characteristics of energy consumption are frequently ignored by traditional prediction methods. This paper proposes a building energy consumption prediction method based on Bayesian regression and thermal inertia correction. The thermal inertia correction model is established by introducing an equivalent temperature variable to characterize the influence of thermal inertia on temperature. The equivalent temperature is described as a linear function of the actual temperature, and the key parameters of the function are optimized through genetic algorithm (GA). Using historical energy usage, temperature, and date type as inputs and future building energy comsuption as output, a Bayesian regression prediction model is established. Through Bayesian inference, combined with prior information on building energy usage data, the posterior probability distribution of building energy usage is inferred, thereby achieving accurate forecast of building energy consumption. The case study is conducted using energy consumption data from a commercial building in Nanjing. The results of the case study indicate that the proposed thermal inertia correction method is effective in narrowing the distribution of temperature data from a range of 24.5°C to 36.5°C to a more concentrated range of 26.5°C to 34°C, thereby facilitating a more focused and advantageous data distribution for predictions. Upon applying the thermal inertia correction method, the relative errors of the Radial Basis Function (RBF) and Deep Belief Network (DBN) decreases by 2.0% and 3.1% respectively, reaching 10.9% and 7.0% correspondingly. Moreover, with the utilization of Bayesian regression, the relative error further decreases to 4.4%. Notably, the Bayesian regression method not only achieves reduced errors but also provides probability distribution, demonstrating superiority over traditional methods.


Introduction
As the society and economy develop rapidly, the building energy consumption has been accounting for an increasing share within the total energy consumption of the society (Narayanan et al. 2017).Buildings hold significant potential both in terms of demand response (DR) and energy efficiency improvement (EEI) (Esmaeili Shayan et al. 2022).
The prediction of building energy consumption is a crucial prerequisite for buildings to participate in DR and EEI.Through predicting, the power grid operation department can gain a more precise understanding of the future electricity supplydemand relationship, thereby allocating electrical resources more efficiently and enhancing the utilization of various resources.
A significant amount of research works has been conducted on the prediction of building energy consumption.From the perspective of physical models, (Angelis et al. 2013) constructs a prediction model for building energy consumption utilizing physical model based on thermodynamic calculations.(Zhang et al. 2021) takes the impact of different spatial layouts into account, applying spatial reconstruction and building simulations methods to better predict the distribution characteristics of building loads within entire communities.(Fang et al. 2021) introduces a day-ahead prediction model considering key feature search to forecast building energy consumption during transitional seasons.A comprehensive energy consumption prediction model is proposed by (Cao et al. 2023), which considers spatial features of time series data to predict short-term energy consumption and employs cooperative game theory to analyse the impact of these features on the prediction model.(Li et al. 2020) conducts simulation experiments for predicting building energy consumption by using swarm decision table (SDT) and introducing a dataset which represents the scenario of typical IoT connected to building energy demand prediction.An Elman recurrent neural network (RNN) model and an exponential model are established by (Bedi et al. 2020) to predict energy consumption and temperature under the scenario of IoT-driven buildings.(Yu et al. 2022) constructs a building energy consumption prediction system based on IoT, which can effectively predict energy consumption to enhance management capabilities and energy efficiency.(Cheng et al. 2021) proposes a day-ahead probability residential load prediction method based on deep learning, utilizing convolutional neural network with squeeze-andexcitation modules (CNN-SE) and micrometeorological data, together with the multi-channel with different weights to input data, making it possible to analyse numerous input data.A building energy consumption prediction model based on PCA-RF-AdaBoost is established by (Li et al. 2023), using principal component analysis (PCA) to reduce the input dimensions of the prediction model based on random forest (RF) and AdaBoost algorithms, improving the predicting performance.Research has also been conducted based on deep learning and neural network.A generative adversarial network model based on ResNetGan is built by (Fan et al. 2019) for predicting building energy consumption through adversarial games.A deep learning model using long short-term memory (LSTM) and GRU recurrent neural networks (RNN) is proposed by (Mohapatra et al. 2022) for predicting time series data to forecast building energy consumption, the model significantly improves prediction accuracy.(Jiang et al. 2023) offers a deep chained echo state network (DCESN) to enhance the capability of prediction, while (Lee et al. 2023) proposes an ensemble deep learning model to predict the energy consumption, and increases the effectiveness of deep learning through an integrated architecture.(Zhou et al. 2022) employs reinforcement learning (RL) and LSTM models to forecast the building energy consumption.The modelling method offered in (Almalaq et al. 2019) is established upon deep learning and GA for enhancing the prediction accuracy of LSTM.(Vijayan et al. 2022) compares the results of various machine learning and deep learning models, then establishes the dependencies between energy consumption and parameters such as temperature and wind speed.(Clayton et al. 2022) builds a hybrid energy consumption prediction model combining RF and ensemble deep learning methods, achieving accurate prediction and reducing prediction errors.(Luo et al. 2020) proposes the utilization of GA to optimize the parameters employed in neural network models, while (Chae et al. 2016) employs an Artificial Neural Network (ANN) model to predict short-term building energy consumption, along with the analysis of the optimal structure of the prediction model.(Wang et al. 2023) presents a novel hybrid neural network prediction model, combining bidirectional gate recurrent unit (BiGRU) with convolutional neural networks (CNN) for bidirectional cyclic training of feature vectors extracted by CNN, which can make use of residual connections to comprehensively learn features.(Liu et al. 2023) proposes a hybrid forecasting method for industrial and commercial buildings, merging time-series generation adversarial network (TimeGAN) with a convolutional neural network (CNN)-enhanced long short-term memory (LSTM) neural network, to cope with the data deficit problem.(Lauricella et al. 2023) proposes a day-ahead and intraday load forecasting method for buildings, using limited data batches spanning two weeks for training, which can be implemented under the condition that large datasets are not available.(Qin et al. 2023) designs a building-level forecasting model that combines federated learning (FL), the differentiable architecture search (DARTS) technique, and a two-stage personalization approach together, to overcome the limited data and overfitting problems.(Wang et al. 2022) presents an adaptive probabilistic load forecasting model designed to autonomously generate high-performance neural network architectures tailored for diverse buildings, in order to improve the adaptivity and efficiency of the forecasting.(Ramos et al. 2022) uses a decision tree to identify different contexts of energy patterns, which is evaluated with a reinforcementlearning-based decision criterion to develop the forecasting algorithm.(Syed et al. 2021) proposes a hybrid deep learning model, which includes data cleaning stage and model building stage, to predict energy consumption for smart buildings.(Moradzadeh et al. 2022) presents an improved hybrid machine-learning-based model for forecasting the cooling load (CL) and the heating load (HL) of residential buildings by investigating different types of CL and HL forecasting models.(Xu et al. 2021) proposes a load forecasting method based on modified twolayer LSTM for building energy systems.(Cai et al. 2019) develops a deep learning-based technique for day-ahead multistep load forecasting in commercial buildings by adopting RNN and CNN.(Moradzadeh et al. 2022) presents a heating load demand forecasting approach based on Cyber-Secure Federated Deep Learning (CSFDL), which provides forecasting without revealing the privacy.
Despite the significant amount of theoretical progress that has been achieved, the aforementioned research works still exhibits deficiencies in aspects such as thermal inertia and uncertainty associated with building energy consumption.These deficiencies primarily manifest in two aspects: 1) Thermal inertia: Despite utilizing temperature as an input for the prediction model, existing works overlook the long-term cumulative effects of temperature on energy consumption variations.2) Uncertainty: Existing works take the output obtained from the prediction model as the forecast value of energy consumption, yet fail to reflect the probability distribution of prediction outcomes.
Targeting at the issues mentioned above, this paper proposes a building energy consumption prediction method based on Bayesian regression and thermal inertia correction.The method not only enhances the correlation between temperature and energy consumption through thermal inertia correction, but also addresses the uncertainty of prediction samples and obtains the probability distribution of predicted energy consumption by utilizing Bayesian regression.
The remainder of the paper are structed as follows: Section 2 introduces the thermal inertia correction model of buildings, Section 3 proposes the energy consumption prediction method based on Bayesian regression, Section 4 contains the case study, Section 5 gives the result and discussion and Section 6 concludes the paper.

Energy Consumption and Temperature Data Description
As widely recognized, temperature and date-type are two major influential factors affecting building energy consumption (Lin et al. 2023), (Wang et al. 2021).
Fig. 1(a) illustrates curves of daily maximum temperature and daily electricity consumption of a commercial building in Nanjing from June 1 th and September 15 th , Fig. 1(b) presents a scatter plot of daily maximum temperature and daily electricity consumption.It can be seen that, on one hand, there exists a clear positive correlation between daily electricity consumption and temperature; on the other hand, electricity consumption of weekdays (from Monday to Friday) is notably higher than that of weekends (Saturday and Sunday).
In addition to the factors listed above, thermal inertia is another crucial factor on energy consumption.To demonstrate the impact of thermal inertia, Fig. 1(c) provides a scatter plot of daily maximum temperature-daily electricity consumption for different time periods, excluding data from weekends, among which the data from June 1 st to July 18 th represents the early summer period, while the data from July 19 th to September 15 th represents the late summer period.It is evident that energy consumption during the late summer period is higher than that during the early summer period when at the same temperature level, highlighting the influence of thermal inertia.

Thermal Inertia Correction Model Development
The reason for such phenomenon lies in thermal inertia, where energy consumption is not only related to the current temperature but also the historical temperature.After introducing equivalent temperature T eq to represent the impact of thermal inertia on temperature, the thermal inertia model is established.The variation of T eq lags behind the variation of actual temperature T, it can be expressed as a linear equation, given by: where Teq(n) and T(n) respectively represent the corrected value and actual value of the temperature for the day n, T(n-i) represents the actual value of the temperature for the previous i-th day.Through (1), the impact of thermal inertia on building energy consumption can be characterized by Teq, thereby providing a more accurate reflection of the relationship between temperature and energy consumption.
In (1), the selection of parameters a0-a4 is crucial.The guiding principle for selecting parameters a0-a4 is to maximize the correlation between T eq and energy consumption E, which can be formulated as the following optimization problem: where Cor(E, Teq) represents the Pearson correlation coefficient, which is formulated as: The lager value of Cor(E, Teq) comes with the closer linear relationship between T eq and E. By solving the optimization problem of ( 1)-( 3), the values of a0-a4 are obtained.However, it can be seen from ( 3) that Cor(E, Teq) is a complex nonlinear function related to T eq and E, which is challenging to solve utilizing conventional convex optimization methods.So genetic algorithm (GA) is introduced to solve the aforementioned problem.GA is a randomized search method based on the principles of biological evolution (Almalaq et al. 2019), known for its simplicity and strong scalability.It involves the following five main steps to solve the optimization described by ( 1 Through this process, values of a0-a4 are obtained, and the expression for thermal inertia model (Equation ( 1)) can be derived subsequently.

Bayesian Energy Consumption Prediction Model
Upon the establishment of thermal inertia model, the building energy consumption prediction model can be further constructed.The overall structure is illustrated in Fig. 2. X denotes the input of the model, including various factors affecting the energy consumption.According to the previous subsection, the influential factors affecting building energy consumption include historical energy consumption, temperature and date-type.Therefore, X consists of energy consumption of the previous day E(n-1), equivalent temperature of the previous day Teq(n-1), equivalent temperature of the current day Teq(n), date type of the previous day W(n-1), date type of the current day W(n).Y denotes the output of the model, which is the energy consumption of the current day E(n).According to the overall Structure of the predictive model in Fig.Given N sets of independent learning samples X={E(n-1), Teq(n-1), Teq(n), W(n-1), W(n)}, Y=E(n), Bayesian linear regression employs the following multivariate linear regression model: where ω and ε represent weight coefficients and residuals, respectively.
According to the definition of linear model, ω and X are mutually independent, and are also independent of ε.It can be derived from Bayes' theorem (Wu et al. 2010) (Mathankumar et al. 2021) that the posterior of weight coefficients in Bayesian linear regression can be demonstrated as: where p(Y|X,ω) is likelihood, p(ω) is the prior of weight coefficients, p(Y|X) is the marginal likelihood of Y.It can be observed that: The likelihood p(Y|X,ω) is fully determined by the linear regression model.Taking the example of modelling residuals as a 0-mean normal distribution, in this case, the likelihood also follows a normal distribution: The prior p(ω) is a continuous probability distribution, which is typically chosen as a 0-mean normal distribution: To obtain the Bayesian estimator of ω, which is essentially to obtain the posterior probability p(Y|X,ω), formulas ( 7) and ( 8) are substituted into (6), and the following formula can be derived: where: Therefore, N(μ,λ) denotes the required Bayesian estimator of ω.
Based upon the Bayesian estimator of ω, predictions can be made for the new test samples X*, as follows: ( ) where Y* denotes the required prediction results.

Case Study
The subsequent case study is based on energy consumption data from a commercial building in Nanjing, covering the period from June 1 st , 2021, to August 31 th , 2021, spanning a total of 92 days.The dataset comprises the daily electricity consumption of the building and the daily recorded maximum temperatures.Data from June 1 st to August 14 th is utilized for thermal inertia analysis and training the Bayesian regression model.Subsequently, data from August 15 th to August 31 th is used to evaluate the predictive performance of the Bayesian regression model.The following case study is organized as follows: In Subsection 3.1, the analysis of the effectiveness of the thermal inertia correction is conducted, followed by Subsection 3.2, which examines the effectiveness of energy consumption prediction of the proposed method.

Thermal Inertia Correction
Firstly, an analysis of the effectiveness of thermal inertia correction is conducted.Adopting the thermal inertia correction model depicted in (1), the values of a0-a4 in the thermal inertia model are optimized by GA, then the equivalent temperature can be calculated.
To validate the effect of thermal inertia correction, the analysis needs to be conducted to assess the correlation between equivalent temperature and electricity consumption, focusing on the following aspects: 1) Scatter plot analysis: The electricity-temperature scatter plots are plotted before and after the thermal inertia correction.The concentration of points after the correction is analyzed to verify the effectiveness of the correction.2) Kernel density estimation: Kernel density estimation is employed on the electricity-temperature scatter plots before and after correction.Through the aforementioned analyses, the effectiveness of the thermal inertia correction can be verified and its potential impact on subsequent energy consumption predictions can be assessed.

Electricity Consumption Prediction
Next, the prediction performances of Bayesian regression model are validated.The training data is selected from July 1 st to August 14 th , 2021, with the duration of 45 days, while the testing data is selected from August 14 th to August 31 st , totalling 17 days.For comparative analysis, the following 5 methods are taken into account: Among the aforementioned five methods, RBF-LTI and DBN-LTI, as opposed to RBF and DBN, incorporate thermal inertia correction.By comparing RBF and RBF-LTI, as well as DBN and DBN-LTI, the effectiveness of thermal inertia correction can be verified.Furthermore, RBF-LTI, DBN-LTI, and Bayes-LTI are three methods based on thermal inertia correction.Comparing these methods allows the verification of the accuracy of Bayesian regression in energy consumption prediction.
Apart from predictive accuracy, an analysis of the distribution prediction capabilities of Bayes regression is necessary.To demonstrate the predictive distribution capabilities, the predicted interval for building energy consumption using the Bayes-LTI method can be obtained at a fixed confidence level (such as 95% confidence), Then, this predicted interval can be compared with the actual energy consumption values to determine whether the majority of the actual energy consumption values are contained within this predicted interval, thereby the effectiveness of Bayesian regression's distribution prediction can be assessed.

Thermal Inertia Correction
Firstly, the results of thermal inertia correction are provided.The scatter plot of electricity-temperature before and after thermal inertia correction is shown in Fig. 3.The electricity-temperature kernel density estimation before and after thermal inertia correction is shown in Fig. 4. From Figure 3, it is evident that the scatter plot of uncorrected weekday electricity consumption against equivalent temperature is mostly within a range of approximately ±120MWh around the fitted curve.However, the scatter plot of corrected weekday electricity consumption against equivalent temperature is concentrated within a range of around ±80MWh around the fitted curve.This indicates that the scatter points of corrected electricity consumption against equivalent temperature are more tightly clustered around the fitted curve, demonstrating a noticeable increase in the correlation between temperature and daily electricity consumption.
Moreover, Figure 4 illustrates the kernel density estimate of electricity consumption against temperature, providing a more intuitive visualization of the changes in the correlation between temperature and electricity consumption before and after thermal inertia correction.In Figure 4, it's apparent that the range of the kernel density estimate of uncorrected electricitytemperature relationships spans approximately between 60MWh and 140MWh, whereas the kernel density estimate of corrected electricity-temperature relationships is more concentrated, ranging from 75MWh to 130MWh.The distribution is more focused and exhibits improved linearity after correction.
Hence, it is evident that, compared to actual temperature, the equivalent temperature shows a better correlation and linearity with building energy usage.This makes it more suitable for predicting energy consumption of the buildings.Furthermore, Fig. 5 presents the comparison of temperature probability distribution curves before and after thermal inertia correction.From Figure 5, it is evident that the probability distribution of temperatures before correction is approximately within the range of 24.5°C to 36.5°C, whereas the probability distribution of temperatures after correction is approximately within the range of 26.5 °C to 34 °C.After undergoing thermal inertia correction, the probability distribution of equivalent temperatures becomes more concentrated.Additionally, comparing the probability distribution of temperatures with a fitted normal distribution function, it is noticeable that the probability distribution of temperatures before correction differs significantly from a normal distribution, whereas the probability distribution of equivalent temperatures after correction is closer to a normal distribution.These characteristics make the corrected equivalent temperatures more advantageous for building and training predictive models.

Electricity Consumption Prediction
The building electricity consumption prediction outcome of RBF, DBN, RBF-LTI, DBN-LTI, and Bayes-LTI are depicted in Fig. 6,  Furthermore, Fig. 7 presents the building energy consumption prediction interval at 95% confidence level using Bayes-LTI method.It is clearly shown that the actual load curve resides within the 95% confidence interval predicted by Bayes-LTI for the majority of the time periods.Only on the 9th day (August 23 rd ), did the prediction exceed the 95% confidence interval, with a relative error of -11.1%.The days within the 95% confidence interval approximate about 94.1% of the total days, which closely aligns with the 95% confidence level.This underscores that the prediction method based on Bayesian regression are capable of forecasting the probability distribution of building energy consumption accurately, thereby providing crucial technical support for energy management strategies considering uncertainties.

Discussion
The case study results verify the superiority of both thermal inertia correction and Bayesian regression.The reason why the case study results outperform traditional methods is attributed to the inherent advantages of the thermal inertia correction and Bayesian regression methods themselves, which are discussed as follows: The reason why thermal inertia correction enhances load forecasting is due to its direct association with the actual attributes of building energy consumption.Owing to the insulation effects within buildings, the internal temperature lags behind external temperature changes.Devices such as air conditioning and water heaters, which control the temperature, are correlated with the internal temperature of the building.Consequently, the energy consumption of buildings also lags behind temperature changes.To model the thermal inertia, the traditional method is to establish the differential equation model of the internal temperature of the building (Chen et al. 2018), (Lu et al. 2022), or even the multi-particle differential equation model that includes the wall, floor, and air temperature (Dakir et al. 2020).However, due to the large number of parameters in the model, most of these methods remain in theoretical analysis, and are difficult to combine actual energy consumption data for prediction.In contrast, this paper innovatively calculates the equivalent temperature through thermal inertia correction based on GA, and only uses electricity consumption and temperature data to model the thermal inertia of buildings, avoiding the problem of facing too many parameters and difficulties in calculating the differential equation model (Chen et al. 2018), (Lu et al. 2022), (Dakir et al. 2020).Since it accurately reflects the thermal inertia of buildings, the proposed prediction method can achieve more accurate prediction results.
On the other hand, Bayesian regression model possesses unparalleled advantages in building energy predictions that cannot be equaled by other methods.Traditional power consumption prediction models regress on historical data points to calculate the output power consumption (Syed et al. 2021), (Xu et al. 2021), (Cai et al. 2019).Although such point-prediction models can consider the information of each data point, they have difficulty reflecting prior information such as the probability distribution of data points.Unlike traditional methods, the proposed prediction model is based on Bayes' theorem, combining prior information with historical data points, and introducing prior probabilities.By this way, Bayesian regression can consider the uncertainties more comprehensively than traditional methods, thereby predicting building energy consumption more accurately.Furthermore, Bayesian regression models not only provide point estimates but generate probability distributions of posterior estimates, allowing for probability distributions of predicted energy consumption.Such results empower decision-makers to gain a more comprehensive understanding of the potential range of building energy usage, thereby favoring the facilitation of energy management of the buildings.
Notwithstanding the advantages in terms of accuracy and probability distribution prediction, there is a drawback to the Bayesian regression prediction method, which is that it can only establish a Bayesian regression model based on the normal distribution function given by ( 7) and (8).Such drawback was also mentioned in reference (Löschenbrand et al. 2021).To address this limitation, reference (Löschenbrand et al. 2021) suggests that Bayesian regression models need to be established for different distribution characteristics such as Poisson distribution.However, an examination conducted within this study reveals that the outcomes derived from thermal inertia correction closely resemble a normal distribution.Consequently, the thermal inertia correction offers a potential solution to the necessity for Bayesian regression models to conform rigidly to a normal distribution.It can be seen that the combination of thermal inertia correction and Bayesian regression can effectively enhance the applicability of the Bayesian model, thereby achieving better prediction performance.

Conclusion
This paper proposes a building energy consumption prediction method based on thermal inertia correction and Bayesian regression.The method addresses the uncertainty of prediction samples and enhance the prediction accuracy through adopting a Bayes-based modelling method and elevating the correlation between temperature and energy consumption.From the case study analysis, the conclusions are drawn as follows: • The thermal inertia correction method for predicting building energy consumption significantly improves the correlation between temperature and energy consumption.Compared to methods not utilizing thermal inertia correction, employing this correction method yields more accurate predictions for building energy consumption.

•
The building energy consumption prediction model based on Bayesian regression achieves more accurate load forecasting results compared to RBF neural networks and Deep Belief Networks (DBN).Moreover, it can predict the distribution patterns of building energy consumption based on sample probability distribution.
Future work will focus on developing energy management strategies that take uncertainty into account based on the predicted probability distribution of building energy consumption.
-4940/© 2024.The Author(s).Published by CBIORE -4940/© 2024.The Author(s).Published by CBIORE )-(3) through GA (Luo et al. 2020).a) Randomly generate an initial population (a set of random values of a0-a4).b) Calculate the fitness of each individual in the population based on the objective function (Equation (2)).c) Apply the rule called "survival of the fittest", favoring individuals with higher fitness and eliminating those with lower fitness.d) Perform crossover and mutation operations to generate a new population.e) Repeat steps b to d until the termination criteria are met or the maximum iteration count is reached.
1) RBF: A prediction model established by Radial Basis Function (RBF) neural network (Tang et al. 2019) without employing thermal inertia correction.2) DBN: A prediction model built by Deep Belief Network (DBN) (Chang et al. 2020), (Phyo et al. 2021) without employing thermal inertia correction.3) RBF-LTI: A prediction model constructed by RBF neural network and incorporates thermal inertia correction.4) DBN-LTI: A predictive model built by DBN and incorporates thermal inertia correction.5) Bayes-LTI: The proposed method, which constructs a Bayesian regression prediction model and incorporates thermal inertia correction.The prediction model structure is illustrated in Section 2.

Fig. 3 Fig. 4
Fig. 3 Comparison of electricity-temperature scatter plot before and after thermal inertia correction

Fig. 7
Fig. 6 Comparison of prediction outcomes of different methods while Table 1 further lists the prediction outcome of