# An Intelligent Ensemble-Based Detection of In-Vehicle Network Intrusion
## 5 Results and Discussion  
This research's main objective is to detect and classify intrusion detection attacks. DoS, fuzzing, spoofing, and replay attacks are four common CAN bus attacks that can pose a threat to the safety of a vehicle's driver, passengers, and pedestrians. We built a scheme that detects these common CAN bus attacks and classifies their type. We utilized supervised machine learning in combination with stacking, voting, and bagging ensemble methods for this purpose. Initially, we developed and evaluated three promising supervised learning techniques. After performing feature selection and data balancing, we utilized RF, DT, and XGBoost and fine-tuned these models. These models were selected due to their effective multithreading capabilities, and these tree structure algorithms provide minimal computational time. Furthermore, their ability to execute in parallel significantly decreases the time frame of model training while improving accuracy [67]. In terms of precision, recall, and F1-score, feature selection enhanced the performance of all models (RF, DT, and XGBoost). We obtained F1-scores higher than 0.979, precision scores higher than 0.980, and recall scores higher than 0.979. The XGBoost model with feature selection has the highest precision, recall, and F1-score, followed by the RF model with feature selection. Also, using feature selection with ensemble methods (stacking, bagging, and voting) improved the performance in terms of precision, recall, and F1-score. The stacking method has the highest performance with an F1-score of 0.993, precision of 0.993, and recall of 0.993. Voting has the second-highest performance with an F1-score of 0.981, precision of 0.982, and recall of 0.981. The bagging method has the lowest performance with an F1-score of 0.980 and precision and recall of 0.980. Figure 8 shows that applying feature selection to the RF, DT, XGBoost, stacking, bagging, and voting models increases their precision, recall, and F1-score performance. Cross-validation is a technique for determining the performance of machine learning models. Cross-validation can provide a more accurate estimate of model performance than a single train-test split by performing multiple iterations of training and testing on different subsets of the data [68]. In our proposed scheme, the dataset is divided using 10-fold cross-validation, where each fold is utilized once as test data and the remaining nine as training data. This process is repeated ten times to ensure robust evaluation by averaging the performance across all iterations. In this study, the accuracy of the models with feature selection is compared to that of the models without feature selection using 10-fold cross-validation. Without feature selection, stacking achieved the highest accuracy of 0.986. XGBoost and bagging achieved an accuracy of 0.982 and 0.976, respectively. The accuracy of the voting model is 0.975, while the accuracy of the RF and DT models is 0.973 and 0.971, respectively. The stacking method has the highest performance among all the models without feature selection. However, feature selection has improved the performance of most of the models. Stacking and DT have the same accuracy because both of them are already able to select significant features effectively. Both the XGBoost model  
recall, and F1-score. Stacking, XGBoost, and voting achieve the highest performance for the fuzzing attack, reaching a value of 1.00 for precision, recall, and F1-score. These results were achieved through the use of feature selection for detecting these attacks. These are followed by bagging, RF, and DT models with feature selection. The stacking model with feature selection has the highest performance for normal traffic, with precision, recall, and F1-score values of 1.00, 0.97, and 0.98, respectively. With precision, recall, and F1-scores of 1, 0.94, and 0.97, respectively, the XGBoost and RF models with feature selection have the second-highest performance.