trains a svm model
model = libsvm_svmtrain(training_label_vector, training_instance_matrix); model = libsvm_svmtrain(training_label_vector, training_instance_matrix,libsvm_options); crossvalidationResult = libsvm_svmtrain(training_label_vector, training_instance_matrix,".. -v n");
set type of SVM (default 0)
C-SVC (class seperation)
nu-SVC (nu - classification)
one-class SVM (one-class-classification)
epsilon-SVR (epsilon - regression)
nu-SVR (nu - regression)
set type of kernel function (default 2)
u'*v
(gamma*u'*v + coef0)^degree
exp(-gamma*|u-v|^2)
tanh(gamma*u'*v + coef0)
(kernel values in training_instance_matrix)
set degree in kernel function (default 3)
set gamma in kernel function (default 1/num_features)
set coef0 in kernel function (default 0)
set the parameter C of C-SVC, epsilon-SVR, and nu-SVR (default 1)
set the parameter nu of nu-SVC, one-class SVM, and nu-SVR (default 0.5)
set the epsilon in loss function of epsilon-SVR (default 0.1)
set cache memory size in MB (default 100)
set tolerance of termination criterion (default 0.001)
whether to use the shrinking heuristics, 0 or 1 (default 1)
whether to train a SVC or SVR model for probability estimates, 0 or 1 (default 0)
set the parameter C of class i to weight*C, for C-SVC and nu-SVC (default 1)
n-fold cross validation mode
quiet mode (no outputs)
parameters
number of classes; = 2 for regression/one-class svm
total #SV
-b of the decision function(s) wx+b
label of each class; empty for regression/one-class SVM
sv_indices[0,...,nSV-1] are values in [1,...,num_traning_data] to indicate SVs in the training set
pairwise probability information; empty if -b 0 or in one-class SVM
pairwise probability information; empty if -b 0 or in one-class SVM
number of SVs for each class; empty for regression/one-class SVM
coefficients for SVs in decision functions
support vectors
[Cross Validation Accuracy, Positive Cross Validation Accuracy, Negative Cross Validation Accuracy]
svm types:
Class separation (-s 0): optimal separating hyperplane between the two classes by maximizing the margin between the classes’ closest points the points lying on the boundaries are called support vectors, and the middle of the margin is our optimal separating hyperplane
nu-Classification (-s 1): this model allows for more control over the number of support vectors by specifying an additional parameter (-n nu) which approximates the fraction of support vectors.
one-class-classification ( -s 2): this model tries to find the support of a distribution and thus allows for outlier/novelty detection
epsilon-regression ( -s 3): here, the data points lie in between the two borders of the margin which is maximized under suitable conditions to avoid outlier inclusion.
nu-regression ( -s 4): With one additional parameter (-n nu) which approximates the fraction of support vectors
Crossvalidation:
to assess the quality of the training result, a k-fold cross-classification on the training data can be performed by setting the parameter (-v ) to n (default: 0). This option -v randomly splits the data into n parts and calculates crossvalidation accuracy/mean squared error on them. The returned model is just a vector: [Cross Validation Accuracy, Positive Cross Validation Accuracy, Negative Cross Validation Accuracy].
Scaling:
Scale your data. For example, scale each column of the instance matrix to [0,1] or [-1,+1].
Output:
The 'svmtrain' function returns a model which can be used for future prediction. It is a structure and is organized as [Parameters, nr_class, totalSV, rho, Label, ProbA, ProbB, nSV, sv_coef, SVs]:
If you do not use the option '-b 1', ProbA and ProbB are empty matrices