Use of Explainable Artificial Intelligence for Analyzing and Explaining Intrusion Detection Systems
Abstract
:1. Introduction
2. Explainability and Interpretability Methods and Datasets
2.1. LIME: Local Interpretable Model-Agnostic Explanations
- g represents the interpretable model.
- L measures the closeness between g and the original model’s prediction f.
- defines the proximity between the generated samples and the instance x.
- controls the complexity of g.
2.2. SHAP: SHapley Additive Explanations
- 1.
- Local Accuracy:The contributions of all features must sum to the difference between the prediction for x and the average prediction:
- 2.
- Missingness: Features not present in the coalition () receive an attribution value of zero:Conversely, features included in the explanation () are assigned their respective Shapley values.
- 3.
- Consistency: If a model changes such that the marginal contribution of a feature increases or remains the same (regardless of other features), the Shapley value for that feature must also increase or remain unchanged. Formally, for any models f and , and ,
2.3. Dataset: UNSW-NB15
2.4. Model Training
- Nominal Identifiers and High-Cardinality Categoricals: Features such as srcip (source), dstip (destination IP addresses), sport, dsport (port numbers), proto (protocol type, such as TCP or UDP), state (state and protocol indicator, such as ACC or CLON), and service (e.g., HTTP, FTP, SSH, DNS) were excluded. These features often act as unique identifiers or have very high cardinality, making them challenging for direct model input without specific encoding strategies (like hashing or embedding) that could potentially obscure interpretability or lead to overfitting. The attack_cat feature was also excluded as it represents the specific attack category name derived from the target label itself.
- Temporal Features: stime and ltime (start and end timestamps) were omitted as raw timestamps are typically not directly suitable for non-sequential models like the ones used here and could introduce data leakage if not handled carefully.
2.4.1. XGBoost
Algorithm 1 XGBoost classifier configuration |
xgb_model = xgb.XGBClassifier( n_estimators=100, learning_rate=0.1, early_stopping_rounds=10, max_depth=6, min_child_weight=1, subsample=0.8, colsample_bytree=0.8, objective=’binary:logistic’, random_state=42, use_label_encoder=False, eval_metric=’logloss’ ) |
2.4.2. TabNet
Algorithm 2 TabNet classifier configuration |
tabnet_model = TabNetClassifier( n_d=8, n_a=8, n_steps=3, gamma=1.3, lambda_sparse=1e-4, cat_emb_dim=1, cat_idxs=[], optimizer_fn=torch.optim.Adam, optimizer_params=dict(lr=2e-2), scheduler_fn=torch.optim.lr_scheduler.StepLR, scheduler_params=dict( step_size=10, gamma=0.1 ), device_name=str(device) ) |
3. Results
3.1. XGBoost
- The base value (labeled on the plot) represents the average prediction score across the dataset—the starting point before considering this instance’s specific features.
- Features act as forces pushing the prediction: features shown in red increase the score (pushing towards the Attack class, typically 1), while features shown in blue decrease the score (pushing towards the “Normal” class, typically 0).
- The width of each feature’s block is proportional to the magnitude of its impact (its SHAP value) on the prediction score; wider blocks have a larger influence.
- These forces accumulate from the base value to reach the final output value (). In this specific case for XGBoost, the combined effect of the blue forces (predominantly sttl) heavily outweighs the red forces. This indicates a high-confidence prediction by the XGBoost model that instance 15,482 is Normal.
- Blue bars represent contributions supporting the predicted class (Normal). Longer bars indicate stronger support.
- The direction (left for negative impact, right for positive) shows how the feature pushes the prediction relative to an average or baseline. Here, strong negative impacts push towards the Normal class (typically class 0).
- Features near the zero line had little impact on this specific prediction according to LIME’s local view.
3.2. TabNet
3.3. Comparative Analysis of SHAP and LIME Explanations
4. Discussion
4.1. Model Performance and Generalization
4.2. Global Interpretability: SHAP Summary Insights
4.3. Local Interpretability: Agreement and Divergence Between LIME and SHAP
4.4. Comparative Interpretability and Forensic Applicability
5. Conclusions
Author Contributions
Funding
Data Availability Statement
Acknowledgments
Conflicts of Interest
Abbreviations
NIDS | Network-based Intrusion Detection System |
AI | Artificial Intelligence |
ML | Machine Learning |
DL | Deep Learning |
XAI | EXplainable Artificial Intelligence |
LIME | Local Interpretable Model-Agnostic Explanations |
SHAP | SHapley Additive exPlanations |
References
- Fleck, A. Infographic: Cybercrime Expected To Skyrocket in Coming Years. 2024. Available online: https://www.statista.com/chart/28878/expected-cost-of-cybercrime-until-2027/ (accessed on 2 March 2025).
- Sharma, R. Emerging trends in cybercrime and their impact on digital security. Cybersecur. Rev. 2022, 15, 78–90. [Google Scholar]
- Stallings, W. Cyber Attacks and Countermeasures; Pearson: London, UK, 2023. [Google Scholar]
- National Institute of Standards and Technology. Digital Evidence; NIST: Gaithersburg, MD, USA, 2016. [Google Scholar]
- Casey, E. Digital forensics: Science and technology of the 21st century. J. Digit. Investig. 2018, 15, 1–10. [Google Scholar]
- Lin, J. Artificial Intelligence in digital forensics: Opportunities and challenges. Forensic Sci. Int. 2020, 310, 110235. [Google Scholar]
- Taylor, M. Machine learning for digital forensics: A systematic review. Digit. Investig. 2021, 38, 201–215. [Google Scholar]
- Maratsi, M.I.; Popov, O.; Alexopoulos, C.; Charalabidis, Y. Ethical and Legal Aspects of Digital Forensics Algorithms: The Case of Digital Evidence Acquisition. In Proceedings of the 15th International Conference on Theory and Practice of Electronic Governance, Guimarães, Portugal, 4–7 October 2022. [Google Scholar] [CrossRef]
- Association of Chief Police Officers (ACPO). Principles for digital evidence in criminal investigations. Digit. Crime J. 2021, 12, 45–50. [Google Scholar]
- Bathaee, Y. The Artificial Intelligence Black Box and the Failure of Intent and Causation. Harv. J. Law Technol. 2018, 31, 889. [Google Scholar]
- Defense Advanced Research Projects Agency (DARPA). Addressing the black-box problem in AI systems. AI Rev. 2023, 34, 12–20. [Google Scholar]
- Calderon, M. Legal challenges in using AI-generated evidence in courts. Leg. Stud. J. 2022, 29, 112–129. [Google Scholar]
- Adadi, A.; Berrada, M. AI explainability: Legal requirements and SHAP’s role in meeting them. AI Ethics 2021, 2, 215–231. [Google Scholar]
- IBM. What Is Explainable AI; IBM: Armonk, NY, USA, 2024; Available online: https://www.ibm.com/topics/explainable-ai (accessed on 6 November 2024).
- Carvalho, D.V.; Pereira, E.M.; Cardoso, J.S. Machine Learning Interpretability: A Survey on Methods and Metrics. Electronics 2019, 8, 832. [Google Scholar] [CrossRef]
- Adadi, A.; Berrada, M. Peeking inside the black-box: A survey on Explainable Artificial Intelligence (XAI). IEEE Access 2018, 6, 52138–52160. [Google Scholar] [CrossRef]
- Guidotti, R. The role of explainability in artificial intelligence research. AI Ethics 2019, 8, 1–15. [Google Scholar]
- Miller, T. Explanation in artificial intelligence: Insights from the social sciences. Artif. Intell. 2019, 267, 1–38. [Google Scholar] [CrossRef]
- Arrieta, A.B.; Díaz-Rodríguez, N.; Del Ser, J.; Bennetot, A.; Tabik, S.; Barbado, A.; García, S.; Gil-López, S.; Molina, D.; Benjamins, R.; et al. Explainable Artificial Intelligence (XAI): Concepts, taxonomies, opportunities and challenges toward responsible AI. Inf. Fusion 2020, 58, 82–115. [Google Scholar] [CrossRef]
- Doshi-Velez, F.; Kim, B. Towards A Rigorous Science of Interpretable Machine Learning. arXiv 2017. [Google Scholar] [CrossRef]
- Molnar, C. Interpretable Machine Learning; Github: San Francisco, CA, USA, 2019. [Google Scholar]
- Mishra, R.; Singh, K. Scalable LIME: Enhancing interpretability for massive datasets. Big Data Cogn. Comput. 2023, 7, 99–120. [Google Scholar]
- Ribeiro, M.T.; Singh, S.; Guestrin, C. “Why Should I Trust You?”: Explaining the Predictions of Any Classifier. arXiv 2016. [Google Scholar] [CrossRef]
- Lundberg, S.M.; Lee, S.I. Explainable AI for tree-based models with SHAP and LIME: A comprehensive review. J. Mach. Learn. Res. 2020, 21, 210–245. [Google Scholar]
- Zhou, C.; Wang, L. Model-agnostic interpretability techniques: A survey on LIME and SHAP applications. Artif. Intell. Rev. 2022, 55, 2151–2180. [Google Scholar]
- Guidotti, R.; Monreale, A. Explainable AI: Interpretable models and beyond. Inf. Fusion 2021, 77, 4–19. [Google Scholar]
- Yang, H.; Patel, N. Interpretable machine learning: Advances in LIME for high-dimensional data. J. Comput. Intell. 2023, 39, 356–371. [Google Scholar]
- Kalai, E.; Samet, D. Monotonic Solutions to General Cooperative Games. Econometrica 1985, 53, 307. [Google Scholar] [CrossRef]
- Lundberg, S.; Lee, S.I. A Unified Approach to Interpreting Model Predictions. arXiv 2017. [Google Scholar] [CrossRef]
- Sundararajan, M.; Najmi, A. Many Shapley value methods: A unified perspective and comparison. Adv. Neural Inf. Process. Syst. 2020, 33, 18702–18714. [Google Scholar]
- Molnar, C. Interpretable Machine Learning: A Guide for Making Black Box Models Explainable; Leanpub: Victoria, BC, Canada, 2022. [Google Scholar]
- Zhang, W.; Li, R. SHAP explanations in financial AI: A review of applications and challenges. J. Financ. Data Sci. 2021, 3, 65–78. [Google Scholar]
- Chen, Y.; Zhao, L. AI explainability in healthcare: Integrating SHAP for enhanced trust and usability. Healthc. Anal. 2023, 5, 22–35. [Google Scholar]
- Yang, H.; Liu, M. SHAP compliance in regulatory AI systems: A case study. J. Artif. Intell. Regul. 2023, 12, 112–134. [Google Scholar]
- Moustafa, N.; Slay, J. The evaluation of Network Anomaly Detection Systems: Statistical analysis of the UNSW-NB15 data set and the comparison with the KDD99 data set. Inf. Secur. J. Glob. Perspect. 2016, 25, 18–31. [Google Scholar] [CrossRef]
- Moustafa, N.; Slay, J. UNSW-NB15: A comprehensive data set for network intrusion detection systems (UNSW-NB15 network data set). In Proceedings of the 2015 Military Communications and Information Systems Conference (MilCIS), Canberra, ACT, Australia, 10–12 November 2015. [Google Scholar] [CrossRef]
- Moustafa, N.; Creech, G.; Sitnikova, E. A new framework for evaluating cybersecurity solutions in smart cities. Future Gener. Comput. Syst. 2021, 123, 148–162. [Google Scholar]
- National Center for Biotechnology Information. Optimizing IoT Intrusion Detection Using Balanced Class Distribution. Sensors 2025, 24, 4293. [Google Scholar]
- Sharma, N.; Yadav, N.S.; Sharma, S. Classification of UNSW-NB15 dataset using Exploratory Data Analysis and Ensemble Learning. EAI Endorsed Trans. Ind. Netw. Intell. Syst. 2021, 8, e3. [Google Scholar] [CrossRef]
- Zoghi, Z.; Serpen, G. UNSW-NB15 Computer Security Dataset: Analysis through Visualization. arXiv 2021, arXiv:2101.05067. [Google Scholar] [CrossRef]
- Moustafa, N. UNSW-NB15 dataset: Modernized network traffic benchmark for intrusion detection systems. Comput. Secur. 2021, 104, 102195. [Google Scholar]
- Zaman, T.; Ahmed, S. Analyzing UNSW-NB15 for Intrusion Detection in Modern Networks. Cybersecur. Netw. 2023, 5, 210–225. [Google Scholar]
- Wang, F.; Zhao, M. Evaluation of machine learning models using data splits: A practical approach. J. Inf. Secur. Appl. 2022, 67, 103123. [Google Scholar]
- Elrawy, M. Benchmarking datasets and methods for cybersecurity applications: An overview. Cyber Threat Intell. Rev. 2021, 3, 58–72. [Google Scholar]
- Mohamed, A. Feature selection techniques for improving machine learning models in cybersecurity. Cybersecur. Strateg. 2022, 8, 88–101. [Google Scholar]
- Singh, R. Robust feature selection methods for modern ML systems: A comparative study. Adv. Comput. Res. 2023, 12, 44–63. [Google Scholar]
- Gupta, R.; Kumar, A. Machine learning approaches for anomaly detection in network security. Cybersecur. Adv. 2023, 4, 199–213. [Google Scholar]
- Husain, A.; Salem, A.; Jim, C.; Dimitoglou, G. Development of an Efficient Network Intrusion Detection Model Using Extreme Gradient Boosting (XGBoost) on the UNSW-NB15 Dataset. In Proceedings of the 2019 IEEE International Symposium on Signal Processing and Information Technology (ISSPIT), Ajman, United Arab Emirates, 10–12 December 2019. [Google Scholar] [CrossRef]
- Arik, S.O.; Pfister, T. TabNet: Attentive Interpretable Tabular Learning. arXiv 2019. [Google Scholar] [CrossRef]
- Lundberg, S.M.; Erion, G.; Chen, H.; DeGrave, A.; Prutkin, J.M.; Nair, B.; Katz, R.; Himmelfarb, J.; Bansal, N.; Lee, S.I. From local explanations to global understanding with explainable AI for trees. Nat. Mach. Intell. 2020, 2, 56–67. [Google Scholar] [CrossRef]
Aspect | LIME | SHAP |
---|---|---|
Definition | Local explanations using a simple model fitted to perturbed data. | Explanations based on Shapley values from game theory. |
Focus | Local explanations (single prediction). | Local and global explanations (individual and overall feature impact). |
Functioning | Perturbs instance features, predicts outcomes, and fits a simple model to interpret results. | Evaluates each feature’s contribution by combining it with others to calculate its fair impact. |
Accuracy | Less precise, as it depends on how data are perturbed and selected. | Very accurate and consistent due to the use of Shapley values. |
Output | Outputs feature importance but does not capture complex feature interactions. | Provides fair and equitable explanations of each feature, including both importance and interactions. |
Ideal Applications | Quick explanations for specific predictions. | Detailed explanations, global analyses, and applications requiring high transparency. |
Limitations | May be inconsistent and sensitive to perturbation techniques. | High computational cost and mathematical complexity. |
No. | Name | Description |
---|---|---|
Flow Features | ||
1 | srcip | Source IP address |
2 | sport | Source port number |
3 | dstip | Destination IP address |
4 | dsport | Destination port number |
5 | proto | Transaction protocol |
Basic Features | ||
6 | state | Indicates the state and its protocol dependency (e.g., ACC, CLO, and CON) |
7 | dur | Total duration of the record |
8 | sbytes | Bytes from source to destination |
9 | dbytes | Bytes from destination to source |
10 | sttl | Source-to-destination time-to-live |
11 | dttl | Destination-to-source time-to-live |
12 | sloss | Retransmitted or discarded packets from the source |
13 | dloss | Retransmitted or discarded packets from the destination |
14 | service | Services such as HTTP, FTP, SMTP, SSH, DNS, and FTP-data |
15 | sload | Bits per second from the source |
16 | dload | Bits per second from the destination |
17 | spkts | Number of packets from source to destination |
18 | dpkts | Number of packets from destination to source |
Content Features | ||
19 | swin | Source TCP window advertisement |
20 | dwin | Destination TCP window advertisement |
21 | stcpb | Source TCP sequence number |
22 | dtcpb | Destination TCP sequence number |
23 | smeansz | Average packet size transmitted by the source |
24 | dmeansz | Average packet size transmitted by the destination |
25 | trans_depth | Depth in the HTTP request/response transaction connection |
26 | red_bdy_len | Size of the content data transferred from the HTTP service server |
Time Features | ||
27 | sjit | Source jitter (ms) |
28 | djit | Destination jitter (ms) |
29 | stime | Start time record |
30 | ltime | End time record |
31 | sintpkt | Source inter-packet arrival time (ms) |
32 | dintpkt | Destination inter-packet arrival time (ms) |
33 | tcprtt | TCP connection setup round-trip time (sum of SYN-ACK and ACK-DAT) |
34 | synack | TCP connection setup time between SYN and SYN_ACK packets |
35 | ackdat | TCP connection setup time between SYN_ACK and ACK packets |
Additional Generated Features | ||
36 | is_sm_ips_ports | Assigned 1 if srcip equals dstip and sport equals dsport, otherwise 0 |
37 | ct_state_ttl | Number of each state based on specific sttl and dttl ranges |
38 | ct_flw_http_mthd | Number of flows with methods like GET and POST in HTTP service |
39 | is_ftp_login | Assigned 1 if FTP session accessed with user credentials, otherwise 0 |
40 | ct_ftp_cmd | Number of flows with an FTP session command |
41 | ct_srv_src | Records with the same service and srcip in 100 records based on ltime |
42 | ct_srv_dst | Records with the same service and dstip in 100 records based on ltime |
43 | ct_dst_ltm | Records with the same dstip in 100 records based on ltime |
44 | ct_src_ltm | Records with the same srcip in 100 records based on ltime |
45 | ct_src_dport_ltm | Records with the same srcip and dsport in 100 records based on ltime |
46 | ct_dst_sport_ltm | Records with the same dstip and sport in 100 records based on ltime |
47 | ct_dst_src_ltm | Records with the same srcip and dstip in 100 records based on ltime |
Traffic Type Features | ||
48 | attack_cat | Attack category names (e.g., Fuzzers, Analysis, DoS, etc.) |
49 | Label | 0 for normal traffic, 1 for attack records |
Processing Step | Technique Used | Description and Role in This Study |
---|---|---|
Categorical Encoding | Ordinal encoding, internal embeddings | Transforms categorical values (e.g., protocol, state) into numerical format. XGBoost uses ordinal encoding, while TabNet handles embeddings internally. |
Feature Scaling/Normalization | Min-Max Scaling | Normalizes continuous features to a common scale [0, 1], ensuring balanced contribution across attributes. |
Regularization/Early Stopping | Early stopping on validation loss | Prevents overfitting by halting training when no improvement is observed in validation performance. Applied in both XGBoost and TabNet. |
Feature Selection/Exclusion | Manual exclusion of identifiers | Non-informative or high-cardinality features (e.g., IP addresses, ports) were excluded to avoid overfitting and noise. |
Instance | Instance | Top-Five Feature | Jaccard |
---|---|---|---|
Type | ID | Overlap (Count) | Similarity Index |
Normal | N1 | 4 | 0.67 |
Normal | N2 | 3 | 0.50 |
Normal | N3 | 4 | 0.67 |
Attack | A1 | 5 | 1.00 |
Attack | A2 | 4 | 0.67 |
Attack | A3 | 3 | 0.50 |
Attack | A4 | 5 | 1.00 |
Attack | A5 | 4 | 0.67 |
Normal | N4 | 3 | 0.50 |
Normal | N5 | 4 | 0.67 |
Instance ID | Top-Five Features | Overlap Count | Jaccard Similarity (%) | Divergent Features | ||
---|---|---|---|---|---|---|
SHAP | LIME | SHAP | LIME | |||
Normal 1 | 3, 5, 6, 8, 13 | 3, 5, 6, 8, 9 | 4 | 80 | 13 | 9 |
Normal 2 | 8, 5, 6, 13, 19 | 8, 5, 6, 13, 22 | 4 | 80 | 19 | 22 |
Attack 1 | 6, 3, 5, 8, 14 | 6, 3, 5, 8, 19 | 4 | 80 | 14 | 19 |
Attack 2 | 3, 6, 5, 13, 14 | 3, 6, 5, 13, 9 | 4 | 80 | 14 | 9 |
Normal 3 | 5, 8, 13, 6, 19 | 5, 8, 13, 6, 19 | 5 | 100 | – | – |
Attack 3 | 6, 3, 5, 8, 14 | 6, 3, 5, 8, 14 | 5 | 100 | – | – |
Normal 4 | 5, 8, 3, 13, 6 | 5, 8, 3, 13, 19 | 4 | 80 | 6 | 19 |
Attack 4 | 3, 6, 8, 13, 19 | 3, 6, 8, 13, 14 | 4 | 80 | 19 | 14 |
Normal 5 | 8, 5, 13, 6, 19 | 8, 5, 13, 6, 19 | 5 | 100 | – | – |
Attack 5 | 3, 6, 5, 13, 19 | 3, 6, 5, 13, 14 | 4 | 80 | 19 | 14 |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2025 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Hermosilla, P.; Díaz, M.; Berríos, S.; Allende-Cid , H. Use of Explainable Artificial Intelligence for Analyzing and Explaining Intrusion Detection Systems. Computers 2025, 14, 160. https://doi.org/10.3390/computers14050160
Hermosilla P, Díaz M, Berríos S, Allende-Cid H. Use of Explainable Artificial Intelligence for Analyzing and Explaining Intrusion Detection Systems. Computers. 2025; 14(5):160. https://doi.org/10.3390/computers14050160
Chicago/Turabian StyleHermosilla, Pamela, Mauricio Díaz, Sebastián Berríos, and Héctor Allende-Cid . 2025. "Use of Explainable Artificial Intelligence for Analyzing and Explaining Intrusion Detection Systems" Computers 14, no. 5: 160. https://doi.org/10.3390/computers14050160
APA StyleHermosilla, P., Díaz, M., Berríos, S., & Allende-Cid , H. (2025). Use of Explainable Artificial Intelligence for Analyzing and Explaining Intrusion Detection Systems. Computers, 14(5), 160. https://doi.org/10.3390/computers14050160