Main Content

Anomaly Detection

Detect outliers and novelties

Statistics and Machine Learning Toolbox™ provides several anomaly detection features for unlabeled multivariate sample data. 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
isanomalyFind anomalies in data using isolation forest
fitcsvmTrain support vector machine (SVM) classifier for one-class and binary classification
resubPredictClassify training data using trained classifier
predictClassify observations using support vector machine (SVM) classifier
robustcovRobust multivariate covariance and mean estimate
mahalMahalanobis distance to reference samples
pdist2Pairwise distance between two sets of observations

Objects

IsolationForestIsolation forest for anomaly detection
ClassificationSVMSupport vector machine (SVM) for one-class and binary classification

Topics

Unsupervised Anomaly Detection

Detect anomalies using isolation forest, one-class support vector machine (OCSVM), and Mahalanobis distance.

Anomaly Detection with Isolation Forest

Detect anomalies by isolating anomalies from normal points using an isolation forest (ensemble of isolation trees).

Model-Specific Anomaly Detection

After training a classification, regression, or clustering model, detect anomalies using a model-specific anomaly detection feature.