# Isolation Forest: simple example

Can some one please explain Isolation Forests more clearly? Everywhere I search, I find the same explanation:

Isolation Forest ‘isolates’ observations by randomly selecting a feature and then randomly selecting a split value between the maximum and minimum values of the selected feature.

Let's take an example to solve this:

x1 = [2, 1, 4, 6, 4, 2, 1, 2, 3, 4, 19]


How would I say that 19 is an outlier?

The idea is that the faster you can isolate a sample the higher the chance it is an outlier/anomaly.

Here is one possible scenario for your example:

x1 = [2, 1, 4, 6, 4, 2, 1, 2, 3, 4, 19]

1. Draw a random value between min=1 and max=19; e.g. 10
2. Split according to selected value:
x1_left = [2,1,4,6,4,2,1,2,3,4]
x1_right = [19]

1. Repeat on subsets

We already isolated 19 after one step whereas the other samples "to the left" are not yet isolated and haven't changed much so far. Any threshold sampled greater than 6 would isolate 19 in a single split which has a probability close to 70%.

To make it more obvious, say x1=[1,2,3,4,5,10000000000]. Sampling a value between 1 and 10000000000 will almost surely give a result > 5 and therefore immediately isolate 10000000000.