## 5 The Experiments
### Experimental Results  
To eliminate the influence of random error, the 10-fold cross-validation method was used. The parameters of the Chaos Bat Algorithm were selected empirically; the population size and the number of iteration are 25 and 100, respectively. The other important parameters of the methods used were all selected empirically and are shown in Table 2.  
The scores_function of sklearn. SelectKBest was used to obtain the scores of different features. The scores of features in the NSL-KDD, UNSW-NB15 and CICIDS2017 datasets are shown in Figure 3. The serial number of the features is in accordance with the abscissa, the ordinate score for the curve for result analysis. As can be seen in Figure 3, these features are ranked into a specified range: [0, 30,000], [0, 20,000] and [0, 20,000], respectively. The features with the highest scores are 39, 34 and 11 in the three datasets. In each dataset, almost half of the features have lower scores and some features with a 0 score also exist, especially in the CICIDS2017 dataset. \begin{table}
\begin{tabular}{c c c c} \hline \hline
**Methods** & **Parameters** \\ \hline Support Vector Machine & \(C=1\), kernel = ‘_rbf_’, gamma = ‘auto’ \\ K-Nearest Neighbors & n\_neighbors = 3 \\ Decision Tree & criterion = ‘gini’, random\_state = 0, max\_depth = 20, \\ \multicolumn{3}{c}{min\_samples\_leaf = 20,} \\ Chaos Bat Algorithm & \(A=0.5\), \(f_{min}=0\), \(f_{max}=2\), \(r\) is obtained by chaotic mapping \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Parameters for the base learners. \begin{table}
\begin{tabular}{c c c c} \hline \hline
**Dataset** & **Number of Features** & **Number of Types** & **Type of Attacks** \\ \hline NSL-KDD & 41 & 5 & Probe, DoS, U2R and R2L \\ UNSW-NB15 & 42 & 10 & Evnžer, Analysis, Backdoor, DOS, Exploit, Generic, Reconnaissance, Shellcode and Worm \\ CICIDS2017 & 77 & 7 & Pratator, web-attack, DoS, Infiltration, Bot and PortScan \\ \hline \hline \end{tabular}
\end{table} 
Table 1: A brief summary of the NSL-KDD, UNSW-NB15 and CICIDS2017 datasets. The proposed model is trained based on different numbers of features. After the training, the appropriate ensemble weights were obtained. Finally, different numbers of features (2, 3, 5, 10, 15, 20,... ) were fed into the proposed method, and the three classification accuracy curves were obtained, as shown in Figure 4. The orange curve, blue curve and green curve represent the test accuracy based on NSL-KDD, NUSW-NB15 and CICIDS2017 datasets, respectively. The change trends of the three accuracy curves are similar. As the number of selected features increases, the testing accuracy increases rapidly at the beginning, and finally shows a stable trend. It is observed that the maximum accuracy is achieved when the number of features is about 20, 19 and 25 in the three datasets. Figure 3: The score of each feature in the NSL-KDD, UNSW-NB15 and CICIDS2017 datasets. Suppose that the features of different datasets are represented by \(Fn\), and \(n\) means the serial number of the features, which starts from 1. The more relatively important features of different datasets based on chi-square filtering technology are shown in Table 3. The quantity of selected features is derived from Figure 4.  
Next, the hard-voting method was compared with the soft-voting model on the three datasets. The hard-voting model includes the majority voting and the weighted voting methods. The soft-voting includes the no weight, classifier-level weight and class-level weight methods. For the above five methods, the weight only exists in the weighted voting method, the classifier-level weight method and class-level weight method. The majority voting and the no weight methods do not use the weight. It is worth noting that the weights of the three weight voting methods mentioned above are all obtained by the Chaos Bat Algorithm (CBA) with the Opposition-Based Learning method. As shown in Section 4.2.1, the individual in the Bat Algorithm represents the weight.