Categories &

Functions List

Class Definition: CompactClassificationSVM

statistics: CompactClassificationSVM

A CompactClassificationSVM object is a compact version of a support vectors machine model, CompactClassificationSVM.

The CompactClassificationSVM does not include the training data resulting to 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.

The available methods for a CompactClassificationSVM object are:

  • predict
  • loss
  • margin
  • savemodel

See also: fitcsvm, ClassificationSVM

Source Code: CompactClassificationSVM

Method: loss

CompactClassificationSVM: L = loss (obj, X, Y)
CompactClassificationSVM: L = loss (…, name, value)

Determine the classification error for a Support Vector Machine classifier.

L = loss (obj, X, Y) returns the predictive accuracy of support vector machine (SVM) classification models. Comparing the same type of loss across multiple models allows you to identify which model is more accurate, with a lower loss indicating superior predictive performance. It supports only binary classifier models.

  • obj must be a binary class CompactClassificationSVM object.
  • X must be an M×P numeric matrix with the same number of features P as the corresponding predictors of the SVM model in obj.
  • Y must be M×1 numeric vector containing the class labels corresponding to the predictor data in X. Y must have same number of rows as X.

L = loss (…, Name, Value) returns the aforementioned results with additional properties specified by Name-Value pair arguments listed below.

NameValue
"LossFun"Loss function, specified as a built-in loss function name. It accepts the following options: (Default is ’classiferror’)
  • ’binodeviance’: Binomial deviance: The binomial deviance loss function is used to evaluate the performance of a binary classifier. It is calculated as: L = \sum_j=1^n w_j \log \1 + \e×p [-2m_j]\
  • ’classiferror’: Misclassification rate in decimal The classification error measures the fraction of misclassified instances out of the total instances. It is calculated as: L = \frac1n \sum_j=1^n \mathbbI(m_j \leq 0)
  • ’exponential’: Exponential loss: The exponential loss function is used to penalize misclassified instances exponentially. It is calculated as: L = \sum_j=1^n w_j \e×p [-m_j]
  • ’hinge’: Hinge loss: The hinge loss function is often used for maximum-margin classification, particularly for support vector machines. It is calculated as: L = \sum_j=1^n w_j \ma× (0, 1 - m_j)
  • ’logit’: Logistic loss: The logistic loss function, also known as log loss, measures the performance of a classification model where the prediction is a probability value. It is calculated as: L = \sum_j=1^n w_j \log \1 + \e×p [-m_j]\
  • ’quadratic’: Quadratic loss: The quadratic loss function penalizes the square of the margin. It is calculated as: L = \sum_j=1^n w_j (1 - m_j)^2
"Weights"Specified as a numeric vector which weighs each observation (row) in X. The size of Weights must be equal to the number of rows in X. The default value is: ones(size(X,1),1)

See also: fitcsvm, ClassificationSVM

Method: margin

CompactClassificationSVM: m = margin (obj, X, Y)

Determine the classification margins for a Support Vector Machine classification object.

m = margin (obj, X, Y) returns the classification margins for the trained support vector machine (SVM) classifier obj using the sample data in X and the class labels in Y. It supports only binary classifier models. The classification margin is commonly defined as m = yf(x), where f(x) is the classification score and y is the true class label corresponding to x. A greater margin indicates a better model.

  • obj must be a binary class CompactClassificationSVM object.
  • X must be an M×P numeric matrix with the same number of features P as the corresponding predictors of the SVM model in obj.
  • Y must be M×1 numeric vector containing the class labels corresponding to the predictor data in X. Y must have same number of rows as X.

See also: fitcsvm, CompactClassificationSVM

Method: predict

CompactClassificationSVM: labels = predict (obj, XC)
CompactClassificationSVM: [labels, scores] = predict (obj, XC)

Classify new data points into categories using the Support Vector Machine classification object.

labels = predict (obj, XC) returns the vector of labels predicted for the corresponding instances in XC, using the trained Support Vector Machine classification compact model, obj. For one-class SVM model, +1 or -1 is returned.

  • obj must be a CompactClassificationSVM class object.
  • XC must be an M×P numeric matrix with the same number of predictors P as the corresponding predictors of the SVM model in obj.

[labels, scores] = predict (obj, XC also returns scores, which contains the desicion values for each each prediction. Alternatively, scores can contain the posterior probabilities if the ScoreTransform has been previously set using the fitPosterior method.

See also: fitcsvm, ClassificationSVM.fitPosterior

Method: savemodel

CompactClassificationSVM: savemodel (obj, filename)

Save a CompactClassificationSVM object.

savemodel (obj, filename) saves a CompactClassificationSVM object into a file defined by filename.

See also: loadmodel, fitcsvm, ClassificationSVM, CompactClassificationSVM