# IoT Anomaly Detection to Strengthen Cybersecurity in the Critical Infrastructure of Smart Cities
## 3 Results
### Model Evaluation  
The evaluation results indicate that all anomaly detection models have strong performance in detecting anomalies in IoT data, as seen in Table 5. The results support the effectiveness of all models in detecting anomalies in IoT data. \begin{table}
\begin{tabular}{c c c} \hline
**Feature ID** & **Description** & **Explained Variance (\%)** \\ \hline Feature 1 & Daytime Consumption & 15.3 \\ Feature 2 & Weekly Trend & 12.4 \\ Feature 3 & Peak Frequency & 10.1 \\ Feature 4 & Daily Variability & 9.5 \\ Feature 5 & Seasonality & 7 \\ Feature 6 & Night Consumption & 6.4 \\ Feature 7 & Monthly Trend & 5.7 \\ Feature 8 & Average consumption & 4.9 \\ Feature 9 & Weekly Variability & 4.1 \\ Feature 10 & Night Frequency & 3.5 \\ Feature 11 & Monthly Variability & 2.8 \\ Feature 12 & Daily Trend & 2.2 \\ Feature 13 & Monthly consumption & 2 \\ Feature 14 & Weekly Seasonality & 1.9 \\ Feature 15 & Annual consumption & 1.7 \\ Feature 16 & Annual Variability & 1.4 \\ Feature 17 & Annual Trend & 1.2 \\ Feature 18 & Monthly Seasonality & 1.1 \\ Feature 19 & Weekly Consumption & 1 \\ Feature 20 & Annual Seasonality & 1 \\ \hline \end{tabular}
\end{table} 
Table 4: Feature descriptions and explained variance. * Isolation Forest: The model achieves an accuracy of 92%, meaning that 92% of anomaly detections are correct. The completeness is 88%, indicating that the model captures 88% of all anomalies in the data set. The F1-Score is 90%, suggesting a good balance between precision and completeness. The ROC Curve (AUC) is 0.94, demonstrating a high discrimination capacity. * RNN: This model shows even better performance, with 94% accuracy and 91% completeness. The F1-Score is 93%, indicating high overall performance. The ROC Curve (AUC) is 0.96, suggesting exceptional discrimination ability. * VAE Autoencoders: Although slightly lower in terms of accuracy (88%), this model still offers solid performance with a completeness of 84% and an F1-Score of 86%. The ROC Curve (AUC) is 0.92, indicating good discrimination capacity. * GANs: Achieves 90% accuracy and 86% completeness. The F1-Score is 88%, and the ROC Curve (AUC) reaches 0.93, reflecting good anomaly detection performance. * BERT: This model obtains an accuracy of 91% and a completeness of 89%. The F1-Score is 90%, and the ROC Curve (AUC) reaches 0.94, suggesting high discrimination power. Figure 4 presents the Precision-Recall curves for each anomaly detection model. Each of these curves illustrates how precision varies as a function of completeness as the decision threshold is adjusted. Precision represents the proportion of correct positive detections, while completeness measures the model's ability to identify all positive instances in the data set. By analyzing these curves, you gain a deeper understanding of the performance of each model in different configurations. For example, a model displaying a curve with high precision but relatively low completeness may be preferable when minimizing false positives is crucial. On the other hand, a model with an angle that balances precision and fullness may be appropriate in scenarios where both metrics are equally important. Visualizations are essential for making informed decisions about which model best suits a specific anomaly detection application. The proposed models perform strongly on critical metrics compared to other anomaly detection approaches. For example, the accuracy of our models ranges between 0.88 and 0.94, outperforming the accuracy of a statistics-based method, which has an accuracy of 0.85 on the same data set. Similarly, the completeness of our models ranges between 0.84 and 0.91, significantly outperforming the 0.78 totality of the SVM-based baseline approach. These results indicate that our models have a more remarkable ability to identify anomalies and typical urban data cases. A key advantage of our models is their ability to handle high-dimensional data, which is essential for analyzing complex urban data.