# A Robust Machine Learning Model for Detecting XSS Attacks on IoT over 5G Networks
## 4 Results and Discussion  
This section provides an in-depth analysis of the effectiveness of the proposed ML model for detecting XSS attacks in IoT environments operating over 5G networks. The evaluation focuses on two datasets, NF-ToN-IoT-v2 and Edge-IIoTset, and employs two feature selection methods (filter and wrapper) along with three widely used classification algorithms: Naive Bayes, Random Forest, and Decision Tree. Key performance metrics, including accuracy, precision, recall, and F1-score, are used to assess the performance of the models under different configurations. The results highlight the impact of feature selection methods on the classification performance and provide a comparative analysis across datasets and algorithms, illustrating the robustness and adaptability of the proposed approach. Table 2 comprehensively evaluates the proposed model's performance on two datasets NF-ToN-IoT-v2 and Edge-IIoTset using filter and wrapper feature selection methods combined with three machine learning classifiers: Naive Bayes, Random Forest, and Decision Tree. The results highlight the exceptional performance, robustness, and adaptability of the proposed model, especially when leveraging the wrapper method, achieving near-optimal detection metrics across all classifiers and datasets. The wrapper method demonstrates its superiority in dynamically optimizing feature subsets to maximize classification performance. For instance, Random Forest achieves an exceptional accuracy of 99.8%, precision of 0.997, recall of 0.999, and F1-score of 0.998 on both datasets, underscoring its capability to handle complex feature interactions effectively. Decision Tree, another high-performing classifier, achieves a 99.8% accuracy, precision of 0.996, recall of 1.000, and F1-score of 0.998 on the NF-ToN-IoT-v2 dataset, demonstrating its unparalleled ability to capture all instances of XSS attacks without false negatives. In comparison, Naive Bayes, while slightly trailing in performance, still achieves impressive metrics with an accuracy of 98.1%, precision of 0.945, recall of 0.995, and F1-score of 0.969 on the NF-ToN-IoT-v2 dataset under the wrapper method. \begin{table}
\begin{tabular}{l c c c c c c c c} \hline \hline \multirow{2}{*}{**ML Algorithm**} & \multicolumn{4}{c}{**Edge-IIoTset Dataset**} & \multicolumn{4}{c}{**NF-ToN-IoT-v2 Dataset**} \\ \cline{2-9}  & **Accuracy** & **Precision** & **Recall** & **F1-Score** & **Accuracy** & **Precision** & **Recall** & **F1-Score** \\ \hline \multicolumn{9}{c}{**Filter Method**} \\ \hline Naive Bayes & 0.945 & 0.910 & 0.975 & 0.941 & 0.952 & 0.860 & 0.998 & 0.924 \\ Random Forest & 0.996 & 0.994 & 0.997 & 0.995 & 0.997 & 0.993 & 0.997 & 0.995 \\ Decision Tree & 0.997 & 0.995 & 0.997 & 0.996 & 0.998 & 0.996 & 0.998 & 0.997 \\ \hline \multicolumn{9}{c}{**Wrapper Method**} \\ \hline Naive Bayes & 0.955 & 0.925 & 0.982 & 0.952 & 0.981 & 0.945 & 0.995 & 0.969 \\ Random Forest & 0.998 & 0.997 & 0.999 & 0.998 & 0.997 & 0.999 & 0.998 \\ Decision Tree & 0.998 & 0.996 & 0.998 & 0.997 & 0.998 & 0.996 & 1.000 & 0.998 \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Classification Results Using Filter and Wrapper Feature Selection Methods for NF-ToN-IoT-v2 and Edge-IIoTset Datasets. By contrast, the filter method, while computationally efficient, shows a slight decline in performance, particularly in precision and F1-score. For instance, the Decision Tree classifier achieves a strong accuracy of 99.7%, precision of 0.995, recall of 0.997, and F1-score of 0.996 on the Edge-IIoTset dataset using the filter method, but these results are consistently surpassed by the wrapper approach. Similarly, Naive Bayes achieves a filter-based accuracy of 94.5%, precision of 0.910, recall of 0.975, and F1-score of 0.941 on the Edge-IIoTset dataset, reflecting its limitations in capturing nuanced feature interactions compared to the wrapper method. The novelty of the proposed approach is reflected in its consistent performance across datasets with varying scales and complexities.