## 6 Comparison between Isolation Forest and Variational Autoencoder Algorithms
### Results of the Tests Performed with the Isolation Forest  
The Sklearn library (version 1.1.1) [63] was used to perform the computational tests of the IF algorithm. In terms of algorithm settings, a grid search was performed on the hyperparameters \(\texttt{contamination}\in\{0.008,0.01,0.03,0.05,0.1\}\), \(\texttt{bootstrap}\in\{True,False\}\), and \(\texttt{max\_samples}\in\{\texttt{'}auto^{\prime},0.05,0.1,0.3,0.5\}\). For the remaining hyperparameters (see the IF class documentation [[https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.IsolationForest.html](https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.IsolationForest.html)]([https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.IsolationForest.html](https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.IsolationForest.html)), accessed on 27 May 2022 ), the default values of the library were considered. The best results obtained by the IF algorithm are summarized in Table 5. From the results, it can be concluded that, according to the metrics defined before, the algorithm performed well in the detection of unknown points (\(S_{1}=0.99\)) for all meters, that is, the number of unidentified readings classified as anomalous remained within the tolerance range. The same happened also in early-stage anomaly detection (\(S_{2}\)). An exception was the anomaly \"\(S_{2}\) Anomaly 2\" in the \"Electricity 1\" meter, which could not be identified, penalizing its \(S_{final}\), reaching only 0.73 points on the scale.  
Analyzing the results, it appears that the model, in a real context, needs to have the parameters and input variables adjusted according to each meter. In terms of variables, it was found that three of the best results are associated with scenarios where hotel and environmental variables (as expressed in Table 5) were present. This indicates their relevance and the fact that they should be considered whenever possible. When choosing the set of variables for the training base of the models, it was clear that the readings from meters, temporal variables, and \(min_{24h}\) seem to improve the performance of the algorithm. The results were unclear regarding the integration of the variables \(\Delta_{X}\) and \(\Delta\texttt{average}_{24h}\), particularly regarding whether they should be considered with the calculated difference or in the binary perspective of consumption increase/decrease. Therefore, in order to make a decision, a critical analysis of the situation was carried out and it was understood that a binary approach could bring some loss of sensitivity, specifically placing large and small variations in the same proportion. Regarding the hyperparameters, it is not possible to draw a clear conclusion, given the diversity of data types considered, so keeping pre-established parameters seems to be a viable solution. In the context of use, the parameter contamination must be adjusted according to the results by the system manager. It should also be noted that several of the simulations which were carried out took an average of about 30 s to complete, which is relatively fast considering the number of samples used. This proves that the IF algorithm requires little computational cost, confirming the results obtained for examples by [PERSON]  
\begin{table}
\begin{tabular}{c c c c} \hline \hline
**Scenario** & **Features** & **Temporal Variables** & **Hotel and Environment Variables** \\ \hline
1 & Reading, \(\Delta_{1h}\), \(\Delta_{2h}\), \(\Delta_{3h}\), \(\Delta_{24h}\), \(\Delta_{48h}\), \(\Delta_{72h}\), \(\min_{24h}\), & Hour, day of the week, month \\
2 & Reading, \(\Delta_{1h}^{b}\), \(\Delta_{2h}^{b}\), \