All Products
Search
Document Center

Platform For AI:IForest Anomaly Detection

Last Updated:Apr 01, 2026

The IForest Anomaly Detection component detects outliers in tabular datasets using the Isolation Forest (IForest) algorithm. IForest works by randomly selecting a feature and splitting the data between the feature's minimum and maximum values — anomalous data points require fewer splits to isolate, producing shorter path lengths. The component uses subsampling to reduce computational complexity while maintaining detection accuracy.

Configure the component in Designer or through Python code using the PyAlink Script component.

How it works

IForest builds an ensemble of random decision trees. For each tree, it randomly selects a feature and a split value, then recursively partitions the data. Points that are isolated quickly (short paths) receive high outlier scores. After scoring all data points, the component applies an outlier threshold to label them as outliers or normal.

Two parameters directly control detection behavior:

  • Number of trees in the model (numTrees, default: 100) — more trees reduce score noise by averaging results across a larger ensemble. Start with the default value of 100; increase it if scores appear unstable across runs.

  • Number of rows sampled per tree (subsamplingSize, default: 256) — relates to the expected density of anomalies. Decrease this value if you expect a higher anomaly rate.

Configure the component

Use Designer

Configure the component parameters on the workflow page in Designer.

Fields setting

ParameterDescription
Feature columnsFeature columns for training. Mutually exclusive with Vector column and Tensor column — use only one to specify input features.
Group columnsColumns for grouping data.
Tensor columnName of the tensor column. Mutually exclusive with Vector column and Feature columns.
Vector columnName of the vector column. Mutually exclusive with Tensor column and Feature columns.

Parameter settings

ParameterDefaultRangeDescription
Prediction result columnName of the output column that stores the prediction result (outlier or normal).
Prediction details columnName of the output column that stores the raw outlier score for each data point.
Outlier score thresholdData points with scores above this value are labeled as outliers. A higher threshold means fewer points are flagged.
Maximum number of outliers per groupMaximum number of outliers to detect per group.
Maximum ratio of outliersMaximum proportion of data points that can be labeled as outliers. For example, set to 0.05 to flag at most 5% of data.
Maximum number of samples per groupMaximum number of samples per group.
Number of trees in the model100Number of trees in the ensemble. More trees reduce score noise.
Number of rows sampled per tree256[2, 100000]Rows sampled per tree.
Number of threads1Number of threads for the component.

Execution tuning

ParameterDefaultRangeDescription
Number of workers[1, 9999]Number of workers. Use with Memory per worker.
Memory per worker (MB)[1024, 65536]Memory allocated to each worker, in MB.

Use Python code

Configure parameters using the PyAlink Script component. For more information, see PyAlink Script.

Parameters

ParameterRequiredDefaultDescription
predictionColYesName of the output column for the prediction result.
predictionDetailColYesName of the output column for prediction details (raw outlier scores).
featureColsNoSelect AllFeature column names. Array type.
groupColsNoNoneGroup column names. Supports multiple columns.
outlierThresholdNoNoneOutlier score threshold. Points above this value are labeled as outliers.
maxOutlierRatioNoNoneMaximum proportion of points to label as outliers.
maxOutlierNumPerGroupNoNoneMaximum number of outliers per group.
maxSampleNumPerGroupNoNoneMaximum number of samples per group.
numTreesNo100Number of trees in the ensemble.
subsamplingSizeNo256Rows sampled per tree. Range: [2, 100000].
numThreadsNo1Number of threads.
tensorColNoNoneTensor column name.
vectorColNoNoneVector column name.

Example

The following example detects outliers in a small dataset using IForestOutlierBatchOp. It sets an outlierThreshold of 3.0 and specifies val as the only feature column. The prediction result is written to pred and the raw scores to pred_detail.

from pyalink.alink import *
import pandas as pd

df = pd.DataFrame([
    [0.73, 0],
    [0.24, 0],
    [0.63, 0],
    [0.55, 0],
    [0.73, 0],
    [0.41, 0]
])

dataOp = BatchOperator.fromDataframe(df, schemaStr='val double, label int')

outlierOp = IForestOutlierBatchOp()\
    .setFeatureCols(["val"])\
    .setOutlierThreshold(3.0)\
    .setPredictionCol("pred")\
    .setPredictionDetailCol("pred_detail")

outlierOp.print()

Constraints and guidance

  • Feature input is mutually exclusive: Set only one of Feature columns, Vector column, or Tensor column. Setting more than one causes an error.

  • Choosing a threshold: Outlier scores are dimensionless path-length metrics. If you do not have a prior expectation for the threshold, run the component once without setting outlierThreshold to inspect the score distribution in predictionDetailCol, then choose a cutoff based on the distribution.

  • Controlling the anomaly rate: Use maxOutlierRatio when you have a known or estimated anomaly rate in your dataset. This acts as a cap regardless of the threshold setting.

What's next