## 3 Case Study and Results
### Machine Learning  
Data with a period of 1 min are converted to 30 min by adding or averaging their values over the periods, due to differences in the monitoring period. Thus, as NaN values are allowed in the neural network, there are 17,956 values. In addition to the data presented above, the neural network also considers the hour of the day, day of the week and day of the year, with the final objective being to recognize the electrical consumption of the building (lighting and loads) from the rest of the variables. The configuration shown in Figure 4 has been obtained from the selection of the best configuration with root mean square error (RMSE), modeled in Python. I.e., the following hyperparameters are properly adjusted: number of layers, the number of nodes per layer, the type of activation function in each layer, the selection of a suitable learning rate, the optimizer, or the number of epochs and batches in the model. The testing was carried out for neuron values corresponding to the range 0-100 with step 25 and with the possibility of up to six hidden layers. All possible configurations of the activations shown in Figure 2 were also evaluated. \begin{table}
\begin{tabular}{c c c c c c} \hline \hline  & **Indoor** & **Ambient** & **Loads** & **Lighting** & **Outdoor** \\  & **Temperature** & **Illumination** & **Consumption** & **Consumption** & **Temperature** \\ \hline Errors (\%) & 1.56 & 1.56 & 0.15 & 0.15 & 0.66 \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Percentage of errors in the collection period of the variables considered. \begin{table}
\begin{tabular}{c c c c} \hline \hline  & **Peak Hours** & **Flat Hours** & **Valley Hours** \\ \hline Energy prices (\(\xi\)/kWh) & 0.2061 & 0.1128 & 0.0777 \\ \hline Power prices (\(\xi\)/kW-day) & 0.0875 & 0.0875 & 0.0073 \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Energy and power prices by period of the tariff considered. \begin{table}
\begin{tabular}{c c c c} \hline \hline
**Charging Power (W)** & **Discharging Power (W)** & **Capacity (Wh)** & **Efficiency (\%)** \\ \hline
2500 & 2500 & 2500 & 95 \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Battery characteristics considered. The methodology used consisted of a batch learning of 64 units in each epoch, with a maximum of 500. The proposed model was carried out with a 90% Train/Dev and 10% test sample partition, i.e., 90% modelling and 10% predicting, and a 10 division k-fold method. The mean error for the different divisions of the sample and the global sample is shown in Table 4.  
As can be seen in Table 4, the errors of the SNN model with k-fold reduced. On the one hand, the mean modeling errors are 5.44% for the training set, and 5.59% for the validation set (Dev). On the other hand, the mean errors of the prediction set (Test) are 5.28%. In this way, it has been possible to obtain a model that can model and predict the data with mean errors of 5.47%. The fitting of the electricity demand of this SNN model with k-fold presented with respect to the real data is shown in Figure 5. \begin{table}
\begin{tabular}{c c c c c} \hline  & **Train** & **Dev** & **Test** & **Full Sample** \\ \hline RMSE (\%) & 5.44 & 5.59 & 5.28 & 5.47 \\ \hline \end{tabular}
\end{table} 
Table 4: Mean values of the RMSE in the different divisions of the sample. Figure 4: Best configuration of the SNN model in the office building tested. Figure 5: Comparison between the predicted electrical consumption with the SNN k-fold model and the actual consumption in a working day in the selected zone of the building. (**a**) Train/Dev sample division; (**b**) Test sample division. As can be seen in Figure 5, the SNN k-fold results were accurate. The model adjusted to the variations in electrical consumption that occur through the day in the building, both in the Train/Dev and Test partitions. Therefore, it can be determined that the model is capable of modeling and predicting electricity consumption in the selected office building.