Intrusion and anomaly detection, malware analysis, threat intelligence, phishing, security logs and incident response: defensive experiments that really compute in your browser on synthetic data, with algorithms, datasets, projects and quizzes.
- Home
- AI Intrusion Detection
- Cyber Anomaly Detection
- Malware Analysis
- Cyber Threat Intelligence
- AI Network Security
- AI Phishing Detection
- AI Security Log Analytics
- AI Incident Response
- Algorithm Library
- Datasets Repository
- Learning Roadmap
- Projects
- Quizzes and Challenges
- Experiment Workbench
- Research and Metrics
- My experiments
- Scientific references
- Glossary and FAQ
Explainable Intrusion Detection
Projects · Project Advanced
Description
Add an explanation layer (permutation importance and Shapley) to an IDS classifier.
The project uses synthetic data or licensed public datasets after checking their terms; it involves no attacks and no opening of malicious files or links.
Goals
- Global and local explanation
- Assess explanation stability
Requirements
- Python or the workbench.
Data
Synthetic or a licensed IDS set.
Suggested datasets
Suggested algorithms
Implementation steps
- Train RF
- Compute permutation importance
- Explain two alert samples
- Change the baseline and watch stability
Code
# Use the lab’s SHAP-style experiment (mal.explain) for an in-browser version; this sketch shows permutation importance only.
# Educational sketch on SYNTHETIC data (no download, no real traffic). Requires: numpy, scikit-learn
import numpy as np
from sklearn.model_selection import train_test_split
from sklearn.metrics import classification_report, roc_auc_score, average_precision_score
rng = 7
from sklearn.datasets import make_classification
from sklearn.ensemble import RandomForestClassifier
from sklearn.inspection import permutation_importance
X, y = make_classification(n_samples=2000, n_features=8, n_informative=4, weights=[0.8, 0.2], random_state=rng)
Xtr, Xte, ytr, yte = train_test_split(X, y, test_size=0.3, stratify=y, random_state=rng)
m = RandomForestClassifier(random_state=rng).fit(Xtr, ytr)
print(permutation_importance(m, Xte, yte, n_repeats=10, random_state=rng).importances_mean.round(3))
Expected results and how to read them
Expected results (qualitative, not achieved numbers): Importances will vary with baseline and model.
Challenges
- An explanation is not causality
Extensions
Test agreement between two explanation methods.
Related experiments
Related labs
References
- Arp, Quiring, Pendlebury, Warnecke, Pierazzi, Wressnegger, Cavallaro, Rieck (2024). Pitfalls in Machine Learning for Computer Security. Communications of the ACM 67(11), pp. 104-112. doi:10.1145/3643456
