Main Content

Anomaly Detection

Detect outliers and novelties

Statistics and Machine Learning Toolbox™ provides several anomaly detection features for unlabeled multivariate sample data. You can also detect anomalies in streaming data using one-class support vector machine (SVM) and robust random cut forest algorithms (see Incremental Anomaly Detection Overview). The anomaly detection features detect outliers (anomalies in training data) either by training a model or by learning parameters. For novelty detection (detecting anomalies in new data with uncontaminated training data), you train a model or learn parameters with uncontaminated training data (data with no outliers) and detect anomalies in new data by using the trained model or learned parameters. For more details, see Unsupervised Anomaly Detection.

If you have training data labeled as normal points and anomalies, you can train a binary classification model and use the resubPredict and predict object functions to detect anomalies in the training data and new data, respectively. For the list of supported classification features, see Classification.

The toolbox also provides model-specific anomaly detection features that you can apply after training a classification, regression, or clustering model. For details, see Model-Specific Anomaly Detection.

Functions

expand all

iforestFit isolation forest for anomaly detection (Since R2021b)
isanomalyFind anomalies in data using isolation forest (Since R2021b)
rrcforestFit robust random cut forest model for anomaly detection (Since R2023a)
isanomalyFind anomalies in data using robust random cut forest (Since R2023a)
lofCreate local outlier factor model for anomaly detection (Since R2022b)
isanomalyFind anomalies in data using local outlier factor (Since R2022b)
ocsvmFit one-class support vector machine (SVM) model for anomaly detection (Since R2022b)
isanomalyFind anomalies in data using one-class support vector machine (SVM) (Since R2022b)
robustcovRobust multivariate covariance and mean estimate
mahalMahalanobis distance to reference samples
pdist2Pairwise distance between two sets of observations
incrementalRobustRandomCutForestRobust random cut forest model for incremental anomaly detection (Since R2023b)
incrementalLearnerConvert robust random cut forest model to incremental learner (Since R2023b)
fitTrain robust random cut forest model for incremental anomaly detection (Since R2023b)
isanomalyFind anomalies in data using robust random cut forest (RRCF) for incremental learning (Since R2023b)
resetReset incremental robust random cut forest model (Since R2023b)
incrementalOneClassSVM One-class support vector machine (SVM) model for incremental anomaly detection (Since R2023b)
incrementalLearnerConvert one-class SVM model to incremental learner (Since R2023b)
fitTrain one-class SVM model for incremental anomaly detection (Since R2023b)
isanomalyFind anomalies in data using one-class support vector machine (SVM) for incremental learning (Since R2023b)
resetReset incremental one-class SVM model (Since R2023b)

Objects

IsolationForestIsolation forest for anomaly detection (Since R2021b)
RobustRandomCutForestRobust random cut forest model for anomaly detection (Since R2023a)
LocalOutlierFactorLocal outlier factor model for anomaly detection (Since R2022b)
OneClassSVMOne-class support vector machine (SVM) for anomaly detection (Since R2022b)

Topics

Related Information