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
Machine Learning-Based Intrusion Detection
Projects · Project Beginner
Description
Build a classifier separating normal from attack traffic and compare algorithms.
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
- Train and compare three algorithms
- Read recall and FPR
- Interpret the errors
Requirements
- Python with scikit-learn, or the lab’s workbench.
Data
Synthetic to start; then CIC-IDS2017 or UNSW-NB15 after reading the licence.
Suggested datasets
Suggested algorithms
Implementation steps
- Generate data or load a licensed set
- Split temporally if possible
- Train three models
- Compare recall, FPR and PR-AUC
- Write the limits of the results
Code
# 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.linear_model import LogisticRegression
from sklearn.tree import DecisionTreeClassifier
X, y = make_classification(n_samples=3000, n_features=8, n_informative=5, weights=[0.8, 0.2], class_sep=1.0, random_state=rng)
Xtr, Xte, ytr, yte = train_test_split(X, y, test_size=0.3, stratify=y, random_state=rng)
for name, m in [("rf", RandomForestClassifier(random_state=rng)), ("lr", LogisticRegression(max_iter=500)), ("dt", DecisionTreeClassifier(max_depth=6, random_state=rng))]:
m.fit(Xtr, ytr); p = m.predict_proba(Xte)[:, 1]
print(name, "AUC=%.3f AP=%.3f" % (roc_auc_score(yte, p), average_precision_score(yte, p)))
print(classification_report(yte, p > 0.5, digits=3))
Expected results and how to read them
Expected results (qualitative, not achieved numbers): Differences between models appear and shift with seed and difficulty; never report a number without data and seed.
Challenges
- Class imbalance
- Leakage
- Threshold choice
Extensions
Try a licensed real dataset and compare with the synthetic result.
Related experiments
Related labs
References
- Sommer, Paxson (2010). Outside the Closed World: On Using Machine Learning for Network Intrusion Detection. IEEE Symposium on Security and Privacy 2010, pp. 305-316. doi:10.1109/sp.2010.25
- 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
- Sharafaldin, Lashkari, Ghorbani (2018). Toward Generating a New Intrusion Detection Dataset and Intrusion Traffic Characterization. Proc. ICISSP 2018, pp. 108-116. doi:10.5220/0006639801080116
