Note: Pressing "New tree" is the algorithm running to completion. "Cut once" is a replay.
The whole idea.
Pick an axis at random. Pick a split value at random, somewhere between the smallest and largest
reading on that axis. Throw away the half your point is not in. Repeat until your point sits alone.
Count the cuts.
That count is the path length. A point way out on its own gets fenced off in two or three
cuts, because almost any random line separates it. A point buried in the middle of the crowd
survives cut after cut, because a random line nearly always keeps it with company.
Anomalies are the points that are easy to isolate — that is the whole algorithm, and
there is no distance, no mean, and no density estimate anywhere in it.
Term
What it is here
Path length
how many cuts this tree needed to get your point alone
The forest
100 trees, each with its own random cuts; the score uses the average path length
Score
s = 2−E[h]/c(n) — near 1 means isolated unusually fast, near 0.5 means ordinary
Three things worth trying:
1. Press Pick an outlier, then Run to isolation, and count. Now press
Pick one from the middle and run again. The outlier typically goes in about 3
cuts; the middle point takes around 9, and you can watch its cell stay crowded cut after
cut while the counter climbs.
2. Keep the same point and press New tree a few times. The number jumps around —
the same outlier can take 2 cuts or 9, purely on the luck of where the random lines fell.
One tree tells you almost nothing. Over 100 trees that luck cancels out: the
forest gives an outlier an average path length near 3.7, against about 8.4 for a
point in the middle. That gap is the whole reason it is a forest and not a tree.
3. Now read the tree underneath. It is the same tree the cuts came from — every leaf is one
isolated point, and depth runs down the left edge. Your outlier’s route stops near the top,
while the crowd in the middle keeps splitting down to a deepest leaf of 11 or so. The score
is nothing more than that comparison: your depth against everyone else’s. Press
Randomize the data and the shape of the tree changes completely, but the strays keep
finishing near the top.
Is this the real thing? Yes. The scores this page computes agree with
scikit-learn’s IsolationForest on the same 30 points to a correlation of
0.99, so this is good.