Table Of Contents

Previous topic

mvpa.clfs.libsvmc.sens

Next topic

mvpa.clfs.meta

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.

Note

Available state variables:

  • base_sensitivities: Stores basic sensitivities if the sensitivity relies on combining multiple ones
  • biases+: Offsets of separating hyperplanes
  • null_prob+: State variable
  • null_t: State variable
  • raw_result: Computed results before applying any transformation algorithm

(States enabled by default are listed with +)

See also

Please refer to the documentation of the base class for more information:

Sensitivity

Initialize the analyzer with the classifier it shall use.

Parameters:
  • clf (LinearSVM) – classifier to use. Only classifiers sub-classed from LinearSVM may be used.
  • enable_states (None or list of basestring) – Names of the state variables which should be enabled additionally to default ones
  • disable_states (None or list of basestring) – Names of the state variables which should be disabled
  • force_training (Bool) – if classifier was already trained – do not retrain
  • combiner (Functor) – The combiner is only applied if the computed featurewise dataset measure is more than one-dimensional. This is different from a transformer, which is always applied. By default, the sum of absolute values along the second axis is computed.

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.

Note

Available state variables:

  • feature_ids: Feature IDS which were used for the actual training.
  • predicting_time+: Time (in seconds) which took classifier to predict
  • predictions+: Most recent set of predictions
  • probabilities: Estimates of samples probabilities as provided by LibSVM
  • trained_dataset: The dataset it has been trained on
  • trained_labels+: Set of unique labels it has been trained on
  • training_confusion: Confusion matrix of learning performance
  • training_time+: Time (in seconds) which took classifier to train
  • values+: Internal classifier values the most recent predictions are based on

(States enabled by default are listed with +)

See also

Please refer to the documentation of the base class for more information:

_SVM

Interface class to LIBSVM classifiers and regressions.

Default implementation (C/nu/epsilon SVM) is chosen depending on the given parameters (C/nu/tube_epsilon).

SVM/SVR definition is dependent on specifying kernel, implementation type, and parameters for each of them which vary depending on the choices made.

Desired implementation is specified in svm_impl argument. Here is the list if implementations known to this class, along with specific to them parameters (described below among the rest of parameters), and what tasks it is capable to deal with (e.g. regression, binary and/or multiclass classification).

Implementations:
 
ONE_CLASS : one-class-SVM

Capabilities: oneclass

C_SVC : C-SVM classification

Parameters: C

Capabilities: binary, multiclass

NU_SVR : nu-SVM regression

Parameters: nu, tube_epsilon

Capabilities: regression

NU_SVC : nu-SVM classification

Parameters: nu

Capabilities: binary, multiclass

EPSILON_SVR : epsilon-SVM regression

Parameters: C, tube_epsilon

Capabilities: regression

Kernel choice is specified as a string argument kernel_type and it can be specialized with additional arguments to this constructor function. Some kernels might allow computation of per feature sensitivity.

Kernels:
rbf

gamma

linear : provides sensitivity

No parameters

poly

coef0, degree, gamma

sigmoid

coef0, gamma

Parameters:
  • tube_epsilon – Epsilon in epsilon-insensitive loss function of epsilon-SVM regression (SVR). (Default: 0.01)
  • C – Trade-off parameter between width of the margin and number of support vectors. Higher C – more rigid margin SVM. In linear kernel, negative values provide automatic scaling of their value according to the norm of the data. (Default: -1.0)
  • probability – Flag to signal either probability estimate is obtained within LIBSVM. (Default: 0)
  • degree – Degree of polynomial kernel. (Default: 3)
  • shrinking – Either shrinking is to be conducted. (Default: 1)
  • weight_label – To be used in conjunction with weight for custom per-label weight. (Default: [])
  • weight – Custom weights per label. (Default: [])
  • epsilon – Tolerance of termination criteria. (For nu-SVM default is 0.001). (Default: 5e-05)
  • cache_size – Size of the kernel cache, specified in megabytes. (Default: 100)
  • coef0 – Offset coefficient in polynomial and sigmoid kernels. (Default: 0.5)
  • nu – Fraction of datapoints within the margin. (Default: 0.5)
  • gamma – Scaling (width in RBF) within non-linear kernels. (Default: 0)
  • enable_states (None or list of basestring) – Names of the state variables which should be enabled additionally to default ones
  • disable_states (None or list of basestring) – Names of the state variables which should be disabled
  • kernel_type (basestr) – String must be a valid key for cls._KERNELS
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.