Lion Cipher Lab

Build gradient-boosted trees from scratch for phishing URL detection, and match scikit-learn

Why it matters

Gradient-boosted trees are the default answer for tabular security data: URL features, login records, process telemetry, email metadata. Teams reach for them because they usually win. Most people use them as a black box with three magic settings. That is fine until something goes wrong: the model overfits, the probabilities are off, the importance chart points at nonsense, or a phisher changes two cheap things and walks past it. This lab takes the box apart. You write the algorithm yourself in numpy, straight from the 2001 paper that defined it. Then you prove your version gives the same…

What you'll learn

Steps in this lab

  1. What you are building, and the words you need
  2. Open a terminal, make a folder, install numpy and scikit-learn
  3. Generate the synthetic URL features (with a hidden rule and a planted trap)
  4. Measure BEFORE: a straight line and a single tree
  5. Write the booster: residuals, a regression tree, and a Newton step in every leaf
  6. Prove it: match scikit-learn row by row, and explain the rows that differ
  7. Learning rate, number of trees, and early stopping, measured
  8. Honest negative 1: the probabilities are close on average, not in every range
  9. Honest negative 2: your version is slow, and exact boosting is slow next to histograms
  10. Honest negative 3: impurity importance gives a random column real weight
  11. Honest negative 4: good synthetic scores say nothing about real phishing
  12. When to use boosting, when not to, and how a pro does it better

Open the full interactive lab →