Over the past few years, there has been significant research on the Internet of Things (IOT), with a major challenge being network security and penetration. Security solutions require careful planning and vigilance to safeguard system security and privacy. Adjusting the weights of neural networks has been shown to improve detection accuracy to some extent. In attack detection, the primary goal is to enhance the precision of attack detection using machine learning techniques. The paper details a fresh approach for adjusting weights in the random neural network to recognize attacks. Reviews of the method under consideration indicate better performance than random neural network methods, Nearest Neighbor, and Support Vector Machine (SVM). Up to 99.49% accuracy has been achieved in attack detection, while the random neural network method has improved to 99.01%. The amalgamation of the most effective approaches in these experiments through a multi-learning model led to an accuracy improvement to 99.56%. The proposed model required less training time compared to the random neural network method.