OneClassSVM
statistics: OneClassSVM
One-class support vector machine model for anomaly detection.
A OneClassSVM object stores a one-class support vector machine
fitted to a set of observations in an expanded feature space, and detects
anomalies through the isanomaly method. Create a OneClassSVM
object with ocsvm or the class constructor.
The model maps the data to a randomized feature space that approximates a Gaussian kernel and fits a linear boundary that encloses the bulk of the observations; points outside the boundary receive higher anomaly scores.
See also: ocsvm, OneClassSVM.isanomaly
Source Code: OneClassSVM
The OneClassSVM class contains the following properties:
The OneClassSVM class offers the following public methods:
OneClassSVM: Mdl = OneClassSVM (X)
OneClassSVM: Mdl = OneClassSVM (…, name, value)
Mdl = OneClassSVM (X) fits a one-class support vector
machine to the N-by-P matrix X, whose rows are
observations and columns are variables, and returns a OneClassSVM
object Mdl.
Mdl = OneClassSVM (…, name, value) takes
the following Name-Value pairs.
| Name | Value |
|---|---|
'KernelScale' | the scale of the approximated Gaussian
kernel, a positive scalar or 'auto' (default). |
'Lambda' | the ridge regularization strength, a
nonnegative scalar or 'auto' (default). |
'NumExpansionDimensions' | the number of expanded
feature dimensions, a positive integer or 'auto' (default). |
'StandardizeData' | a logical scalar (default
false); when true each predictor is centered and scaled and
the means and standard deviations are stored in Mdl.Mu and
Mdl.Sigma. |
'ContaminationFraction' | the assumed fraction of
anomalies in X, a scalar in [0, 1] (default 0). It sets
Mdl.ScoreThreshold to the 1 -
ContaminationFraction quantile of the anomaly scores of X;
when it is 0 the threshold is the maximum score and no training
observation is flagged. |
The feature expansion uses random projections, so the model depends on the state of the random number generator and is not reproducible across runs unless the generator is seeded.
ocsvm fits the same model and also returns the anomaly indicators
and the anomaly scores of the observations in X.
See also: ocsvm, OneClassSVM.isanomaly
OneClassSVM: tf = isanomaly (Mdl, Xnew)
OneClassSVM: [tf, scores] = isanomaly (Mdl, Xnew)
OneClassSVM: […] = isanomaly (…, 'ScoreThreshold', t)