Skip to content
StackDecode
AI & ML Atlas
Machine LearningalgorithmAnimated walkthrough

Isolation Forest

Finds anomalies because they are isolated with fewer random splits.

The idea

Build trees that split on a random feature at a random value. A rare, unusual point sits far from the crowd and ends up alone after only a few splits; a typical point needs many. The average path length over many trees becomes the anomaly score: shorter means more anomalous.

score = 2^(−E[h(x)] / c(n))

Watch it run

The pipeline lights up one step at a time. Use the controls to pause or step through it.

  1. 1Draw a random subsample and build a tree by random splits.
  2. 2Repeat to make many trees.
  3. 3Measure how many splits it takes to isolate each point.
  4. 4Average over trees and convert to a score.
  5. 5Flag the points with the shortest paths.

score = 2^(−E[h(x)] / c(n))

1/5

Step by step

  1. 1Draw a random subsample and build a tree by random splits.
  2. 2Repeat to make many trees.
  3. 3Measure how many splits it takes to isolate each point.
  4. 4Average over trees and convert to a score.
  5. 5Flag the points with the shortest paths.

Where it is used

Fraud detection, system monitoring, data cleaning.

Watch out for

Axis-parallel splits can miss anomalies that hide inside dense, oddly shaped regions.

Related