Sub topic 13
Limitations: axis-parallel splits, high dimensions, drift
This chapter assumes you know how an isolation tree is built from random feature and split-value choices, how path length becomes an anomaly score, and how to run IsolationForest in scikit-learn. It covers three situations where the method gives poor results, and what to do about each.
Axis-parallel splits
Each split in an isolation tree compares one feature with one threshold. Every cut is therefore parallel to a coordinate axis. The regions the tree carves out are rectangles, and a diagonal structure in the data does not fit them well.
Suppose normal points lie along a diagonal band. A point just off the band, in an empty corner of its bounding box, can sit in a large rectangle that also covers part of the band. Axis-parallel cuts can reach it only after several splits, so its path is not short and its score looks ordinary. The score map then shows faint bands along the axes, called ghost regions, where scores are unreliable.
The code below builds correlated data and compares the score of an off-diagonal point with the score of a point on the band.
import numpy as np
from sklearn.ensemble import IsolationForest
rng = np.random.RandomState(0)
t = rng.normal(size=1000)
X = np.column_stack([t, t + rng.normal(scale=0.1, size=1000)]) # diagonal band
clf = IsolationForest(random_state=0).fit(X)
on_band = np.array([[1.5, 1.5]])
off_band = np.array([[1.5, -1.5]]) # unusual, but inside the axis ranges
print("on band :", clf.score_samples(on_band))
print("off band:", clf.score_samples(off_band))The off-band point should score as more abnormal, but the gap is smaller than the geometry suggests. Extended Isolation Forest, covered in a later chapter, uses randomly oriented cuts to reduce this effect.
High dimensions
Each split picks one feature at random. If only a few of many features carry the anomaly signal, most splits are wasted on irrelevant features. Those splits separate points by noise, so path lengths for normal points and anomalies become similar.
Two effects follow:
- Anomalies that differ only in a small subset of features are diluted by the many features where they look normal.
- In very high dimensions, distances and densities concentrate, so every point looks similarly isolated.
Isolation Forest scales well in cost, but cost is not the same as accuracy. Options to try:
- Remove features that are constant or irrelevant before fitting.
- Reduce dimensionality with PCA or feature selection, and check that the anomaly signal survives.
- Lower
max_featuresbelow 1.0 only if you have a reason. It does not fix noisy features by itself. - Fit separate forests on groups of related features, then combine the scores.
Drift
The forest learns what "normal" looked like at training time. If the data distribution changes afterwards, the model's idea of normal goes stale. This is drift. Two failure modes appear:
- Concept drift moves normal behavior to a new region. The forest flags the new normal as anomalous, and the alert rate rises.
- Slow drift can instead be absorbed if you retrain on recent data that already contains the shifted points, so real anomalies in the new regime become normal.
A fixed contamination value also assumes a stable anomaly rate. If the true rate changes, the threshold flags the wrong share of points.
import numpy as np
from sklearn.ensemble import IsolationForest
rng = np.random.RandomState(1)
train = rng.normal(loc=0.0, size=(1000, 2))
later = rng.normal(loc=2.0, size=(1000, 2)) # normal behavior has shifted
clf = IsolationForest(random_state=1).fit(train)
print("flagged in train:", (clf.predict(train) == -1).mean())
print("flagged later :", (clf.predict(later) == -1).mean())The flagged share after the shift is far higher than in training, even though nothing is wrong.
To handle drift, monitor the flagged rate and the score distribution over time, and retrain on a schedule using recently verified normal data.
Summary of failure modes
| Limitation | Cause | Mitigation |
|---|---|---|
| Missed off-axis anomalies | Cuts use one feature at a time | Extended Isolation Forest |
| Weak signal | Many irrelevant features | Feature selection, PCA |
| Rising false alarms | Normal behavior shifts | Monitor and retrain |
Exercise
After deploying an Isolation Forest, the share of flagged points rises from 5% to 30% over two months, and manual review finds most of the new flags are ordinary. Which limitation is the likely cause, and what do you do first?
Show answer
Drift. Normal behavior has moved away from the training data, so the forest treats the new normal as abnormal. Check the score distribution over time to confirm, then retrain on recent data that has been verified as normal, and keep monitoring the flagged rate.
Exercise
Normal data lies along a diagonal band, and points just off the band are not flagged. Why do axis-parallel splits cause this?
Show answer
Each split cuts along one axis, so the regions are rectangles. A point off the band can sit in a large rectangle that also contains band points, so it needs many splits to isolate. Its path length is long and its score looks normal.