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
Network Anomaly Detection
Projects · Project Intermediate
Description
Apply unsupervised detectors to synthetic flows and measure quality.
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
- Compare Isolation Forest, LOF and z-score
- Analyse the effect of rarity
Requirements
- Python/scikit-learn or the workbench.
Data
Synthetic; then UNSW-NB15 or UGR'16 after checking terms.
Suggested datasets
Suggested algorithms
Implementation steps
- Generate normal data with a small anomaly share
- Run the detectors
- Compare ROC-AUC and PR-AUC at different rates
- Choose a threshold
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.ensemble import IsolationForest
from sklearn.neighbors import LocalOutlierFactor
norm = np.random.RandomState(rng).randn(1900, 4)
anom = np.random.RandomState(rng + 1).uniform(-6, 6, size=(100, 4))
X = np.vstack([norm, anom]); y = np.r_[np.zeros(1900), np.ones(100)]
s_if = -IsolationForest(random_state=rng).fit(X).score_samples(X)
s_lof = -LocalOutlierFactor(n_neighbors=20).fit(X).negative_outlier_factor_
for n, s in [("iforest", s_if), ("lof", s_lof)]:
print(n, "AUC=%.3f AP=%.3f" % (roc_auc_score(y, s), average_precision_score(y, s)))
Expected results and how to read them
Expected results (qualitative, not achieved numbers): PR-AUC falls faster than ROC-AUC under rarity.
Challenges
- Choosing contamination
- Non-Gaussian distributions
Extensions
Add a time series with seasonality.
Related experiments
Related labs
References
- Liu, Ting, Zhou (2008). Isolation Forest. IEEE ICDM 2008, pp. 413-422. doi:10.1109/icdm.2008.17
- Breunig, Kriegel, Ng, Sander (2000). LOF: identifying density-based local outliers. ACM SIGMOD 2000, pp. 93-104. doi:10.1145/342009.335388
- Chandola, Banerjee, Kumar (2009). Anomaly detection: A survey. ACM Computing Surveys 41(3), pp. 1-58. doi:10.1145/1541880.1541882
