Inspiration

Network attacks are rare. In the real traffic I used (CIC-IDS2017, five days of labelled network flows), the rarest attack is one flow in 45,000 normal flows. A detector that calls everything normal looks 80% accurate and catches nothing. I wanted a system that finds those few flows, handles attacks it has never seen, and gives analysts something they can act on.

What it does

  • Finds rare attacks. Rebalanced training (SMOTE, class weights) and a soft-voting ensemble of 5 models. On a held-out test set of 121,196 flows: 99.9% of attack flows raise an alert, and 0.10% of normal flows raise a false alarm.
  • Flags unseen attacks. A Local Outlier Factor detector trained only on normal traffic raises an Unknown-Anomaly alert when a flow looks normal to the classifier but unlike any normal traffic. Web attacks, when hidden from training, go from 3% to 87% caught.
  • Detects drift without labels. Population stability index on alerted traffic, prediction-mix shift and unknown-rate rise. On the future days of the dataset the model drops to 0.18 macro-F1, and retraining on 10% labelled new flows recovers it to 0.93.
  • Turns alerts into incidents. 22,601 flow alerts become 483 incidents (grouped by attack family, shared endpoint and a one-hour gap), each with a P1–P4 priority, the features that most deviate from normal, a conformal prediction set of possible families, and a first-response playbook.
  • Learns from analysts. Each decision is stored as a labelled example. nids retrain retrains, compares the old and new model on flows nobody reviewed, and archives the old one.

How we built it

Python, pandas and scikit-learn for the pipeline; imbalanced-learn for resampling inside cross-validation folds; a PyTorch MLP with focal loss; Streamlit for the analyst console. Every model and imbalance strategy is selected on the validation split, and the test split is used once. I added Mondrian conformal prediction for per-family coverage guarantees, paired bootstrap tests for every claimed gain, and three evaluation protocols (random, session-grouped and temporal split). Automatic data audit checks for leakage and shortcut features before training. 81 automated tests run the whole pipeline end to end.

Challenges

  • The CIC-IDS2017 timestamps are written on a 12-hour clock without AM/PM, and the dataset has 288,602 empty rows and 308,218 duplicate flows. The loader repairs these automatically and the report states exactly what was changed.
  • The headline macro-F1 jump (0.766 → 0.973) comes mostly from 9 test flows of the two rarest families. I report that openly with counts instead of hiding it in an average.
  • Random splits leak attack sessions between train and test. The session-grouped split (0.888) and the temporal split (0.18) show the real generalisation problem.

What we learned

A high score on a random split says little about a system that must catch attacks it has not seen. Honest evaluation (intervals, several protocols, explicit limits) matters more than a single number.

Limitations

  • Flow statistics only: port scans, brute-force and botnet traffic look normal at flow level and are mostly missed by the novelty detector (0–3%). Payload inspection (Zeek, Suricata) is needed for those.
  • The novelty detector has a 1% false-alarm budget, which is a real cost on large networks.
  • CIC-IDS2017 is from 2017 and has known labelling issues.

Built before the event

This project was built before the hackathon, on the CIC-IDS2017 dataset. All code, reports and the presentation are in the repository. See the repository README for the full list of results and limitations.

Built With

Share this project:

Updates

Submission history