# A Novel Intrusion Detection Approach Using Machine Learning Ensemble for IoT Environments
## 4 Experimental Results and Discussion
### Hyperparameter Optimization for the Random Forest Model
Figure 7: Scatter plot of best optimal model parameter with (a) ’border_count’: 1, (b) ’12_reg’: 4.8139, (c) ’nr_iterations’: 1900.0, (d) ’random_strength’: 5.0, and (e)’ tree_depth’: 10.0. The accuracy score of the gradient boosting machine model, with consideration of the precision and recall covered in Table 9, additionally Table 10 cover the range of misclassification attack of the model after using ensemble technique with random forest, and as visualized in Figure 9 with an average ratio of precision and recall, was 98.27%, and the computed confusion matrix over the true and predicted values is presented in Figure 10, which represents the number of true positives, true negatives, false positives, and false negatives. \begin{table}
\begin{tabular}{c c c c c} \hline  & **Misclassified** & **Total** & **Percent\_Misclassified** \\ \hline
**Infiltration** & 11,690 & 16,193 & 0.721917 \\
**SQL Injection** & 1 & 9 & 0.111111 \\
**Brute Force-XSS** & 1 & 23 & 0.043478 \\
**Brute Force-Web** & 2 & 61 & 0.032787 \\
**Benign** & 9784 & 1,348,471 & 0.007256 \\
**DoS-Slowloris Attacks** & 6 & 1099 & 0.00546 \\
**Bot** & 35 & 28,619 & 0.001223 \\
**DDoS-LOIC-HTTP Attacks** & 13 & 57,619 & 0.000226 \\ \hline \end{tabular}
\end{table} 
Table 10: Misclassification by attack category. \begin{table}
\begin{tabular}{c c c c} \hline
**Parameter Description** & **Parameter Identifier** & \begin{tabular}{c} **Hyperparameter Search** \\ **Space Training** \\ \end{tabular} & \
\begin{tabular}{c} **Hyperparameter Search** \\ **Space Result** \\ \end{tabular} \\ \hline Maximum number of trees & (nr\_iterations) & Uniform integer space in the interval of [100, 2000]. &
\begin{tabular}{c} A value in the interval of \\ [1600, 1900] seems to perform \\ best. \\ \end{tabular} \\ \hline Maximum depth of a tree & (depth) & Uniform integer space in the interval of [4, 10]. & The optimal value for the maximum dept of trees is 10 in all best performing cases. This suggests that another round of hyperparameter search with a higher value might yield a better result. \\ \hline L2 regularization coefficient & (l2\_leaf\_reg) & Uniform space in the interval of [1, 10]. & A value in the interval of [2, 6] yields good results. \\ \hline Number of splits for numerical features & (border\_count) & A choice of 128 and 254. & A border count of 254 was chosen for all the best models. \\ \hline Amount of randomness used for scoring splits & (random\_strength) & Uniform integer space in the interval of [0, 5]. & The optimal value seems to be in the interval of [3, 5]. \\ \hline \end{tabular}
\end{table} 
Table 8: Hyperparameter search space for gradient boosting machine. \begin{table}
\begin{tabular}{c c c c c} \hline  & **Precision** & **Recall** & **f1-Score** & **Support** \\ \hline
**0** & 0.991 & 0.993 & 0.992 & 1,348,471 \\
**1** & 0.964 & 0.957 & 0.961 & 274,823 \\ \hline
**Accuracy** & & & 0.987 & 1,623,294 \\
**Macro avg.** & 0.978 & 0.975 & 0.976 & 1,623,294 \\
**Weighted avg.** & 0.987 & 0.987 & 0.987 & 1,623,294 \\ \hline \end{tabular}
\end{table} 
Table 9: Classification report of model after applying ensemble technique with random forest. Figure 11 presents the average response times that were taken by the classifiers individually and with the ensemble technique as the proposed model for classifying a single instance. From the results, it can be observed that the ensemble technique through bagging with random forest and boosting with gradient boosting machine took the least time to classify the instances of the CSE-CIC-IDS2018-V2 dataset. Figure 10: Confusion matrix without normalization. Figure 9: Precision-recall curve with average precision/recall score \(\approx\) 98.27%. The comparison results are shown in Table 11. The proposed model outperformed the most recent functions of intuition detection trained with the CSE-CIC-IDS2018-V2 dataset, that is, random forest + gradient boosting machine, in terms of accuracy.