Isolation Forest for sensor anomalies: how it works and where it misleads
Read flagged rows in a sensor table by their isolation score, understand what contamination does in the model, and see where the method misleads you.
Spot unusual periods and the sensors behind them; your data stays in this browser.
How Sentinel learns normal and how to read an alert.
A machine has dozens of sensors. A failing seal rarely breaks one limit. It quietly changes how the sensors move together. Sentinel learns normal operation from the first part of your data. Then it scores every row with three methods, and raises an alert only when the deviation persists. For each alert you see which sensors carried the deviation, so you know where to look first. Load a CSV, or try a built-in scenario. Everything runs in your browser.
Narration: synthetic voice (Piper, voice “Joe”, CC0 public domain). Captions are burned into the video.
Pick a scenario. All are mathematically generated examples, not real plant data.
Drop a CSV file here
Numeric columns are sensors; a date column becomes the time axis.
Alarm rate accepted during normal operation (): low 0.1% · balanced 1% · high 3%. High sensitivity gives more alarms.
Above 1: limit crossed. Drag to zoom. (Clipped at 4.)
Pick one to see the reasons below.
Bars: each sensor’s share. Small charts: each against its normal band.
Points are rows; faint ones are training. Outside the box: over limit.
Seven steps: set aside the training part, learn normal, score with three methods, combine into one index, watch slow drift separately, filter short blips, and split the cause across the sensors.
The first part of the table is taken as “normal”; everything is measured against it. Empty cells are filled with that sensor’s median in the training part.
Training is the first rows in file order, not a random sample.
For PCA each sensor is scaled by its training mean and sample standard deviation (σ = 1 if σ ≈ 0).
| Setting | Value | Note |
|---|---|---|
| Training share r | 0.60 | adjustable 30–90% |
| Usable sensor | > 5 values | at most 30% empty, not constant; 2–24 sensors |
| Row limits | 60 – 20,000 | at least 60 rows, at least 40 training rows |
Source sentinel/sentinel.js · forge/import.js
It tries to separate a row from the others with random cuts. An unusual row is alone after a few cuts; a typical row needs many.
| Setting | Value | Note |
|---|---|---|
| Trees | 100 | seed 42 |
| ψ | 256 | subsample per tree; maximum depth ⌈log₂ψ⌉ = 8 |
| Fit | ≤ 4,096 | training rows chosen at even spacing; each cut is uniform between the node’s min and max |
Source dev/native/kutupml.c · wasm/kutupml.js
It learns how the sensors normally move together. T² measures how far a row goes along those usual directions; SPE measures how far it steps outside them, i.e. how much the relationship between sensors broke.
R: the training correlation matrix; eigen-decomposition by the Jacobi method.
The fewest components that explain 90% of the variance (at most C − 1).
Source dev/native/kutupml.c · sentinel/sentinel.js
The three methods score on different scales. Each is rescaled so its training median is 0 and its training threshold is 1; the index is the largest of them. Above 1 is beyond the limit.
k: the selected methods (IF, T², SPE).
Q_k: linear-interpolated quantile of method k’s scores over the training rows.
The budget is per method: each method crosses on roughly a share b of training rows, so the flagged share in training lies between b and (number of methods) × b. Thresholds are computed on the rows the models were fitted on, not on held-out data.
Source sentinel/sentinel.js · tool-ui.js
In a small but lasting drift, single rows may never cross the limit. An exponentially weighted moving average (EWMA) of the index accumulates the drift and flags rows once it crosses its own limit.
ℓ_e: the EWMA limit. ē, σ_e, Q_e: from the e values of training rows after row 30.
Flag: A ≥ 1, or (row ≥ 30 and e > ℓ_e).
Source sentinel/sentinel.js
Single-row blips do not raise an alert. Flagged rows are joined even with up to two unflagged rows between them; a run with at least 3 flagged rows becomes an “unusual period”.
| Setting | Value | Note |
|---|---|---|
| Persistence | 3 | fewest flagged rows for a period (1–8) |
| Bridge | ≤ 2 | unflagged rows allowed in between |
| Kind | 0.3 | “drift” if rows with A ≥ 1 are at most 30% of the EWMA flags, else “sudden” |
| Ongoing | N − max(3, 2%) | if the last period ends after this row the verdict is “Attention” |
Source sentinel/sentinel.js
For each period, T² and SPE are split across the sensors: how much each sensor added to the row’s distance from normal. The shares are averaged over the period’s rows, weighted by the index.
Σ_j T²_j = T², Σ_j SPE_j = SPE; r: the residual PCA cannot explain.
Rows: every ⌊length/40⌋-th row of the period with A ≥ 0.5. With PCA off, Isolation Forest occlusion is used instead: how much the score falls when one sensor is set to its training median.
Source sentinel/sentinel.js · dev/native/kutupml.c
Rows and periods where several sensors together depart from the learned normal operation. It also catches cases where each sensor is within its own limits but the combination is unusual.
No. Sentinel only says a row departs from the normal it learned. A commissioning step, a product change or maintenance also look unusual. The engineer decides the cause; the per-sensor shares for each period support that review.
No. The table is processed in your browser by a WebAssembly module written in C. Nothing is sent anywhere and it is gone when you close the page. Files you export stay with you.
The model then treats that behaviour as normal and may miss similar events later. Check that the training part really represents normal operation; Sentinel also shows the alarm rate inside the training part.
At least 60 rows (40 of them training) and two to twenty-four numeric sensors; in practice a few hundred normal rows are advised. Sentinel reads up to 20,000 rows. Isolation Forest and PCA are fitted on at most 4,096 training rows chosen at even spacing; thresholds and the EWMA use every training row.
Read flagged rows in a sensor table by their isolation score, understand what contamination does in the model, and see where the method misleads you.
Read correlated sensors through T² and SPE together rather than one statistic, interpret contribution plots, and learn where the method’s assumptions break.
Learn what unlabelled sensor history can and cannot tell you, how to evaluate a detector without labels, and why operating modes need attention first.
Let’s review your data source, your existing system and the decision you want to improve.