# Optimizing Energy Forecasting Using ANN and RF Models for HVAC and Heating Predictions
## 2 Methodology  
### Data Collection  
This research used data collected from two prominent buildings in Spain, Lucia in Valladolid and FUHEM in Madrid, where historical energy use profile data from 2020 was used to extract a complete dataset of 8760 entries, one for every hour of the year. The detailed hourly data were vital in analyzing energy demand changes across the year, accommodating both the daily and seasonal differences. Extensive datasets were collected for the Lucia Building, as shown in Figure 1a; the dataset encompassed various factors, including weather parameters and structural geometric characteristics. Key weather variables--such as temperature, humidity, wind speed, and solar radiation--were critical for assessing how external conditions influenced energy consumption. Additionally, geometric data provided details on the buildings' physical attributes, such as surface area and volume, further supporting the analysis [35].  
As an additional step to evaluate our predictive models, we drew a random dataset of 100 data points from the FUHEM Building, as shown in Figure 1b, in Madrid. The FUHEM Building in particular was selected for this test because of its unique building typology and operational characteristics, which are different from the Lucia Building in Valladolid in both geographical and climate aspects. The differences in the climate of Madrid and Valladolid would also be relevant for identifying how geographical variation will influence energy demand.  
We feel that, by collating the extensive dataset of hourly recorded consumption (as well as monitored variables such as occupancy and outdoor temperature) with the limited dataset of the FUHEM Building, we are equipped to create forecasting models for energy demand. Models such as those provided by obtainable datasets are often good for developing an understanding of the general capabilities of the variables. While more data are always better for modeling, using these combinations of sources adds another type of 'generalized' dataset to make our forecasting models more relevant to differing building types and conditions.  
Using data from 2020 to train the models may limit the relevance of the findings, particularly because building usage patterns can evolve over time. While this dataset provides valuable insights into energy consumption trends and behaviors during that period, it is important to consider how shifts in occupancy, usage patterns, and external factors such as economic conditions and climate change can impact energy demand. Additionally, the challenges associated with collecting more recent data, such as resource availability and varying monitoring systems across different buildings, can complicate efforts to obtain up-to-date information. These factors highlight the need for a comprehensive approach to data collection that accommodates the dynamic nature of building energy usage.  
In Figure 2, the Energy Demand Prediction Workflow shows the steps in energy demand prediction in a structured way with the help of two machine learning models: ANN and Random Forest. First, the data are inputted to the software environment MATLAB; then, some preprocessing operations take place, which include data checking and normalization. Afterward, both models will be trained and tested using some performance evaluation metrics, namely RMSE, MAE, KGE, and Nash-Sutcliffe Efficiency, to compare the models. The models are then tested on their performance in terms of energy demand prediction to ensure a robust evaluation of their effectiveness.  
Figure 1: An architectural overview of the buildings: (**a**) LUCIA Building, (**b**) FUHEM Building.