Unsupervised learning
Isolation Forest and One-Class Boundaries
Study Isolation Forest, one-class SVM, and boundary-based novelty detection, including score interpretation and scaling tradeoffs.
By the end you can
- Explain why random partition trees isolate some anomalies with short paths
- Describe one-class boundary learning around a reference population
- Compare isolation, distance, density, and support-based anomaly assumptions
- Tune contamination, kernel, subsampling, and thresholds through alert-level evaluation
Analogy
Finding unusual objects by how quickly dividers separate them
Random dividers dropped into a warehouse again and again separate some objects almost at once. An isolated object near an edge is cut off after a few dividers. An object buried in a crowded stack takes many.
A dense group of anomalies stays deep in the tree, because depth records separability and nothing else. Isolation depth does not measure harm or intent.
The analogy hides one detail that matters operationally: the dividers are random in position, never in angle. Every cut is parallel to one feature axis. Three researchers drew the resulting anomaly-score heat maps and found that geometry printed on them. Their 2018 paper, Extended Isolation Forest, reports that “These maps suffer from artifacts generated by the criteria for branching operation of the binary tree.” Their fix is to cut with hyperplanes at random slopes instead of splitting parallel to the axes.
H2O.ai's own implementation documentation names the same cause independently: “The cause of the bias is that branching is defined by the similarity to BST. At each branching point the feature and the value are chosen; this introduces the bias since the branching point is parallel to one of the axes.” So the score surface a reviewer inspects carries a signature of the splitting rule as well as of the data. Two points that look equally unusual to a human eye can sit at different depths. One of them simply happened to be unusual along a coordinate the cuts can reach.
The cuts are random in position but never in angle, and the score map shows it.
Visual
Two different ways to describe normal support
Isolation methods and one-class boundaries come at novelty from opposite directions. Isolation Forest partitions features and values at random, then measures how short a path is needed to cut a point out of the sample. It never estimates a density, and it never needs to see the whole training set at once. A One-Class SVM instead learns a kernel boundary that separates most of the reference data from the origin. Each new point is then asked whether it falls inside that support region.
The two costs are not comparable, and the difference is documented rather than folkloric. scikit-learn's user guide gives the one-class solver a range rather than a figure: “The QP solver used by the libsvm-based implementation scales between O(n_features × n_samples^2) and O(n_features × n_samples^3) depending on how efficiently the libsvm cache is used in practice (dataset dependent).” Isolation Forest's published cost is O(tψ log ψ) to train and O(nt log ψ) to evaluate. Here ψ is the sub-sample per tree and t the number of trees. The sample size enters the training term only through ψ, and ψ is held at 256 by default.
Sensitivity to units is documented by the maintainers of both standard implementations. The same scikit-learn page warns that “Support Vector Machine algorithms are not scale invariant, so it is highly recommended to scale your data.” The LIBSVM authors open the scaling section of their practical guide with the sentence “Scaling before applying SVM is very important.” The reason they give is arithmetic, not stylistic: “The main advantage of scaling is to avoid attributes in greater numeric ranges dominating those in smaller numeric ranges.” Their instruction is explicit: “We recommend linearly scaling each attribute to the range [−1, +1] or [0, 1].” Feed raw amounts in one column and raw counts in another to a One-Class SVM, and you have already chosen which feature the boundary listens to.
Isolation Forest
Randomly partition features and values, then measure path length.
- Uses tree ensembles
- Benefits from subsampling
- Scales well to large numeric data
- Assumes anomalies isolate relatively quickly
One-Class SVM
Learn a kernel boundary separating most reference data from the origin.
- Models a support region
- Depends on kernel and nu
- Can express nonlinear boundaries
- Can be expensive and scale-sensitive
Two geometric stories, and only one of them is documented as not scale invariant.
An anomaly found without modeling the normal density directly
A sparse combination of features is isolated after only a few random tree splits. Common observations require deeper partitions. Isolation Forest converts that path-length difference into an anomaly ranking. The method's efficiency comes from a structural assumption: rare observations with unusual attribute values are often easier to isolate. Not every anomaly satisfies that assumption.
The defaults carry the assumption, and they are the paper's defaults. The original Isolation Forest paper, published in 2008, fixes the sub-sample at ψ = 256 and the ensemble at t = 100 trees. It reports training complexity O(tψ log ψ) and evaluation complexity O(nt log ψ). Its discussion section states the practical consequence: “For Http data set, when ψ = 256, t = 100 and evaluating 283,748 instances, the total processing time is 7.6 seconds only.” Two hundred and eighty-three thousand points scored in under eight seconds, by trees that each saw 256 rows.
scikit-learn ships exactly those numbers. Its IsolationForest reference documents 100 estimators by default and max_samples='auto', defined as “max_samples=min(256, n_samples)”. It records that the contamination default changed to 'auto' in version 0.22, with offset -0.5, and it cites both isolation papers, the 2008 conference one and the 2012 journal one. Feeding a million rows to the estimator does not give each tree a million rows. A small sample per tree is the design, not a shortcut. The examples section shows a case where enlarging it makes the detector measurably worse.
Isolation is a proxy for unusualness, not a causal explanation.
Comparison
Four anomaly assumptions in one view
Method choice should follow the kind of departure the domain expects, and the size of that effect has been measured. ADBench, a 2022 benchmark, ran 30 algorithms across 57 datasets in 98,436 experiments. Its first finding is a negative one: “None of the unsupervised methods is statistically better than the others, as shown in the critical difference diagram of Fig. 4a”.
The ranking is not merely flat. It inverts with the shape of the anomaly. On the benchmark's synthetic clustered anomalies the AUCROC values run LOF 47.17, COF 53.00, DeepSVDD 55.97, OCSVM 95.53, IForest 96.94 and PCA 97.77. A local-density method that would win on scattered outliers scores below chance on clustered ones in the same suite. A support-based method reaches 95.53 there, and an isolation-based one 96.94. The authors state the rule the numbers imply: “Performance of unsupervised algorithms highly depends on the alignment of its assumptions and the underlying anomaly type.”
An earlier independent evaluation reached a compatible verdict about the support-based family. Goldstein and Uchida evaluated 19 unsupervised algorithms on 10 datasets, in PLOS ONE in 2016, and concluded that “One-class SVMs turned out to be not outstanding algorithms and results are average.” They also report the spread in cost that a leaderboard hides. On kdd99 their runtimes range from under 4 seconds for HBOS to more than 6 days for GMGOS-MCD.
Read the four assumptions as four hypotheses about the departure, each with a measured failure mode. Isolation asks that anomalies need fewer random partitions. A support boundary asks that normal data occupy a learnable region. Local density asks that anomalies be sparse relative to nearby peers. Reconstruction asks that anomalies reconstruct poorly under a learned normal representation. The 47.17-versus-96.94 gap in one column of one figure is what happens when the wrong hypothesis is chosen.
Isolation
Anomalies require fewer random partitions to separate.
- Strong for sparse unusual combinations
- Avoids explicit density estimation
- Can miss clustered anomalies
- Affected by irrelevant features
Support boundary
Normal data occupies a learnable region in feature or kernel space.
- Fits clean novelty settings
- Needs representative normal data
- Sensitive to kernel scale
- Can reject shifted normal regimes
Local density
Anomalies are sparse relative to nearby peers.
- Adapts to heterogeneous populations
- Needs reliable neighborhoods
- Can flag boundaries
- Suffers in high dimension
Reconstruction
Anomalies reconstruct poorly under a learned normal representation.
- Can model complex patterns
- May reconstruct anomalies well
- Depends on capacity and loss
- Needs careful thresholding
Example
Where isolation and support methods disagree
Disagreement can reveal the anomaly mechanism rather than identify one universal winner. Each of the following is a documented failure of an assumption rather than a hypothetical.
- Clustered anomalies and masking: the original Isolation Forest paper named this failure itself — “Masking is the existence of too many anomalies concealing their own presence. When an anomaly cluster is large and dense, it also increases the number of partitions to isolate each anomaly.” On the Mulcross data, which contains two dense anomaly clusters, it reports: “When using the entire sample, iForest reports an AUC of 0.67. When using a sub-sampling size of 128, iForest achieves an AUC of 0.91.” The full sample was 4,096 instances. Shrinking what each tree sees to 128 moved AUC from 0.67 to 0.91. ADBench reproduced the effect at benchmark scale: duplicating anomalies six times cost unsupervised methods a median ΔAUCROC of −16.43%, against −0.05% for semi-supervised methods.
- Novel normal regime: a One-Class SVM rejects a new legitimate product line because the clean reference lacks that support. The rejection rate is not incidental. nu is documented as an upper bound on the fraction of training errors and a lower bound on the fraction of support vectors, and scikit-learn's default value is 0.5. An unexamined default has already declared half the reference sample abnormal.
- Irrelevant or rotated dimensions: random splits waste depth on noisy features and reduce Isolation Forest contrast. And because every split is parallel to an axis, the score surface itself carries artifacts — the effect measured in the Extended Isolation Forest heat maps.
- Kernel and scale sensitivity: a narrow RBF boundary memorizes normal points, while a broad kernel accepts too much space. Before the kernel is even chosen, unscaled columns decide the outcome. That is why the LIBSVM authors put “Scaling before applying SVM is very important.” at the head of their guide. The cost of exploring that space is bounded by a solver that scales between O(n_features × n_samples^2) and O(n_features × n_samples^3).
- Score drift: feature distribution changes alter path lengths or boundary distances before label prevalence is known. A threshold calibrated on last quarter's scores is then silently re-tuned by the data rather than by a decision.
Key idea
One-class training data must represent legitimate diversity
A boundary learned from a narrow “clean” period can reject new regions, devices, languages, or users that were simply absent. The detector then enforces historical coverage as normality.
This is not only an accuracy problem, and a court has said so about a deployed risk-selection system. On 5 February 2020 the District Court of The Hague decided NJCM et al. v The Netherlands. Its judgment reads: “the court declares in this judgment that Section 65 SUWI Act and Chapter 5a SUWI Decree have no binding effect, being contrary to Article 8 paragraph 2 ECHR”. The Dutch SyRI risk-indication legislation was struck down as insufficiently transparent and verifiable. The risk model itself was not disclosed, so neither the affected people nor the court could check what the system treated as normal.
The judgment is equally explicit about who bears the cost of a reference population drawn from one part of the country. The court wrote: “It is correct that to date SyRI has only been applied to so-labelled ‘problem districts’, as confirmed by the State at the hearing. This in and of itself need not imply that such use is disproportionate or otherwise contrary to Article 8 paragraph 2 ECHR in all cases. However, given the large amounts of data that qualify for processing in SyRI, including special personal data, and the circumstance that risk profiles are used, there is in fact a risk that SyRI inadvertently creates links based on bias, such as a lower socio-economic status or an immigration background, as NJCM et al. argue.” Van Bekkum and Zuiderveen Borgesius reproduce the same holding and the same discrimination finding in their 2021 analysis of the case.
Audit which populations the reference includes, and the protected slices, before you ship. Record where the reference data was collected, not only how clean it is. Novelty detection should open an unknown workflow, not automatic punishment for unsupported populations. A detector whose support region cannot be described to the person it flags is the configuration the Hague court refused to allow.
A clean reference can still be incomplete and exclusionary — and a risk model nobody can inspect has already lost that argument in court.
Steps
Compare isolation and one-class detectors fairly
Use the same feature pipeline, time split, alert budget, and adjudication process. Three of the steps below have measured stakes rather than stylistic ones.
Defining the expected anomaly form comes first. On ADBench's clustered anomalies LOF scores 47.17 AUCROC and IForest 96.94, in the same experiment. The choice made before any tuning is larger than most of the tuning that follows. Preparing the reference means documenting contamination, legitimate diversity, missingness and time coverage. The SyRI judgment is the record of what an undocumented reference population costs.
Tuning structural parameters means treating the sub-sample as a real parameter and not a default. The Isolation Forest paper's own Mulcross result moved AUC from 0.67 to 0.91 by cutting ψ from the full 4,096-instance sample to 128, and scikit-learn's max_samples='auto' will not do that for you. On the one-class side, nu is not a tolerance knob but a budget with a proven meaning, and its default of 0.5 is rarely the budget anyone intended. Scaling is a prerequisite rather than a step: the LIBSVM guide's instruction — each attribute linearly scaled to the range [−1, +1] or [0, 1] — decides which column the boundary can see.
Then compare score rankings under one alert capacity: precision at capacity, event coverage, subgroup yield and score stability. Finally, monitor unknowns — drift, new regimes, reviewer overturns and reference refresh decisions. ADBench's six-fold duplication experiment cost unsupervised methods −16.43% median ΔAUCROC while semi-supervised methods lost −0.05%. The presence or absence of labels changes what monitoring has to catch.
1. Define expected anomaly form
State whether departures are isolated, locally sparse, outside support, or sequential.
2. Prepare reference data
Document contamination, legitimate diversity, missingness, and time coverage.
3. Tune structural parameters
Sweep tree subsampling, feature sampling, kernel scale, and nu with held-out evidence.
4. Compare score rankings
Measure precision at capacity, event coverage, subgroup yield, and score stability.
5. Monitor unknowns
Track drift, new regimes, reviewer overturns, and reference refresh decisions.
Anomaly algorithms encode different theories of separation
Isolation Forest asks how quickly random axis-parallel partitions separate a point. One-Class SVM asks whether it lies inside a learned support region. Neither score is a calibrated risk probability by default. Their operational value depends on the anomaly mechanism, reference coverage, threshold, and review process.
One-class methods turn the same question into a budget, and the budget has a proof behind it. The 1999 paper that introduced the one-class support vector method states, in its Proposition 1, that ν “is an upper bound on the fraction of outliers” and “is a lower bound on the fraction of SVs”. scikit-learn's OneClassSVM reference documents the same property in its own words: nu is “An upper bound on the fraction of training errors and a lower bound of the fraction of support vectors. Should be in the interval (0, 1]. By default 0.5 will be taken.”
Choosing nu therefore decides in advance how much of the reference sample counts as abnormal. It is an alert budget written into the fit, not a sensitivity dial discovered afterwards. Isolation Forest's equivalent decision is contamination, which scikit-learn moved to 'auto' in version 0.22 with an offset of -0.5. In both cases a default that nobody chose is still a choice. And the ADBench verdict stands over the whole family: “Performance of unsupervised algorithms highly depends on the alignment of its assumptions and the underlying anomaly type.”
Select the detector whose failure assumptions match the investigation.
Key takeaways
- Isolation Forest ranks points by path length in random axis-parallel partition trees. The original 2008 paper fixed ψ = 256 and t = 100 trees, and at those settings scored 283,748 Http instances in 7.6 seconds.
- One-Class SVM learns a support boundary around reference data. It is documented as not scale invariant, and the libsvm QP solver costs between O(n_features × n_samples^2) and O(n_features × n_samples^3).
- Isolation, support, density, and reconstruction encode different anomaly assumptions. On ADBench's clustered anomalies LOF scores 47.17 AUCROC against IForest's 96.94 and PCA's 97.77, and no unsupervised method was statistically better than the rest across 98,436 experiments.
- Clustered anomalies mask each other: 0.67 AUC on the full 4,096-instance Mulcross sample against 0.91 at a 128-point sub-sample, and a −16.43% median ΔAUCROC for unsupervised methods when ADBench duplicated anomalies six times.
- Raw anomaly scores are not calibrated risk probabilities. nu is a proven bound on the outlier and support-vector fractions and defaults to 0.5, and axis-parallel branching leaves visible artifacts in the score surface.
- Thresholds and reference populations require held-out evidence, capacity constraints, and monitoring. On 5 February 2020 the District Court of The Hague voided the Dutch SyRI legislation, because its risk model and its ‘problem districts’ reference could not be inspected.