
Anomaly Detection With Isolation Forests
An Isolation Forest flags unusual data points by how quickly random splits separate them. A greenhouse sensor example shows why rare points still need human context checks.
Fontes
Resumo completo
A greenhouse sensor records temperature and relative humidity every minute. Most afternoons the readings cluster near 22 °C and 65 percent, but one row shows 41 °C and 88 percent. An Isolation Forest can flag that row without any labels or rules. The method builds many random decision trees. Each tree starts with all the data and repeatedly picks one feature at random, then picks a random split value between that feature's minimum and maximum. The data are divided into two groups, and the process continues until every point sits alone in its own leaf. The number of splits needed to isolate a point is its path length. A point far from the crowd often gets separated after one or two splits. A point inside a dense cluster needs many splits before it stands alone. Averaging path lengths over many trees, a short average path signals a potentially unusual point, while a long average path suggests a typical one.
In the greenhouse example, a split on temperature near 30 °C might isolate the 41 °C reading immediately. A reading of 23 °C and 66 percent humidity sits inside the crowd and needs many splits. The forest therefore assigns the hot, humid row a lower normality score. This row is unusual relative to the training data, not automatically wrong. Rare does not equal erroneous. The 41 °C reading could be a genuine heat spike, a sensor placed near a heater, or a calibration drift. A short path length is a prompt for a contextual check, not a verdict. Ask whether the reading matches neighboring timestamps, whether other sensors agree, and whether maintenance records explain it. Without that check, a real event might be discarded as noise.
The method has limits. In dense regions, ordinary variation can look isolated because random splits happen to fall awkwardly. In uneven subsets, a sparse but legitimate group may produce short paths and be flagged repeatedly. With many features, random splits may rarely choose the informative ones, so results vary between runs. No Isolation Forest finds every anomaly, and none proves a point is faulty. The model only identifies points that are easy to isolate under random partitioning. A teacher can demonstrate this with a simple classroom task. Give students twenty hypothetical sensor rows on cards. Ask pairs to draw three random split lines, record how many cuts isolate each row, and write a one-sentence justification beside any flagged row. Post the cards on a wall and compare which rows different pairs flagged. Discuss why the same row received different path lengths and what extra information would settle the question. The written justifications reveal whether students treat shortness as evidence or as a question.
Teachers can extend this by asking students to add a third feature, such as light level in lux, and rerun their splits. Some rows that looked isolated in two dimensions may join a broader group. This shows how feature choice shapes results and why documenting the data range matters. Keep the focus on careful questioning rather than on finding a single correct list of anomalies. The Isolation Forest does not replace human judgment. It narrows the search to rows that deserve a second look, and the second look is where the real work begins.


