# AE-DTI: An Efficient Darknet Traffic Identification Method Based on Autoencoder Improvement
## 3 AE-DTI Model Design
### AE-FS Feature Selection Algorithm Design
#### 3.1.2 AE-FS Algorithm Implementation Process  
Implementing the AE-FS algorithm includes two modules: feature global scoring and key feature extraction. To facilitate the explanation of the implementation process of AE-FS, suppose there is a two-dimensional grayscale dataset \(Q=\{X_{1},X_{2},\ldots,X_{i},\ldots,X_{k}\},i\in[1,k]\), where \(k\) represents the sample of the dataset quantity, \(X_{i}\) represents the two-dimensional grayscale image in the dataset., and each \(X_{i}\) has \(m\) pixels (that is, \(m\) features). Figure 3: AE-FS network structure. Feature Global Scoring  
The feature global score mainly includes three steps: initial reconstruction error calculation, ablation error calculation, and feature score calculation, which are described in detail as follows. Step 1: Initial reconstruction error calculation. The \(X_{i}=\left\{x_{1},x_{2},\ldots,x_{j},\ldots,x_{m}\right\}\), \(j\in[1,m]\) in the dataset \(Q\) is sequentially input into the autoencoder for training, and the decoder outputs \(X_{i}\)\(=\left\{x_{1}^{\prime},x_{2}^{\prime},\ldots,x_{j}^{\prime},\ldots,x_{m}^{ \prime}\right\}\), \(j\in[1,m]\). Use the mean square error to calculate the reconstruction error of each \(X_{i}\) and \(X_{i}^{\prime}\) in turn, accumulate and take the average to obtain the reconstruction error \(L(Q)\) of the dataset \(Q\), referred to as \(L\), as shown in Formula (1). \[L(Q)=\frac{1}{k}\sum_{i=1}^{k}\frac{1}{m}\sum_{j=1}^{m}\left(x_{j}-x_{j}^{ \prime}\right)^{2} \tag{1}\]  
Step 2: Ablation error calculation. The \(m\) features in the dataset \(Q\) are sequentially removed to obtain a new dataset \(Q_{j}=\left\{X_{1}^{j},X_{2}^{j},\ldots,X_{i}^{j},\ldots,X_{k}^{j}\right\}\), \(i\in[1,k]\), \(j\in[1,m]\). \(Q_{j}\) means removal from the dataset of the \(j\)th feature, \(X_{i}^{j}\) represents the grayscale image of the jth feature removed from the dataset. Input \(X_{i}^{j}\) in \(Q_{j}\) to the autoencoder in turn for training, and the decoder outputs \(X_{i}^{j\prime}\). Additionally, use Formula (1) to calculate the reconstruction error of each \(X_{i}^{j}\) and \(X_{i}^{j\prime}\) to obtain the reconstruction error \(L(Q_{j})\) of the dataset \(Q_{j}\), referred to as \(L_{j}\). Step 3: Feature score calculation. The significance of each feature is assessed by comparing the discrepancy \(\tau_{j}\) between the error values \(L\) and \(L_{j}\). A larger value of the difference degree \(\tau_{j}\) means that the feature is more essential, and the corresponding score is higher. To exclude the influence of negative values on the results, AE-FS uses the relative error to calculate the difference degree \(\tau_{j}\), which is calculated as in Formula (2). \[\tau_{j}=\frac{\left|L-L_{j}\right|}{\left|L\right|} \tag{2}\]  
To briefly illustrate the process of AE-FS's feature global scoring, a \(3*3\) (a total of 9 features) image dataset is used as an example to illustrate. First, the \(3*3\) image dataset is passed into the autoencoder for training, and the reconstruction error value calculated by AE-FS is 0.01. Then, AE-FS removes the 1 st, 2 nd, 3 rd, 4 th, \(\ldots\), 9 th features, respectively, to obtain 9 different datasets. Next, AE-FS inputs the 9 datasets into the self-encoder for training in sequence, and calculates the corresponding reconstruction error values: 0.04, 0.02, 0.03, 0.01, 0.05, 0.005, 0.012, 0.003, and 0.025. Finally, AE-FS calculates the difference degree (score) of the two reconstruction errors through the relative error (Formula (2)), and the obtained scores are: 3, 1, 2, 0, 4, 0.5, 0.2, 0.7, and 1.5. The specific data are shown in Table 1.  
\begin{table}
\begin{tabular}{c c c c} \hline
**FEA** & **OREV** & **ROREV** & **FSV** \\ \hline \(x_{1}\) & 0.01 & 0.04 & 3 \\ \(x_{2}\) & 0.01 & 0.02 & 1 \\ \(x_{3}\) & 0.01 & 0.03 & 2 \\ \(x_{4}\) & 0.01 & 0.01 & 0 \\ \(x_{5}\) & 0.01 & 0.05 & 4 \\ \(x_{6}\) & 0.01 & 0.005 & 0.5 \\ \(x_{7}\) & 0.01 & 0.