This paper tempts to implement a new machine-learning algorithm for detecting attacks in WSN. The developed model involves three main phases (a) Data Acquisition, (b) Feature Extraction, and (c) Detection. Next to the data acquisition from different benchmark datasets, the attributes in the form of features are extracted. Further, a new hybrid machine learning algorithm with the integration of Neural Network (NN), and Fuzzy Classifier is used for detection, and it is termed as FNN. As an improvement to the developed hybrid model, the number of hidden neurons in NN, and the membership function of Fuzzy Classifier is optimized by a modified optimization algorithm called Opposition-based Deer Hunting Optimization Algorithm (O-DHOA). Finally, the experiment analysis of our proposed model provides an effective solution to solve the problem of IDS detection and improves the performance of intrusion detection.