Lion Cipher Lab
Flag out-of-distribution alerts with ensemble disagreement, and measure what softmax confidence misses
- AI Security
- Advanced
- ~75 min
- Free · no account required
Why it matters
Security classifiers live in a world that keeps changing. A model trained on last quarter's traffic will meet a new tool, a new attacker technique, or a familiar app that changed its behaviour. When that happens, the model does not say 'I have never seen this'. It must pick one of the labels it knows, and it often reports a very high probability while doing it. Many teams use that probability as a safety net: if the model is less than 90% sure, send it to a human. This lab measures how well that net holds. You will train a small neural network to label network flows, then show it traffic it…
What you'll learn
- building a seeded synthetic flow-feature dataset with four known classes and four kinds of never-seen traffic (far, near, and overlapping), so every result is reproducible
- measuring the max-softmax-probability baseline honestly: on a never-seen port scan the single MLP was more than 0.99 sure on 98.4% of flows, and its OOD AUROC was 0.026, worse than a coin flip
- training a deep ensemble of scikit-learn MLPs that differ only in random seed, and computing ensemble mean probability, predictive entropy and mutual information (the members' disagreement) by hand
- reading where an ensemble helps and where it does not: DNS-tunnel AUROC went from 0.905 (single) to 0.956 (mutual information), but on the port scan all five members agreed (0.0% disagreement) and stayed confidently wrong
- putting a fair rival next to the neural scores: a 10th-nearest-neighbour distance on the scaled inputs reached 0.968 on the port scan and 0.996 on the DNS tunnel
- catching an evaluation trap: C2 traffic identical to web browsing scored 0.818 AUROC against all known flows, but 0.470 against web browsing alone, which is the honest number
- turning uncertainty into a triage rule and measuring accuracy-versus-coverage: at 80% coverage, accuracy on answered flows rose from 0.815 (single softmax) to 0.880 (ensemble plus kNN), and new flows answered fell from 203 to 118 of 300
- pricing the fix: 5 members cost 3.6x to 5.7x the scoring time of one, and 10 members did not beat 5 here
Steps in this lab
- The words first: in-distribution, out-of-distribution, softmax confidence, and disagreement
- Open a terminal, make a folder, install numpy and scikit-learn
- Build the synthetic flows: four known classes and four kinds of never-seen traffic
- Write the evaluator: one MLP, a five-member ensemble, and five uncertainty scores
- Measure BEFORE: the single model's confidence on traffic it has never seen
- Measure AFTER: ensemble disagreement, where it helps and where it does not
- The fair rival: a plain distance on the inputs, and what it costs
- Honest negatives: near-OOD is hard for everyone, identical-looking C2 is invisible, and more members did not help
- Turn it into triage: accuracy versus coverage when the model abstains
- Do it better: how a pro would ship OOD flagging on a security classifier