## 6 Conclusions and Future Work  
This work presents an approach for tackling the increasingly pressing challenge of security in IoT systems relying on the MQTT server. With the rising popularity of IoT networks, this challenge needs to be addressed in an effective and adaptive way. The potential of an approach based on AI is explored for anomalous activity detection as well as attack-type detection. Due to the large feature space of MQTT transactions, a technique based on CNNs is applied to reduce the feature space and prevent important features from fading into feature noise. To improve detection, the outputs of the CNN reduction mechanism are combined with XGBoost for classification. However, due to the considerable reliance of classification performance on hyperparameter selections, metaheuristic algorithms are used to improve model performance through hyperparameter tuning. Additionally, a modified version of the relatively recently introduced RSA is introduced to overcome some of the limitations of the original approach. The proposed algorithm draws inspiration from the GA and is therefore dubbed the GIRSA. The introduced approach is assessed on a real-world dataset. The feature space is reduced using a CNN. This reduced feature space is used by the XGBoost algorithm to classify MQTT traffic. Two experiments are carried out, one handling simple anomalous detection, and the other identifying the specific type of attack. The introduced approach demonstrates potential. While struggling with simple binary classification, multi-class classification demonstrates decent potential with an accuracy rate of 87.94% of the best-performing model. The observed improvements have been meticulously statistically validated, and the best-performing model has been subjected to SHAP analysis in order to determine feature importance. The utilization of data-driven methods for detection and identification offers several advantages. Data-driven methods are capable of adapting to emerging threats without the need for explicit programming and administrator interaction. Furthermore, reduced maintenance can often offset the costs associated with initial development and integration. Reflecting on the validity of the proposed approach, it is essential to consider both internal and external validity aspects. Internally, the utilization of a CNN for feature space reduction and the subsequent integration with XGBoost for classification raises questions about the potential impact of hyperparameter choices on the model's performance. We addressed this concern through the application of metaheuristic algorithms for hyperparameter tuning, enhancing the robustness and reliability of our classification results. Externally, the generalizability of our findings is a crucial consideration. While our experiments were conducted on a real-world dataset, the specific characteristics of the dataset and the nature of MQTT transactions may limit the broader applicability of our approach to diverse IoT environments. Future work should include a broader range of datasets, ensuring that the effectiveness of our algorithm extends to various IoT scenarios. As with any study, some limitations exist with this work as well. Only a limited set of optimization algorithms is explored. Due to limited computational resources, smaller populations are used for optimizations and only a limited number of optimization iterations is conducted. In future works, we hope to expand population sizes and periods of optimization to attain a better understanding of the full capabilities of each algorithm. Future work will center on enhancing the proposed methodology by incorporating hybridization techniques and assessing alternative machine learning methodologies, including the exploration of deep CNNs and emerging versions of recurrent networks.