ml-intrusion-detector
An end-to-end network intrusion detection pipeline, the kind a SOC uses to flag suspicious traffic. It combines an unsupervised detector for unknown attacks with a supervised one for known patterns, and shows why default settings silently lie about performance.
0.93F1 after tuning
0.97ROC-AUC
0.94F1 on UNSW-NB15
405knetwork flows
01. pipeline
raw flows ─► encode + scale ─┬─► Isolation Forest (unsupervised · unknown attacks)
└─► XGBoost (supervised · known patterns)
│
PR-curve threshold tuning ─► stacking ─► multi-class triage
(DoS · Probe · R2L · U2R)02. the silent failure
A model with 0.97 ROC-AUC can still miss a third of attacks at the default 0.5 threshold. Flip the switch.
03. binary results on NSL-KDD
| model | accuracy | F1 | ROC-AUC |
|---|---|---|---|
| Isolation Forest | 0.83 | 0.87 | 0.94 |
| XGBoost (default) | 0.81 | 0.80 | 0.97 |
| XGBoost (tuned) | 0.92 | 0.93 | 0.97 |
| Stacking IF + XGB | 0.81 | 0.80 | 0.95 |
Re-applied to UNSW-NB15, the same method reaches F1 0.94 with an opposite optimal threshold (0.90 vs 0.0001): the approach generalizes by adapting to each dataset's bias.