4.3. Model Performance Comparison
We evaluated all models on the holdout test set drawn from the three network traffic datasets (vDNS, vRouter_vFirewall, and vIDS) and reported mean predictive performance and computational efficiency across the 10 stratified folds. We present the predictive performance results obtained using the vDNS test set in
Table 1, while computational efficiency results for the same test set are presented in
Table 2.
All models achieved high predictive performance scores on the vDNS test set, with PR-AUC values over 0.997 demonstrating a strong ability to distinguish between benign and malicious patterns in virtual network traffic. Random Forest resulted in the highest precision score (0.998), closely followed by the stacked meta classifier (0.996). The highest recall and F1 scores were achieved by XGBoost (0.966 and 0.976, respectively), indicating its sensitivity in capturing malicious traffic while maintaining relatively high precision. The stacked model achieved the highest PR-AUC (0.999) and the second-best FPR (1.4%) after Random Forest, which produced the lowest FPR (0.6%). These results indicate the Random Forest and stacked models’ superiority in minimizing false security alarms in comparison to gradient boosting methods.
In terms of computational efficiency, XGBoost and CatBoost achieved the lowest inference times, resulting in 62 and 26 ms, respectively. While the stacked model resulted in the longest training time (93.785 s), the tuned XGBoost model took only 2.384 s to train. Regarding memory resources, the Random Forest model resulted in the highest memory consumption (557.813 MB). Meanwhile, we measured the largest serialized model size for the stacked model (7.812 MB), where multiple base models contributed to higher storage requirements.
Table 3 presents the predictive performance results collected using the vRouter_vFirewall test set, while computational efficiency results are presented in
Table 4.
According to the results displayed in
Table 3, the Random Forest model accomplished very high scores across multiple performance metrics: precision (0.999), recall (0.998), F1-score (0.999), and PR-AUC (0.999). The stacked model achieved a slightly lower FPR of 0.001 compared to Random Forest, but it also maintained equally high precision and PR-AUC. In this case, its score was 0.999 for both metrics.
Based on the results given in
Table 4, the training process for XGBoost completed in only 1.602 s. Meanwhile, the duration of this process was much higher for the stacked model, which completed its training in approximately 194.050 s. The CatBoost model consumed the least RAM (176.457 MB) and also generated its predictions in only 46 ms, as indicated by its inference time result. XGBoost was the lightest on disk space, as evident from its serialized model size of 0.720 MB. Meanwhile, the stacked model had the largest model size (4.537 MB) and would require approximately 6.3 times more space on the disk if we assume that its size would continue to grow at the same rate.
Table 5 presents the predictive performance results collected using the vIDS test set, while computational efficiency results are presented in
Table 6.
Based on the results in
Table 5, a slight reduction in precision, FPR and PR-AUC was detected for the stacked model compared to its performance on the previous dataset. However, when the model was applied on the new test set, its recall increased from 0.735 to 0.977, indicating that the model’s sensitivity was heightened to malicious traffic samples. Additionally, its F1-score increased from 0.847 to 0.945, suggesting that the model improved its ability to balance between precision and recall using a smaller test set. The CatBoost model demonstrated the highest recall and PR-AUC scores on the vIDS test data, resulting in respective values of 0.978 and 0.988.
Based on
Table 6, the CatBoost model attained the shortest inference time of only 10 ms, while XGBoost followed very closely behind at 12 ms. At the same time, Random Forest achieved the fastest training time (0.638 s), but it also consumed 411.856 MB of memory, which is significant for a single model trained on a relatively small dataset. Finally, the stacked model had the largest model size out of all the models, consuming 1.697 MB of storage resources.
Overall, Random Forest demonstrated the most consistent predictive performance across all three test sets. It achieved precision scores above 0.99 on vDNS and vRouter_vFirewall, shared the highest PR-AUC score (0.999) on vRouter_vFirewall with the stacking model, and produced the lowest FPR (0.006) on vDNS. Despite excellent predictive scores, Random Forest consumed the largest amount of RAM across all test sets (293.5–557.8 MB). Meanwhile, we found XGBoost and CatBoost to be more efficient alternatives for resource-restricted deployments, without a significant reduction in predictive power. While XGBoost demonstrated superior recall (0.966) and F1-score (0.976) on the vDNS test set, confirming its ability to capture malicious traffic and simultaneously reduce false alerts, CatBoost achieved the highest recall (0.978) and PR-AUC (0.988) on the vIDS test set. Both gradient boosting models had the shortest inference times (<0.14 s). Finally, the results emphasize the stacked model’s excellent discriminatory power, even in the presence of imbalanced classes. By combining multiple base classifiers, it produced highly accurate predictions across all decision thresholds, as evident by its consistently high PR-AUC (>0.98). Additionally, it maintained very low FPR (between 0.1% and 6%) and high precision scores (between 0.915 and 0.999) across all test sets. However, the stacked model resulted in the highest training times (up to 194 s) and the largest model sizes (up to 7.812 MB). In general, the results indicate a clear predictive performance and computational efficiency trade-off that requires detailed planning before deploying stacked meta models in resource-constrained NFV environments.
4.4. Model Explainability and Feature Attribution Analysis
This subsection demonstrates the application of an explainable AI technique called SHAP. Additionally, the subsection provides a feature attribution analysis, demonstrating the usage of SHAP visualization tools for plotting the impact of each network traffic feature on final model predictions. This helps us better interpret models’ decisions and detect any potential algorithmic biases. In the context of ML-based cyberattack detection, explainable ML models help security practitioners better understand the decisions generated by analytics engines, embedded in various security software products. For example, if the model raises a security alert, we want to understand the “why” behind the alert, especially which specific network traffic features strongly influenced its activation.
Firstly, we provide SHAP summary plots to demonstrate global feature importance for each of the three VNF datasets, as ranked by the Random Forest, XGBoost, and CatBoost models. Then, we provide SHAP dependence plots per model to illustrate how the exact values of each feature influence specific predictions. Dependence plots also allow us to analyze any feature interactions learned by the models and how these interactions influence the final predictions.
Figure 5 presents three SHAP summary plots for the Random Forest, XGBoost, and CatBoost models, which demonstrate the importance and influence of features from the vDNS dataset on cyberattack predictions. There is an observable consistency in feature importance across all three models, in which features that describe traffic volume per session receive high importance rankings, such as the number of raw and data bytes sent from the source. This indicates that the models primarily use traffic volume features as attack indicators. The calculated SHAP values quantify the impact of each feature on model predictions.
By observing the SHAP summary plot for the Random Forest model, the number of raw and data bytes transferred per network session creates a very wide distribution of SHAP values, indicating that these features strongly impact global predictions, although their contribution is not uniform across all network sessions. This occurs because tree splits in the Random Forest ensemble may use low byte values to predict attacks from one group of sessions, while using them for benign traffic predictions for another group. Whereas, high values for the TCP SYN and TCP Push (PSH) flags indicate a higher probability of attacks, as confirmed by positive SHAP values. Since many packets have TCP SYN and TCP PSH flags set, this suggests extreme spikes in connection attempts and data transfer events, often present in cyberattacks involving automated vulnerability scans, brute-force attacks, or exploit uploads to target hosts. Equivalently, the XGBoost model uses high TCP SYN values and traffic volume features, such as raw and data bytes sent by the source, to classify traffic. However, the distribution of raw source bytes differs slightly, with numerous low byte values pushing predictions toward the malicious class and indicating potential nonlinear interactions with other features. The CatBoost model demonstrates a similar ordering of feature attributions, with a relatively symmetric distribution of source data bytes, pushing TCP SYN, TCP PSH, and TCP SYN-ACK flags higher in importance ranking.
Figure 6 contains three SHAP dependence plots to demonstrate the prediction and interaction effects of the most important features in the vDNS dataset, presented across the Random Forest, XGBoost, and CatBoost models. The
x-axis presents feature values, while the corresponding SHAP values are provided on the
y-axis. Each plot also includes a feature that displays the strongest interaction with the plotted feature, as automatically selected by SHAP’s Explainer object. The exact values of the second feature that interact with the values of the plotted feature are color-coded based on a scale on the right side of the plot.
If we observe the Random Forest model, the dependence plot reveals that for many network sessions with fewer than 200 data bytes transferred by the source, interaction effects become strong when the number of TCP SYN packets in a session exceeds 0.5. This interaction largely dominates benign traffic predictions, as indicated by negative SHAP values between −0.2 and 0, although several occurrences of very low data byte counts (<100) primarily drive malicious traffic predictions. The dependence plot for the XGBoost model demonstrates a wider separation of feature values, where a lower number of raw bytes sent by the source is directly predictive of malicious traffic, yet there is a cluster of sessions with fewer than 250 bytes that predicts benign traffic. Low raw source byte values interacting with total data bytes clustered around 500 push predictions toward the malicious class, whereas sessions carrying more than 2000 raw bytes and more than 2500 total data bytes are mostly used to predict benign traffic. The dependence plot for the CatBoost model reveals that lower counts of source data bytes primarily drive benign traffic predictions, although several groups of sessions use these instances to predict malicious traffic, as shown by positive SHAP values (>2). In a few cases, higher values of both source data bytes and raw bytes increase SHAP values, thereby contributing to malicious traffic predictions.
Figure 7 presents three SHAP summary plots for the Random Forest, XGBoost, and CatBoost models, which demonstrate the importance and influence of features from the vRouter_vFirewall dataset on cyberattack predictions.
As shown in the figure, the Random Forest model relies on the lower range of raw source bytes with an irregular pattern of influence on malicious flow prediction. Different decision trees split different thresholds, leading to a wider distribution of feature influence that aligns with the previously observed distribution for the vDNS dataset, suggesting that this feature is context-sensitive and should be interpreted interactively with other features to understand the positive (attack) predictions. The summary plot for XGBoost exhibits a similar distribution for raw source bytes, but also relies on TCP PSH and TCP Reset (RST) flags to discriminate between benign and malicious flows. Higher frequencies of data uploads and connection resets, as indicated by red dots near the origin point, can suggest possible spoofing, probing, or command-and-control threats. The CatBoost model exhibits a similar distribution of raw source byte values to the previous models. However, there is the data bytes and bytes feature compact distribution, as well as interpretable influence based on the magnitude of byte values. Based on the plot, it is evident that CatBoost utilizes the total number of data and raw bytes transferred per session to discriminate between benign and malicious network flows, with values in the lower range primarily influencing attack predictions.
Figure 8 contains three SHAP dependence plots to demonstrate the prediction and interaction effects of the most important features in the vRouter_vFirewall dataset, presented across the Random Forest, XGBoost, and CatBoost models.
The dependence plot for the Random Forest model explains how the effect of source bytes on the predictions varied with TCP flag values, suggesting that the model generally produced positive (attack) predictions for a small group of sessions sending fewer than 500 raw bytes from the source, most of which contained TCP SYN-ACK values above 1.0. On the other hand, when the number of raw source bytes increased, SHAP values remained negative, indicating that a high traffic volume was generally not associated with cyberattacks. The dependence plot for XGBoost displays a similar cumulative effect of raw source bytes and TCP SYN-ACK values, where increasing SYN-ACK values form tight clusters at negative SHAP values even as raw source bytes increase. However, we can observe a few sessions with values at lower ranges for both features, which appear at positive SHAP values and increase the probability of malicious traffic detection. CatBoost, in contrast, strongly correlates raw source bytes with TCP PSH values, where extremely low values for both features spread across prediction boundaries. However, there is a distinct cluster of low-byte and low-PSH flows that pushes the predictions toward the malicious class.
Figure 9 presents three SHAP summary plots for the Random Forest, XGBoost, and CatBoost models, which demonstrate the importance and influence of features from the vIDS dataset on cyberattack predictions.
To accurately discriminate between benign and malicious flows, all three models mainly relied on protocol-related information, autonomous system numbers (ASNs) calculated from destination IP addresses, and the number of raw bytes transferred from source addresses. It is important to note that each protocol category and destination ASN was encoded using the mean target value, represented as probably malicious flow if it includes that specific category or ASN. The models notably associated high values for the encoded protocol categories with a greater likelihood of cyberattacks. The summary plots for XGBoost and CatBoost exhibit consistent patterns with Random Forest in terms of the two top-ranked features. However, there is slight variability in the distribution of raw source byte values across the three models. While the lower values, in general, tend to increase SHAP values and thereby help the models predict malicious traffic, several clusters of points are more aligned with benign traffic predictions.
Figure 10 contains SHAP dependence plots for demonstrating the prediction and interaction effects of the most important features in the vIDS dataset, presented across the Random Forest, XGBoost, and CatBoost models.
As shown in the figure, the plotted points form seven vertical clusters. This pattern is consistent across all models, where the clusters represent specific network protocol categories, which form strong interaction patterns with different destination ASNs. The patterns imply that some protocol combinations have a higher likelihood of belonging in malicious traffic flows, especially if specific destination ASNs accompany them. Based on the color and position on the Cartesian plane, each plotted point explains the magnitude and direction of the interaction between these features.
By performing a mapping between protocol categories and the probabilities of being used in malicious flows, we can interpret the dependence plots as follows:
The leftmost cluster of network sessions is associated with negative SHAP values, is centered around a protocol value of 0.0, and contains a mix of destination ASN types, as indicated by various point colors in the cluster. Based on these observations and the described mapping, we found that the following protocol combinations have an extremely low likelihood of being included in malicious traffic flows: (TCP, TLS), (DNS, UDP), (TCP, Hypertext Transfer Protocol (HTTP2), TLS), (Dynamic Host Configuration Protocol (DHCP), UDP), (UDP, DHCP), (Network Time Protocol (NTP), UDP), UDP, and (UDP, Quick UDP Internet Connections (QUIC)).
The topmost cluster of sessions is associated with positive SHAP values, is positioned in a protocol range of 0.8 to 1.0, and contains only a few high-risk destination ASNs in its packet headers. Therefore, we can identify the following protocol combinations as the most indicative of malicious traffic: (UDP, DNS), (UDP, NTP), and (TCP, DNS).
Overall, this analysis helped us identify the features that exert the strongest influence on attack predictions, as well as contributed to higher interpretability and explainability of the models included in the study.