SCiForest<T>
Models & Types · AiDotNet.AnomalyDetection.TreeBased
Detects anomalies using SCiForest (Isolation Forest with Split-selection Criterion).
Inheritance: ModelBase<T, Matrix<T>, Vector<T>> → AnomalyDetectorBase<T> → SCiForest<T>
For Beginners
SCiForest improves on Isolation Forest for anomalies that come in small, tight groups (clustered anomalies). Instead of a random cut on one feature, every node tries several random oblique cuts and keeps the one that best separates the data into two tighter groups.
How It Works
The algorithm (Liu, Ting and Zhou, 2010) works by:
- Each tree is built from a random sub-sample of psi rows (without replacement)
- At each node, tau random hyper-planes f(x) = sum_j c_j x_j / sigma_j - p over q random attributes
(c_j uniform in [-1, 1], sigma_j the attribute’s standard deviation in the node) are tried, each with the split point p that maximizes Sdgain = (sigma(Y) - (sigma(Y_l) + sigma(Y_r)) / 2) / sigma(Y) of the projected values Y; the hyper-plane with the highest Sdgain splits the node (f < 0 left, f >= 0 right)
- Nodes are split until they hold at most two rows
- At evaluation, an edge only counts while f(x) stays inside the node’s acceptable range
[-v, v], v = max f - min f over the node’s training rows, which fences off unseen anomalies
- The anomaly score is s = 2^(-E[h(x)] / c(psi))
When to use:
- Clustered anomalies close to normal data
- When anomalies are only visible in combinations of features
- When standard Isolation Forest doesn’t perform well
Paper Defaults:
- Number of trees t: 100
- Sub-sample size psi: 256
- Attributes per hyper-plane q: 2
- Hyper-planes per node tau: 10
- Contamination: 0.1 (10%)
Reference: Liu, F.T., Ting, K.M., Zhou, Z.H. (2010). “On Detecting Clustered Anomalies Using SCiForest.” ECML PKDD 2010, LNCS 6322, pp. 274-290.
Constructors
| Constructor | Summary |
|---|---|
SCiForest(int numTrees, int maxSamples, int attributesPerHyperplane, int hyperplanesPerNode, double contamination, int randomSeed) |
Creates a new SCiForest anomaly detector. |
Properties
| Property | Summary |
|---|---|
int AttributesPerHyperplane { get; } |
Gets the number of attributes q combined in each random hyper-plane. |
int HyperplanesPerNode { get; } |
Gets the number of random hyper-planes tau tried at each node. |
int MaxSamples { get; } |
Gets the maximum samples per tree. |
int NumTrees { get; } |
Gets the number of trees in the forest. |
Methods
| Method | Summary |
|---|---|
Vector<T> ScoreAnomalies(Matrix<T> X) |
|
void Fit(Matrix<T> X) |