- Introduced by
- Extended from Liu, F.T., Ting, K.M., and Zhou, Z-H. (iForest, 2008); semi-supervised variants developed by multiple authors ca. 2013–2020
- Year
- 2013–2020
- Type
- Ensemble anomaly detection (semi-supervised extension)
- Family
- Machine learning
What does it do?
Semi-supervised Isolation Forest extends the classic Isolation Forest anomaly detector by using a small set of labeled anomalies (and, where available, labeled normal examples) together with a large unlabeled dataset.
The labels guide how anomaly scores are adjusted, which may improve the ranking of anomaly types represented in the labels but can lower the ranking of anomaly types the labels do not cover. The method sits between fully unsupervised and fully supervised detection.
The intuition behind the method
Standard Isolation Forest scores a point by how quickly random trees isolate it, since anomalies tend to require fewer splits. Without labels, however, the model has no information about which unusual patterns matter in a given domain. Semi-supervised Isolation Forest adds a few confirmed examples and uses them to steer the scoring toward the patterns those labels identify. The aim is to keep the isolation mechanism while adding a small amount of domain knowledge, so that a fully labeled training set is not required.
History
Isolation Forest was introduced by Liu, Ting, and Zhou in 2008 as an unsupervised detector based on random recursive partitioning. Semi-supervised extensions that add label guidance were developed by several groups over roughly 2013 to 2020. The name therefore refers to a family of variants rather than one published algorithm.
When to use it
Choose this method when you have a large unlabeled tabular dataset, full labeling is impractical, and domain experts can confirm at least a handful of anomalies, ideally with some confirmed normal cases as well. It suits settings such as rare-event screening in cybersecurity, fraud, predictive maintenance, or medical monitoring, where a few past incidents are known. Do not use it when no labeled anomalies exist; standard Isolation Forest or One-Class SVM does not need them. Avoid it when a sufficiently large fully labeled dataset is available, because a supervised classifier is then the more directly grounded choice. Also avoid feeding it raw high-dimensional or sparse features without preprocessing, since each random split selects a feature at random and uninformative columns then dilute the isolation signal.
Limitations and considerations
- Its benefit depends on the labeled anomalies being representative of the anomalies in the unlabeled pool; a narrow labeled sample can bias scores toward one anomaly type.
- The label-integration mechanism is not fixed (tree re-weighting, an added supervised term, or a classifier on top of the scores are all possible), so results from different implementations may differ and are not directly comparable.
- It inherits the axis-parallel splits of Isolation Forest, so anomalies that are separable only along oblique directions can be isolated poorly.
- Because labeled examples inform both scoring and threshold selection, the labeled set must be kept separate from evaluation data, or reported performance will be optimistic.
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- The labeled anomalies adjust the scores, so the ranking can follow patterns confirmed in the domain rather than relying only on the structural isolation signal.
- Labels are needed only for a small subset of the data, which suits settings where annotation is expensive.
- It inherits Isolation Forest's random subsampling and random splits, so the isolation score itself computes no distances or densities; it depends only on path lengths across trees.
- The labeled subset provides a data-based basis for choosing the decision threshold instead of a fixed percentile.
Applications
- Network intrusion detection using a handful of confirmed attack samples alongside normal traffic.
- Financial fraud detection where only a small set of confirmed fraudulent transactions is available for labeling.
- Predictive maintenance: using confirmed failure events to calibrate anomaly scores on sensor streams.
- Medical monitoring: guiding anomaly scoring with confirmed pathological cases from electronic health records.
- Quality control in manufacturing where only a subset of defective units has been independently verified.
How it works
How it works
The available data are split into a small labeled subset, containing confirmed anomalies, confirmed normals, or both, and a large unlabeled pool. The labeled subset is small by design; obtaining full labels is usually costly or impractical, which is precisely the scenario this method targets.
An ensemble of isolation trees is grown on random subsamples of the full dataset (labeled plus unlabeled), following the standard iForest procedure: at each internal node, a random feature and a random split value within that feature's range are chosen to recursively partition data until each point is isolated.
Each observation has an average path length E[h(x)] across the trees, where h(x) is the path length from the root to the leaf in which the point is isolated. The score s(x, n) = 2^(-E[h(x)]/c(n)) normalises this average by c(n), the average path length of an unsuccessful search in a binary search tree of sample size n, which makes scores comparable across sample sizes. Scores lie in (0, 1]; values near 1 mark points that are isolated unusually quickly and are strong anomaly candidates. This is the standard Isolation Forest score; label guidance is applied in the next step.
Formula
s(x, n) = 2^{-E[h(x)] / c(n)}Labeled examples enter the scoring in a variant-specific way. Depending on the variant, they may be used to re-weight trees or splits that separate known anomalies from normal points, to add a supervised term to the score aggregation, or to fit a decision boundary on top of the unsupervised scores. No single procedure is standard for this family, so check the documentation of the implementation before interpreting its scores. In particular, establish what is re-weighted or added, how labeled normal examples are used, and whether the labels also influence the threshold.
A threshold is applied to the adjusted scores to produce anomaly or normal decisions. When labeled examples are available, they can guide the cut-off, for example by choosing the value that maximises F1 on them. Because the same examples may have shaped the scores, this choice should be checked on held-out labeled data; otherwise the resulting performance will be optimistic. A percentile-based cut-off is the alternative when labels are not used for calibration.
Common pitfalls
- Ignoring labeled normal examples when they are available; confirmed normals can constrain the decision boundary in regions where anomalies and ordinary points lie close together.
- Evaluating on data that includes the labeled examples used for fitting or threshold selection, which inflates reported metrics.
- Selecting the threshold on the same labeled examples that shaped the adjusted scores, which can overfit the cut-off.
- Assuming the model generalises when the labeled anomalies cover only one subtype while the unlabeled pool contains other anomaly patterns; those may receive ordinary-looking scores.
- Fitting on unprocessed features with many uninformative columns; because each split picks a feature at random, noise features reduce the share of splits that separate anomalies.
Frequently asked questions
How many labeled anomalies do I need?
No universal minimum count is defined for this method. A few confirmed anomalies can provide some guidance, but coverage matters more than count: the labels should represent the anomaly types present in the unlabeled data. If the labels cover only one subtype, the model will mainly learn about that subtype, so it is worth checking which anomaly types are missing before fitting.
How is this different from standard Isolation Forest?
Standard Isolation Forest is fully unsupervised and scores points only by how easily random trees isolate them. The semi-supervised version uses a small labeled set to adjust the scores, which steers the ranking toward anomaly patterns confirmed in your domain and gives a data-based basis for setting the threshold.
Can I include labeled normal examples as well as anomalies?
Yes, when they are available. Labeled normals show the model where ordinary behaviour lies, which can help separate borderline cases. How they enter the adjustment depends on the implementation, so check the documentation of the variant you use.
Should I use cross-validation to evaluate the model?
Yes, with care. Keep the labeled examples used for fitting or threshold selection out of the test evaluation, or use a separate held-out labeled set. Splitting the labeled portion in a stratified way, so that both classes appear in each fold, helps keep the evaluation stable.
What if my labeled anomalies are not representative?
Label guidance can work against you if the labeled anomalies cover only a narrow part of the anomaly distribution: the model may then rank novel anomaly types low. Pair the detector with unsupervised scoring and monitor for distributional drift after deployment.
Related methods
Sources
Görnitz, N., Kloft, M., Rieck, K., & Brefeld, U. (2013). Toward supervised anomaly detection. Journal of Artificial Intelligence Research, 46, 235–262.
Open publication referenceIsolation Forest. Wikipedia.
Open publication reference