Lion Cipher Lab

Pick an alert classifier's threshold from a cost matrix, instead of the default 0.5

Why it matters

Almost every classifier you will put in front of a SOC ships with a hidden decision: predict() flags an alert when the model's probability is above 0.5. Nobody chose that number for your alerts. It is the threshold that maximises accuracy when both kinds of mistake cost the same, and in a SOC they never do. Closing a benign alert costs an analyst a few minutes. Missing an intrusion costs hours or days. This lab makes you write those costs down, in analyst-minutes, and pick the threshold that minimises them. On the lab's synthetic alert stream, the default 0.5 cost 20,458 analyst-minutes a…

What you'll learn

Steps in this lab

  1. The words first: probability, threshold, cost matrix, calibration, base rate
  2. Open a terminal, make a folder, install numpy and scikit-learn
  3. Write the cost matrix down, then derive the threshold by hand
  4. Measure BEFORE: the default 0.5, then the cost-based threshold
  5. The trap: on an uncalibrated model the formula is wrong
  6. Fix 1: calibrate the probabilities, then trust the formula again
  7. Fix 2: skip the formula and tune the threshold on labels, with TunedThresholdClassifierCV
  8. Add the team: a capacity limit the cost-optimal threshold ignores
  9. Honest negative 1: the base rate moves after you deploy
  10. Honest negatives 2 and 3: the costs are guesses, and a small validation set is noise
  11. When to use which, when NOT to bother, and how a pro does it

Open the full interactive lab →