iforest
Syntax
Description
Use the iforest
function to fit an isolation forest model for outlier
detection and novelty detection.
Outlier detection (detecting anomalies in training data) — Use the output argument
tf
ofiforest
to identify anomalies in training data.Novelty detection (detecting anomalies in new data with uncontaminated training data) — Create an
IsolationForest
object by passing uncontaminated training data (data with no outliers) toiforest
. Detect anomalies in new data by passing the object and the new data to the object functionisanomaly
.
returns an forest
= iforest(Tbl
)IsolationForest
object for predictor data in the table Tbl
.
specifies options using one or more name-value arguments in addition to any of the input
argument combinations in the previous syntaxes. For example,
forest
= iforest(___,Name=Value
)
instructs the function
to process 10% of the training data as anomalies.ContaminationFraction
=0.1
Examples
Input Arguments
Name-Value Arguments
Output Arguments
More About
Tips
After training a model, you can generate C/C++ code that finds anomalies for new data. Generating C/C++ code requires MATLAB® Coder™. For details, see Code Generation of the
isanomaly
function and Introduction to Code Generation.
Algorithms
iforest
considers NaN
, ''
(empty character vector), ""
(empty string), <missing>
, and <undefined>
values in Tbl
and NaN
values in X
to be missing values.
iforest
uses observations with missing values to find splits on
variables for which these observations have valid values. The function might place
these observations in a branch node, not a leaf node. Then
iforest
computes anomaly scores by using the
distance from the root node to the branch node. The function places an observation
with all missing values in the root node, so the score value becomes 1.
References
[1] Liu, F. T., K. M. Ting, and Z. Zhou. "Isolation Forest," 2008 Eighth IEEE International Conference on Data Mining. Pisa, Italy, 2008, pp. 413-422.
Extended Capabilities
Version History
Introduced in R2021b