CompactClassificationSVM
statistics: CompactClassificationSVM
Compact Support Vector Machine classification
The CompactClassificationSVM class implements a compact version of a
Support Vector Machine classifier object for one-class or two-class problems,
which can predict responses for new data using the predict method.
A CompactClassificationSVM object is a compact version of a support
vector machine model, ClassificationSVM. It does not include the
training data resulting in a smaller classifier size, which can be used for
making predictions from new data, but not for tasks such as cross validation.
It can only be created from a ClassificationSVM model by using the
compact object method.
See also: ClassificationSVM
Source Code: CompactClassificationSVM
A positive integer value specifying the number of predictors in the training dataset used for training the SVM model. This property is read-only.
A cell array of character vectors specifying the names of the predictor variables. The names are in the order in which the appear in the training dataset. This property is read-only.
A character vector specifying the name of the response variable Y. This property is read-only.
An array of unique values of the response variable Y, which has the
same data types as the data in Y. This property is read-only.
ClassNames can have any of the following datatypes:
Specified as a function handle for transforming the classification
scores. Add or change the ScoreTransform property using dot
notation as in:
obj.ScoreTransform = 'function_name'
obj.ScoreTransform = @function_handle
When specified as a character vector, it can be any of the following
built-in functions. Nevertherless, the ScoreTransform property
always stores their function handle equivalent.
| Value | Description | |
|---|---|---|
"doublelogit" | ||
"invlogit" | ||
"ismax" | Sets the score for the class with the largest score to 1, and for all other classes to 0 | |
"logit" | ||
"none" | (no transformation) | |
"identity" | (no transformation) | |
"sign" | ||
"symmetric" | ||
"symmetricismax" | Sets the score for the class with the largest score to 1, and for all other classes to -1 | |
"symmetriclogit" |
A boolean flag indicating whether the data in X have been standardized prior to training. This property is read-only.
A numeric vector of the same length as the columns in X containing
the standard deviations of predictor variables. If the predictor
variables have not been standardized, then Sigma is empty.
This property is read-only.
A numeric vector of the same length as the columns in X containing
the means of predictor variables. If the predictor variables have not
been standardized, then Mu is empty. This property is read-only.
A structure containing the parameters used to train the SVM model with
the following fields: SVMtype, BoxConstraint,
CacheSize, KernelScale, KernelOffset,
KernelFunction, PolynomialOrder, Nu,
Tolerance, and Shrinking. This property is read-only.
A structure containing the trained model in 'libsvm' format.
This property is read-only.
The coefficients of the trained SVM classifier specified as an
numeric vector, where is the number of support vectors equal to
sum (obj.IsSupportVector). If the SVM classifier was trained
with a kernel function other than 'linear', then Alpha is
empty. This property is read-only.
The linear predictor coefficients specified as an numeric
vector, where is the number of support vectors equal to
sum (obj.IsSupportVector). If the SVM classifier was trained
with a 'linear' kernel function, then Beta is empty.
This property is read-only.
The bias term specified as a scalar. This property is read-only.
An logical vector that flags whether a corresponding observation in the predictor data matrix is a Support Vector. is the number of observations in the training data. This property is read-only.
The support vector class labels specified as an numeric
vector, where is the number of support vectors equal to
sum (obj.IsSupportVector). A value of +1 in
SupportVectorLabels indicates that the corresponding support
vector belongs to the positive class (ClassNames{2}). A value
of -1 indicates that the corresponding support vector belongs to the
negative class (ClassNames{1}). This property is read-only.
The support vectors of the trained SVM classifier specified an
numeric matrix, where is the number of support vectors equal to
sum (obj.IsSupportVector), and is the number of
predictor variables in the predictor data. This property is read-only.
CompactClassificationSVM: label = predict (obj, XC)
CompactClassificationSVM: [label, score] = predict (obj, XC)
label = predict (obj, XC) returns the vector of
labels predicted for the corresponding instances in XC, using the
predictor data in the CompactClassificationSVM model, obj. For
one-class SVM model, +1 or -1 is returned.
CompactClassificationSVM class object.
[label, score] = predict (obj, XC) also
returns score, which contains the decision values for each each
prediction. Alternatively, score can contain the posterior
probabilities if the ScoreTransform has been previously set using the
fitPosterior method.
See also: CompactClassificationSVM, ClassificationSVM
CompactClassificationSVM: m = margin (obj, X, Y)
m = margin (obj, X, Y) returns
the classification margins for obj with data X and
classification Y. m is a numeric vector of length size (X,1).
The classification margin for each observation is the difference between the classification score for the true class and the maximal classification score for the false classes.
See also: CompactClassificationSVM
CompactClassificationSVM: L = loss (obj, X, Y)
CompactClassificationSVM: L = loss (…, name, value)
L = loss (obj, X, Y) computes the loss,
L, using the default loss function 'classiferror'.
obj is a CompactClassificationSVM object.
X must be a numeric matrix of input data where rows
correspond to observations and columns correspond to features or
variables.
Y is matrix or cell matrix containing the class labels
of corresponding predictor data in X. Y must have same
numbers of Rows as X.
L = loss (…, name, value) allows
additional options specified by name-value pairs:
| Name | Value | |
|---|---|---|
"LossFun" | Specifies the loss function to use.
Can be a function handle with four input arguments (C, S, W, Cost)
which returns a scalar value or one of:
’binodeviance’, ’classifcost’, ’classiferror’, ’exponential’,
’hinge’, ’logit’,’mincost’, ’quadratic’.
| |
"Weights" | Specifies observation weights, must be
a numeric vector of length equal to the number of rows in X.
Default is ones (size (X, 1)). loss normalizes the weights so that
observation weights in each class sum to the prior probability of that
class. When you supply Weights, loss computes the weighted
classification loss. |
See also: CompactClassificationSVM
CompactClassificationSVM: savemodel (obj, filename)
savemodel (obj, filename) saves each property of a
CompactClassificationSVM object into an Octave binary file, the name of
which is specified in filename, along with an extra variable,
which defines the type classification object these variables constitute.
Use loadmodel in order to load a classification object into
Octave’s workspace.
See also: loadmodel, ClassificationSVM, CompactClassificationSVM
# and compare their size load fisheriris X = meas; Y = species; selected_classes = unique (Y)(randperm (3, 2)); selected_indices = ismember (Y, selected_classes); X_selected = X(selected_indices, :); Y_selected = Y(selected_indices); Mdl = fitcsvm (X_selected, Y_selected, 'ClassNames', selected_classes); CMdl = crossval (Mdl) |
CMdl =
ClassificationPartitionedModel object with properties:
BinEdges: []
CategoricalPredictors: []
X: [5.1000, 3.5000, 1.4000, 0.2000; 4.9000, 3, 1.4000, 0.2000; 4.7000, 3.2000, ...]
Y: [100x1 cell]
ClassNames: [2x1 cell]
Cost: []
CrossValidatedModel: 'ClassificationSVM'
KFold: 10
ModelParameters: [1x1 struct]
NumObservations: 100
Partition: [1x1 cvpartition]
PredictorNames: [1x4 cell]
Prior: []
ResponseName: "Y"
ScoreTransform: [1x1 function_handle]
Standardize: 0
Trained: [10x1 cell]
|