%0 Journal Article %T Enhancing Cybersecurity in IoT & IIoT: A Machine Learning Approach for Anomaly Detection %A Mohamed Koroma %A Alhaji Mansaray %A Yahya Labay Kamara %A Chernor Gurasiue Jalloh %A Ibrahim Sorie Ojasy Bah %J Journal of Software Engineering and Applications %P 175-193 %@ 1945-3124 %D 2025 %I Scientific Research Publishing %R 10.4236/jsea.2025.186012 %X The rapid proliferation of the Internet of Things (IoT) and Industrial IoT (IIoT) has revolutionized industries through enhanced connectivity and automation. However, this expansion has introduced significant cybersecurity challenges, including vulnerabilities to Distributed Denial of Service (DDoS) attacks, malware, and unauthorized access. Traditional security measures like firewalls and encryption are often inadequate due to the dynamic and resource-constrained nature of IoT/IIoT networks. While Machine Learning (ML) has emerged as a promising solution for anomaly detection, challenges such as scalability, adversarial robustness, and energy efficiency remain unresolved. This study aims to address these gaps by developing an optimized ML-based framework for real-time anomaly detection in IoT/IIoT environments. The methodology integrates supervised (Random Forest), unsupervised (Isolation Forest), and deep learning (LSTM autoencoder) techniques, leveraging federated learning for edge deployment and adversarial training for robustness. Evaluated on benchmark datasets (TON-IoT, CICIDS2017, UNSW-NB15), the framework achieved a 96.2% F1-score, 14.5 ms latency, and 40.5% energy savings, outperforming traditional methods. Key findings demonstrate its effectiveness in balancing detection accuracy, computational efficiency, and explainability (SHAP values > 90% confidence). The study concludes that hybrid ML models significantly enhance IoT/IIoT cybersecurity, answering the research question affirmatively. Future directions include exploring quantum ML for efficiency and standardizing evaluation benchmarks. %K IoT Security %K Anomaly Detection %K Machine Learning %K Adversarial Robustness %K Edge Computing %U http://www.scirp.org/journal/PaperInformation.aspx?PaperID=143650