## 3 The Proposed SP-IoUAV Model
### Intrusion Detection System (IDS)
#### 3.3.2 Intrusion Detection Engine  
The intrusion detection engine is a critical component within the proposed model responsible for efficiently identifying potential security threats and abnormal activities within the UAV network. It plays a key role in analyzing the collected and preprocessed data to detect any suspicious patterns or behaviors that may indicate intrusion attempts or anomalous activities. The intrusion detection engine is composed of two main stages: data preprocessing and anomaly detection and classification. * **Data Preprocessing:** Before feeding the data into the anomaly detection and classification stage, the data preprocessing stage performs essential tasks to ensure the data are in a suitable format for analysis. Data normalization, feature extraction, and data transformation are all part of this stage. * **Data normalization:** Data normalization is an important step in data preprocessing that ensures all features are of equal importance and scale. Normalization techniques vary, but one popular technique is min-max scaling. The data are scaled to a fixed range, typically between 0 and 1, using the following formula:\[X_{\text{normalized}}=\frac{X-X_{\text{min}}}{X_{\text{max}}-X_{\text{min}}} \tag{9}\]  
where \(X\) represents the original data, \(X_{\text{min}}\) represents the dataset's minimum value, and \(X_{\text{max}}\) represents the dataset's maximum value. * **Feature extraction:** Feature extraction entails extracting the most relevant features from the collected data. Principal component analysis (PCA) is a common feature extraction technique. PCA converts the data into a new coordinate system in which the new features, known as principal components, are orthogonal to each other and capture the most variance in the data. In this step, we will need to calculate the covariance matrix C, which can be calculated as follows:  
\[C=\frac{1}{n-1}\sum_{i=1}^{n}(x_{i}-\bar{x})(x_{i}-\bar{x})^{T} \tag{10}\]  
where \(n\) is the number of data points, \(x_{i}\) represents each data point, and \(\bar{x}\) is the mean vector of the data points. The term \((x_{i}-\bar{x})(x_{i}-\bar{x})^{T}\) represents the outer product of the centered data point with itself. We will also need to compute the eigenvectors and eigenvalues of C, as follows:  
\[C\cdot V=V\cdot\Lambda \tag{11}\]  
where \(C\) represents the covariance matrix of the dataset, \(V\) represents a matrix containing the eigenvectors, and \(\Lambda\) is a diagonal matrix containing the eigenvalues. After that, we have to compute the transformed data using the PCA equation. PCA is expressed as follows:  
\[X_{\text{transformed}}=X\cdot V \tag{12}\]  
where \(X\) represents the original data matrix and \(V\) is the eigenvector matrix derived from the data covariance matrix. * **Data transformation techniques:** These techniques such as t-distributed stochastic neighbor embedding (t-SNE) are used to further enhance the data representation, especially for visualization purposes. t-SNE is commonly used to reduce high-dimensional data to a lower-dimensional space while preserving the local structure of the data. Here, we compute the pairwise distances between data points in \(X_{\text{transformed}}\) as follows:  
\[d(x_{i},x_{j})=\sqrt{\sum_{k=1}^{n}(x_{ik}-x_{jk})^{2}} \tag{13}\]  
where \(d(x_{i},x_{j})\) represents the pairwise Euclidean distance between data points \(x_{i}\) and \(x_{j}\), \(n\) is the number of dimensions (features) in the data, and \(x_{ik}\) and \(x_{jk}\) are the \(k\)-th features of data points \(x_{i}\) and \(x_{j}\), respectively.