Isolation Forest vs the Humble Z-Score
Isolation Forest vs a z-score on the UCR and NAB anomaly benchmarks, why point adjusted F1 is left out and how the winner changes with data.
On this page
The z-score has been doing this quietly for a very long time. Take the recent past, ask how many standard deviations away the new point sits, raise a hand if the answer is large. Before I let an Isolation Forest replace that, I wanted to see the two of them sit the same exam, with the same marking.
The exam is the benchmark harness in Sentinel-ML, an anomaly detection project for infrastructure metrics that I started in October 2026.
The marking scheme comes first
Much published work on time series anomalies reports scores after a step called point adjustment. If a detector flags even one point inside a labelled anomaly, the whole stretch counts as detected. A detector that shouts at random will, sooner or later, shout somewhere inside a long anomaly and collect the lot. Kim and colleagues showed that under point adjustment even a random anomaly score can look like the state of the art.
Here is the trick in one picture.
labelled anomaly . . # # # # # # . .
what was flagged . . . . . # . . . .
after adjustment . . # # # # # # . .One hit, six points of credit. So it is excluded here, entirely. Quality is measured with range-based precision and recall, which gives credit for how much of an anomaly was covered and takes it away for fragmenting the alert into pieces. Beside it sit the number of series detected, the delay from the start of an anomaly to the first hit, and false positive ranges, meaning predicted stretches that touch no labelled point.
The numbers will look small. They are supposed to.
The contestants
- Static threshold: distance from the median of the training data.
- Rolling z-score: distance from the recent mean in units of recent spread, over the previous 100 points.
- EWMA: the same idea with an exponentially weighted memory, smoothing factor 0.1.
- Isolation Forest: 100 random trees over windows of 32 points. The intuition is that unusual samples get separated by random splits in fewer steps.
Every detector scores a point using only what came before it. Each one sets its own alert level from the training portion alone, by fitting on the first half and looking at the second. No test data, no labels.
Comparing at matched recall
Default alert levels make an unfair comparison, since a detector can look quiet simply by catching less. So each detector also gets one global adjustment, chosen to be as strict as possible while still reaching the same average recall as the z-score at its default. Then the false positives are counted.
So every table below reads the same test scores in one of two ways.
flowchart TD
S[Scores on the test stream] --> D["Default: alert level from training"]
S --> M["Matched: one adjustment per detector"]
D --> A["F1, series detected, delay, false positives"]
M --> B["False positives at the z-score's recall"]Warning
The matched adjustment is picked using the test labels. It compares detectors fairly and is not a setting anyone could deploy. The target is also low: on UCR the matched mean range recall is about 0.039, so every method here misses most of the labelled stretch.
Isolation Forest vs z-score on UCR
The UCR Anomaly Archive was introduced by Wu and Keogh in a paper arguing that popular benchmarks are flawed. It has 250 series, each with exactly one labelled anomaly.
Range F1, series detected and delay come from each detector’s own default.
| UCR, at default | Range F1 | Detected of 250 | Median delay |
|---|---|---|---|
| Static threshold | 0.028 | 41 | 43 |
| Rolling z-score | 0.036 | 45 | 21 |
| EWMA | 0.030 | 35 | 23 |
| Isolation Forest | 0.044 | 54 | 89.5 |
| Ensemble of baselines | 0.042 | 47 | 32 |
| Ensemble with forest | 0.047 | 53 | 32 |
Delay is counted in points. Now the false alarms, both ways.
| UCR false positives per 10k | Matched | Default |
|---|---|---|
| Static threshold | 4.97 | 4.71 |
| Rolling z-score | 3.76 | 3.76 |
| EWMA | 9.55 | 3.01 |
| Isolation Forest | 2.97 | 8.06 |
| Ensemble of baselines | 2.00 | 3.96 |
| Ensemble with forest | 1.43 | 5.80 |
At matched recall the forest produces fewer false alarms than the z-score, 2.97 against 3.76. At its own default it produces more than twice as many, 8.06 against 3.76. At that default it also finds more series and takes over four times as long to speak up. Which of those is “better”? It depends on whether your pager hates noise or hates waiting.
A random forest invites one obvious objection: lucky seed. So it ran five times.
xychart-beta
title "UCR matched false positives per 10k, forest by seed"
x-axis ["seed 0", "seed 1", "seed 2", "seed 3", "seed 4"]
y-axis "bars: forest, line: z-score" 0 --> 4
bar [2.97, 3.06, 2.72, 2.84, 2.71]
line [3.76, 3.76, 3.76, 3.76, 3.76]Every bar stays under the line, from 2.71 to 3.06 against 3.76. The false positive win holds in all five. Now the same five runs on the other measures.
| Forest seed | Range F1 | Series detected |
|---|---|---|
| 0 | 0.044 | 54 |
| 1 | 0.037 | 47 |
| 2 | 0.038 | 53 |
| 3 | 0.037 | 45 |
| 4 | 0.033 | 45 |
The range F1 win does not survive nearly as well: the mean is about 0.038 against the z-score’s 0.036, one seed falls below it and two more barely clear it. Seed 0, the one in the headline table, is the best of the five on F1 and series detected. Had I stopped there, the forest would have looked better than it is. Five seeds is not a confidence interval either.
On NAB the lead evaporates
The Numenta Anomaly Benchmark brings timestamped streams, so false positives can be counted per day. 54 series ran, 49 with labels.
| NAB, at default | Range F1 | Detected of 49 | Median delay |
|---|---|---|---|
| Static threshold | 0.193 | 44 | 71.5 |
| Rolling z-score | 0.144 | 36 | 100 |
| EWMA | 0.127 | 36 | 100 |
| Isolation Forest | 0.166 | 43 | 43 |
| Ensemble of baselines | 0.140 | 35 | 100 |
| NAB false positives per day | Matched | Default |
|---|---|---|
| Static threshold | 1.05 | 1.94 |
| Rolling z-score | 0.595 | 0.595 |
| EWMA | 0.82 | 0.53 |
| Isolation Forest | 0.586 | 3.25 |
| Ensemble of baselines | 1.92 | 1.96 |
Matched, the forest and the z-score are level: 0.586 against 0.595 per day, about 1.5 percent apart on a single fit with no seed sweep. At defaults the forest is more than five times as noisy, while catching more and catching it sooner. The delay story from UCR has flipped.
The ensemble flips harder. Second best row on UCR at matched recall, worst row on NAB, behind every single detector. Why does taking the loudest of several detectors help on one suite and hurt on the other? I have not investigated, so I will not guess in print.
The same suite, fewer series
Adding the forest to the ensemble meant a second NAB run with all six detectors, and only 41 series came through it, 36 of them labelled. It is not comparable row for row with the table above, and it is worth showing precisely because of what changes:
| Detector, smaller NAB set | False positives per day, matched | Detected of 36 |
|---|---|---|
| Rolling z-score | 0.69 | 25 |
| Isolation Forest | 0.33 | 34 |
| Ensemble of baselines | 2.08 | 25 |
| Ensemble with forest | 0.56 | 27 |
Put the forest and the z-score from both selections side by side.
xychart-beta horizontal
title "NAB matched false positives per day, two series sets"
x-axis ["z-score, 54 series: 0.595", "Forest, 54 series: 0.586", "z-score, 41 series: 0.69", "Forest, 41 series: 0.33"]
y-axis "lower is better" 0 --> 1
bar [0.595, 0.586, 0.69, 0.33]Here the forest halves the z-score’s false alarms. On the larger set they tied. Same code, same suite, a different selection of streams, and the headline would flip from “no real difference” to “twice as good”. The forest also drags the ensemble a long way down in false alarms, and the result is still noisier than the forest on its own. If someone quotes you one number from one subset, ask which series produced it.
The verdict
The project’s rule is that a learned detector becomes a default only if it beats the baselines across the suite on false positives at matched recall. A clear win on one suite, with the other tied or ahead depending on which series ran, has not settled that yet, and two further suites are still pending. The forest and the ensembles stay opt-in. The losing rows stay in the tables.
The z-score, meanwhile, was the quickest to detect on UCR, stayed level with the forest for the fewest false alarms on the larger NAB set, and fits in a few lines. It has not asked for a promotion.