## 5 Results
### Comparison of Anomaly Detection Models  
The first results are presented using the MAD statistical technique. This technique requires a limit to determine if an observation is anomalous. To address the decision of which limit to use for this case study, within each iterative process of the thirty total iterations, a different limit value was used. That is, instead of performing thirty iterations with one limit value \(x\) and reporting those results, the thirty iterations were performed for different limit values \(x\). To analyze the results (Figure 8a), the F1-score metric is examined. The metric shown in these results corresponds to the average of the metric over the 30 iterations using the corresponding threshold value. The best result was obtained using a cutoff value of \(1.1\). Similar to the analysis of the predictor model, analyzing the F1-score metric, which is the \begin{table}
\begin{tabular}{l c c c c c} \hline
**Regressor** & **Lags** & **n\_Estimators** & **MAPE** & **MAE** & **MSE** \\ \hline Random Forest & 25 & 100 & 0.17 & 1.43 & 4.63 \\ Random Forest & 25 & 300 & 0.17 & 1.43 & 4.61 \\ Random Forest & 25 & 200 & 0.18 & 1.43 & 4.64 \\ Random Forest & 25 & 50 & 0.18 & 1.44 & 4.68 \\ Random Forest & 25 & 20 & 0.18 & 1.45 & 4.64 \\ \hline \end{tabular}
\end{table} 
Table 10: Top 5 best predictive model results. Source: own elaboration. \begin{table}
\begin{tabular}{l c} \hline
**Metric** & **Result** \\ \hline MAE & 2.78 \\ MSE & 13.19 \\ MAPE & 21.04\% \\ \hline \end{tabular}
\end{table} 
Table 11: Best metrics for random forest regressor. Source: own elaboration. Figure 7: Comparison of real data and predicting data with best-performing regressor. Source: own elaboration. harmonic between _precision_ and _recall_, only provides some insight. In addition to this metric, the _accuracy_, _precision_, and _recall_ have been calculated as shown in Figure 8b. This is where the analysis of the different metrics becomes relevant. While the F1-score metric provides some understanding of the performance of a certain technique, it is necessary to know the other metrics to gain a complete understanding of the behavior of the technique. For the MAD technique, an increasing trend is observed in the _accuracy_, but a decreasing trend in the _recall_, while the _precision_ remains practically stable, slightly above 20%. The results obtained in the isolation forest technique are shown in Figure 8c. The best result has been obtained by training the model with 100 _n_estimators_. Unlike the previous technique, the performance of the technique varies in a range of 30% to 40% in the F1-score metric across the different values of _n_estimators_. Figure 8: Behavior of F1-score, accuracy, precision, and recall for anomaly-detection models: _MAD_, _IF_, and _LOF_. Source: own elaboration. Results for additional metrics are found in Figure 8d. Unlike the MAD technique, it can be seen how the _accuracy_ remains relatively high throughout the evaluations, exceeding 70%, and where the _precision_ and _recall_ metrics remain at ranges between 30% and 40%, obtaining the best combination of results in the use of one hundred estimators in the training period. In the LOF, the neighbor values or _neighbors_ were selected to be used in the _grid search_ and to find an ideal value that would result in higher performance. Figure 8e shows the results obtained from the F1-scores across the different neighbor values used during training. Using a range from 1 to 60 neighbors, the result is an increasing performance until reaching the number of ten neighbors. Once this number is increased, the F1-score metric decreases until it reaches a value of 20% when using 30 neighbors. The maximum _score_ obtained by using ten neighbors is slightly greater than 40%. To better understand the full picture of the performance of this technique, Figure 8f shows the results of metrics in addition to the F1-score.