## 3 Methodology
### Self-Attention Mechanism
\[\text{Recall}=\frac{\text{TP}}{\text{TP}+\text{FN}} \tag{10}\]

F1 Score: The F1 score is the harmonic mean of accuracy and recall, offering a unified measure that equilibrates both factors. It is particularly advantageous when managing unbalanced datasets or when both false positives and false negatives incur significant costs. \[\text{F1}-\text{Score}=2\times\frac{\text{Precision}\times\text{Recall}}{ \text{Precision}+\text{Recall}} \tag{11}\]

ROC-AUC Score: The receiver operating characteristic--area under the curve (ROC-AUC) score quantifies the model's aptitude to distinguish across classes, independent of classification thresholds. A perfect score is 1.0. \[\text{AUC}=\int_{0}^{1}\text{TPR}\Big{(}\text{FPR}^{-1}(\text{x})\Big{)}\text {dx} \tag{12}\]

Detection Time: Detection time refers to the duration required for the model to process and classify incoming data. This is crucial in real-time applications like intrusion detection. \[\text{Detection Time}=\text{t}_{\text{end}}-\text{t}_{\text{start}} \tag{13}\]

Delay: Delay is calculated as the complement of recall (1--recall), representing the fraction of actual intrusions not detected. \[\text{Delay}=1-\text{Accuracy} \tag{14}\]

### Baseline

To provide a comprehensive evaluation of the proposed intrusion detection system for WSNs, several baseline models are considered. These models span classical, hybrid, and deep learning approaches commonly used in the field of network security. GWO-LSTM: The Grey Wolf Optimizer-based Long Short-Term Memory (GWO-LSTM) model combines evolutionary optimization with recurrent neural networks. GWO is used to optimize the LSTM's hyperparameters, enhancing its capability to model sequential data and detect DNN temporal patterns associated with intrusions. This integration allows the model to better adapt to dynamic attack behaviors in WSN environments [20]. DNN: A standard serves as a baseline for deep learning-based intrusion detection. Comparising multiple fully connected layers, the DNN is capable of learning complex feature representations from input data. However, it lacks temporal modeling or specialized optimization, making it a useful benchmark for evaluating the benefits of more advanced hybrid models [10]. COA-GS-IDNN: The Coyote Optimization Algorithm with Global Search-enhanced Deep Neural Network (COA-GS-IDNN) integrates metaheuristic optimization into the training of a deep neural model. COA facilitates effective exploration of the search space, while the global search component enhances convergence to optimal solutions. This model is designed to improve detection accuracy and generalization in complex intrusion scenarios [16]. AdaBoost-RBFSVM: This hybrid model combines AdaBoost, an ensemble learning technique, with a Support Vector Machine using a Radial Basis Function kernel (RBF-SVM). The ensemble approach strengthens classification by combining multiple weak learners, while the RBF kernel enables nonlinear decision boundaries. This method provides a classical machine learning baseline with strong generalization capabilities in non-sequential data settings [21]. ### Experimental Setting

The efficacy of the proposed deep learning model for intrusion detection in WSNs was assessed via tests carried out on a Victus HP laptop including an Intel Core CPU, 16 GB of RAM, and 1.5 TB of SSD storage, operating on a 64-bit OS. The model was executed using the Python programming language, employing TensorFlow and Keras as the principal deep learning frameworks. The studies used the WSN-DS dataset, a well-established benchmark for network intrusion detection, which was preprocessed utilizing methods like SMOTE, feature standardization, and one-hot encoding to achieve data balance and numerical stability. The proposed model was trained with the following key hyperparameters presented in Table 4.

The selection of hyperparameters in this study was guided by a combination of experimental tuning, architectural compatibility, and the resource limitations typical of WSNs.