# Optimizing Energy Forecasting Using ANN and RF Models for HVAC and Heating Predictions
## 2 Methodology
### Data Preprocessing  
Data preprocessing is a critical step in analyzing the seasonal data for the two buildings, LUCIA and FUHEM. In this instance, the preprocessing was conducted with a focus on maintaining the integrity of the dataset. No outliers were removed, as all values were considered essential for reflecting the true operational conditions of the buildings. This decision allows for a more accurate representation of the data, particularly in understanding any unique trends or patterns that may arise. Furthermore, the dataset was found to be complete, with no missing values. This completeness ensures that the analysis will not be skewed by gaps in the data, allowing for a thorough examination of seasonal variations in energy usage or occupancy. By retaining all original data points, the analysis can provide valuable insights into how each building's performance fluctuates throughout the seasons, ultimately supporting better decision making and resource management [36]. Table 2 shows the sample of the dataset in each zone. \begin{table}
\begin{tabular}{c c c c c c c c c c} \hline \hline \multirow{2}{*}{**Zone**} & \multirow{2}{*}{ \begin{tabular}{c} **Rated** \\ **Capacity** \\ **(kW)** \\ \end{tabular}  } & \multirow{2}{*}{ \begin{tabular}{c} **Rated** \\ **Flow** \\ **(m\({}^{2}\)/s)** \\ \end{tabular}  } & \multirow{2}{*}{ \begin{tabular}{c} **Total** \\ **Refrigera-** \\ **tion Load** \\ **(kW)** \\ \end{tabular}  } & \multirow{2}{*}{ \begin{tabular}{c} **Sensible** \\ **Load** \\ **(kW)** \\ \end{tabular}  } & \multirow{2}{*}{ \begin{tabular}{c} **Latent** \\ **Load** \\ **(kW)** \\ \end{tabular}  } & \multirow{2}{*}{ \begin{tabular}{c} **Air Temperature** \\ **(\({}^{\circ}\)C)** \\ \end{tabular}  } & \multirow{2}{*}{\ \begin{tabular}{c} **Humidity** \\ **(\%)** \\ \end{tabular}  } & \multirow{2}{*}{ \begin{tabular}{c} **Max. Operating** \\ **Refrigera-** \\ **Item** (\({}^{\circ}\)C)** \\ \end{tabular}  } \\ \hline Zone 1 & 5.95 & 0.407 & 5.17 & 4.8 & 0.37 & 24 & 51.2 & Jul 11:00 & 29.81 \\ Zone 3 & 11.13 & 0.896 & 9.68 & 9.68 & 0 & 23 & 49.7 & Aug 14:00 & 31.2 \\ Zone 10 & 8.2 & 0.57 &  
Data Normalizing  
Prior to analysis, the dataset was cleaned by removing outliers and correcting erroneous entries to prevent biased results. Missing values were addressed using interpolation techniques, ensuring data continuity and reliability, which are critical factors for accurate time-series forecasting. In addition to the primary dataset from the Lucia building, a randomized subset of data from the FUHEM Building in Madrid was incorporated. This secondary dataset was specifically curated to evaluate the robustness of our predictive model across varying conditions, including fluctuations in occupancy and weather patterns. By employing random sampling, we assessed the model's ability to generalize and perform under diverse scenarios, thereby strengthening the validity of our findings. Following data cleaning and preprocessing, feature engineering was conducted to improve predictive accuracy. New variables were introduced to capture temporal trends--such as time of day and day of the week--which are instrumental in understanding energy consumption patterns. The data were then normalized to ensure uniform feature scaling, facilitating the optimal training of our Artificial Neural Network and Random Forest models. These preprocessing steps laid the groundwork for developing a robust and generalizable predictive model capable of capturing energy demand dynamics across both buildings [37]. In this research, we used Artificial Neural Networks (ANNs) and Random Forests (RFs) because of their desirable characteristics in examining the LUCIA and FUHEM datasets. The LUCIA dataset included 8760 hourly data points for near-zero-energy buildings (nZEB), so it includes a significant amount of data that have complex nonlinear associations.