Lion Cipher Lab

Label phishing emails with weak supervision, and measure a label model against majority vote

Why it matters

Every phishing classifier needs labelled emails, and labels are the expensive part. An analyst can hand-label a couple of hundred emails in an afternoon. Ten thousand would take weeks. WEAK SUPERVISION is the shortcut: instead of labelling emails, you write rules that label them for you, each one rough, and let math combine the votes. Snorkel made the idea popular, and a whole family of label models came from it. The pitch is that a clever model will work out which rules to trust without anyone giving it the answers. This lab tests that pitch on synthetic but realistic email data, with the…

What you'll learn

Steps in this lab

  1. The words first: weak supervision, labeling function, label model, end model - and the fact that everything here is synthetic
  2. Open a terminal, make a folder, install numpy and scikit-learn
  3. Build the corpus: 10,000 unlabelled emails, a hidden truth file, 200 gold labels and a test set
  4. Write twelve labeling functions and measure coverage, overlap and conflict
  5. Write the label model: Dawid-Skene style EM, from scratch
  6. Sanity check: where the assumption holds, the label model wins - until you paste a rule three times
  7. Measure on the emails: majority vote beats the label model, and the model is sure of itself
  8. Honest negative 1: the duplicate rules double-count - and removing the duplicate is not enough
  9. Honest negative 2: the class prior moves the answer more than you would think
  10. Train the end model on each set of labels and score it on emails nobody has seen
  11. Honest negative 3: the sub-types your rules never saw - a label gap you can fix, and a feature gap you cannot
  12. Do it better: how a pro runs weak supervision, and when not to

Open the full interactive lab →