Few-shot intrusion detection
Siamese network for few-shot detection of unseen attack classes.

The problem
Intrusion detection systems are good at attacks they have seen and bad at the ones that matter most: novel attack families with almost no labelled examples. A supervised classifier needs many samples per attack class, and on the first day of a new threat you don’t have them.
What I built
A Siamese few-shot detector in TensorFlow. Network flows are turned into feature vectors and assembled into same-class and cross-class pairs. A twin encoder maps each flow into an embedding space, trained with a contrastive loss to pull like traffic together and push unlike traffic apart. At inference, one support example of a novel attack is enough to flag similar flows by nearest neighbour in that space.
The hardest decision
The real choice was framing: supervised classification, or metric learning. A supervised model such as XGBoost is simpler to train and tune, but it cannot recognise an attack class it never saw in training. I chose few-shot metric learning so that one example of an unseen family is enough to detect it. The price was harder engineering: pair construction, contrastive-loss tuning and evaluating the embedding itself.
Results
- 0.97 F1 on unseen attack classes. Basis: CIC-IDS2018 dataset.
- Paper: Published · [venue/link].
- [evaluation protocol: how the unseen attack classes were held out]
What I’d do differently
The result comes from a benchmark dataset, not live traffic. A production deployment would need online adaptation and explicit handling of concept drift as real traffic changes. I’d design for that from the start rather than treat it as follow-up work.