Table Of Contents

Previous topic

mvpa.clfs.libsvmc.sens

Next topic

mvpa.clfs.model_selector

This Page

Quick search

mvpa.clfs.libsvmc.svm

Wrap the libsvm package into a very simple class interface.

The comprehensive API documentation for this module, including all technical details, is available in the Epydoc-generated API reference for mvpa.clfs.libsvmc.svm (for developers).

Classes

LinearSVMWeights

class mvpa.clfs.libsvmc.svm.LinearSVMWeights(clf, **kwargs)

Bases: mvpa.measures.base.Sensitivity

SensitivityAnalyzer for the LIBSVM implementation of a linear SVM.

Initialize the analyzer with the classifier it shall use.

Parameters:
  • clf (LinearSVM) – classifier to use. Only classifiers sub-classed from LinearSVM may be used.

See also

Derived classes might provide additional methods via their base classes. Please refer to the list of base classes (if it exists) at the begining of the LinearSVMWeights documentation.

Full API documentation of LinearSVMWeights in module mvpa.clfs.libsvmc.svm.

SVM

class mvpa.clfs.libsvmc.svm.SVM(kernel_type='linear', **kwargs)

Bases: mvpa.clfs._svmbase._SVM

Support Vector Machine Classifier.

This is a simple interface to the libSVM package.

This is the base class of all classifier that utilize the libSVM package underneath. It is not really meant to be used directly. Unless you know what you are doing it is most likely better to use one of the subclasses.

Here is the explaination for some of the parameters from the libSVM documentation:

svm_type can be one of C_SVC, NU_SVC, ONE_CLASS, EPSILON_SVR, NU_SVR.

  • C_SVC: C-SVM classification
  • NU_SVC: nu-SVM classification
  • ONE_CLASS: one-class-SVM
  • EPSILON_SVR: epsilon-SVM regression
  • NU_SVR: nu-SVM regression

kernel_type can be one of LINEAR, POLY, RBF, SIGMOID.

  • LINEAR: u'*v
  • POLY: (gamma*u'*v + coef0)^degree
  • RBF: exp(-gamma*|u-v|^2)
  • SIGMOID: tanh(gamma*u'*v + coef0)
  • PRECOMPUTED: kernel values in training_set_file

cache_size is the size of the kernel cache, specified in megabytes. C is the cost of constraints violation. (we usually use 1 to 1000) eps is the stopping criterion. (we usually use 0.00001 in nu-SVC, 0.001 in others). nu is the parameter in nu-SVM, nu-SVR, and one-class-SVM. p is the epsilon in epsilon-insensitive loss function of epsilon-SVM regression. shrinking = 1 means shrinking is conducted; = 0 otherwise. probability = 1 means model with probability information is obtained; = 0 otherwise.

nr_weight, weight_label, and weight are used to change the penalty for some classes (If the weight for a class is not changed, it is set to 1). This is useful for training classifier using unbalanced input data or with asymmetric misclassification cost.

Each weight[i] corresponds to weight_label[i], meaning that the penalty of class weight_label[i] is scaled by a factor of weight[i].

If you do not want to change penalty for any of the classes, just set nr_weight to 0.

model
summary()
Provide quick summary over the SVM classifier
untrain()

See also

Derived classes might provide additional methods via their base classes. Please refer to the list of base classes (if it exists) at the begining of the SVM documentation.

Full API documentation of SVM in module mvpa.clfs.libsvmc.svm.