Package mdp :: Package nodes :: Class LibSVMClassifier
[hide private]
[frames] | no frames]

Class LibSVMClassifier


The LibSVMClassifier class acts as a wrapper around the LibSVM library for support vector machines.

Information to the parameters can be found on http://www.csie.ntu.edu.tw/~cjlin/libsvm/

The class provides access to change kernel and svm type with a text string.

Additionally self.parameter is exposed which allows to change all other svm parameters directly.

This node depends on libsvm.

Instance Methods [hide private]
 
__init__(self, kernel=None, classifier=None, probability=True, params=None, input_dim=None, output_dim=None, dtype=None)
kernel -- The kernel to use classifier -- The type of the SVM params -- a dict of parameters to be passed to the svm_parameter probability -- Must be set to True, if algorithms based on probability shall be used.
 
_get_supported_dtypes(self)
Return the list of dtypes selfupported by this node.
 
_label(self, x)
 
_prob(self, x)
 
_stop_training(self)
Transform the data and labels lists to array objects and reshape them.
 
_train(self, x, labels)
Cumulate all input data in a one dimensional list.
 
label(self, x)
Returns an array with best class labels.
 
predict_probability(self, x)
 
prob(self, x)
Returns the probability for each datapoint and label (e.g., [{1:0.1, 2:0.0, 3:0.9}, {1:1.0, 2:0.0, 3:0.0}, ...])
 
set_classifier(self, classifier)
Sets the classifier.
 
set_kernel(self, kernel)
Sets the kernel.
 
stop_training(self)
Transform the data and labels lists to array objects and reshape them.
 
train(self, x, labels)
Cumulate all input data in a one dimensional list.

Inherited from PreserveDimNode (private): _set_input_dim, _set_output_dim

Inherited from unreachable.newobject: __long__, __native__, __nonzero__, __unicode__, next

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __subclasshook__

    Inherited from ClassifierCumulator
 
_check_train_args(self, x, labels)
    Inherited from ClassifierNode
 
_execute(self, x)
 
execute(self, x)
Process the data contained in x.
 
rank(self, x, threshold=None)
Returns ordered list with all labels ordered according to prob(x) (e.g., [[3 1 2], [2 1 3], ...]).
    Inherited from Node
 
__add__(self, other)
 
__call__(self, x, *args, **kwargs)
Calling an instance of Node is equivalent to calling its execute method.
 
__repr__(self)
repr(x)
 
__str__(self)
str(x)
 
_check_input(self, x)
 
_check_output(self, y)
 
_get_train_seq(self)
 
_if_training_stop_training(self)
 
_inverse(self, x)
 
_pre_execution_checks(self, x)
This method contains all pre-execution checks.
 
_pre_inversion_checks(self, y)
This method contains all pre-inversion checks.
 
_refcast(self, x)
Helper function to cast arrays to the internal dtype.
 
_set_dtype(self, t)
 
copy(self, protocol=None)
Return a deep copy of the node.
 
get_current_train_phase(self)
Return the index of the current training phase.
 
get_dtype(self)
Return dtype.
 
get_input_dim(self)
Return input dimensions.
 
get_output_dim(self)
Return output dimensions.
 
get_remaining_train_phase(self)
Return the number of training phases still to accomplish.
 
get_supported_dtypes(self)
Return dtypes supported by the node as a list of dtype objects.
 
has_multiple_training_phases(self)
Return True if the node has multiple training phases.
 
inverse(self, y, *args, **kwargs)
Invert y.
 
is_training(self)
Return True if the node is in the training phase, False otherwise.
 
save(self, filename, protocol=-1)
Save a pickled serialization of the node to filename. If filename is None, return a string.
 
set_dtype(self, t)
Set internal structures' dtype.
 
set_input_dim(self, n)
Set input dimensions.
 
set_output_dim(self, n)
Set output dimensions.
Static Methods [hide private]

Inherited from unreachable._SVMClassifier: is_invertible

    Inherited from Node
 
is_trainable()
Return True if the node can be trained, False otherwise.
Class Variables [hide private]
  classifiers = ['C_SVC', 'NU_SVC', 'ONE_CLASS', 'EPSILON_SVR', ...
  kernels = ['RBF', 'LINEAR', 'POLY', 'SIGMOID']
Properties [hide private]

Inherited from object: __class__

    Inherited from Node
  _train_seq
List of tuples:
  dtype
dtype
  input_dim
Input dimensions
  output_dim
Output dimensions
  supported_dtypes
Supported dtypes
Method Details [hide private]

__init__(self, kernel=None, classifier=None, probability=True, params=None, input_dim=None, output_dim=None, dtype=None)
(Constructor)

 

kernel -- The kernel to use
classifier -- The type of the SVM
params -- a dict of parameters to be passed to the svm_parameter
probability -- Must be set to True, if algorithms based on probability
               shall be used.

Overrides: object.__init__

_get_supported_dtypes(self)

 
Return the list of dtypes selfupported by this node.
Overrides: Node._get_supported_dtypes

_label(self, x)

 
Overrides: ClassifierNode._label

_prob(self, x)

 
Overrides: ClassifierNode._prob

_stop_training(self)

 
Transform the data and labels lists to array objects and reshape them.

Overrides: Node._stop_training

_train(self, x, labels)

 
Cumulate all input data in a one dimensional list.

Overrides: Node._train

label(self, x)

 

Returns an array with best class labels.

By default, subclasses should overwrite _label to implement their label. The docstring of the '_label' method overwrites this docstring.

Overrides: ClassifierNode.label

predict_probability(self, x)

 

prob(self, x)

 

Returns the probability for each datapoint and label (e.g., [{1:0.1, 2:0.0, 3:0.9}, {1:1.0, 2:0.0, 3:0.0}, ...])

By default, subclasses should overwrite _prob to implement their prob. The docstring of the '_prob' method overwrites this docstring.

Overrides: ClassifierNode.prob

set_classifier(self, classifier)

 

Sets the classifier.

classifier -- A string with the name of the classifier which
should be used. Possible values are in self.classifiers

set_kernel(self, kernel)

 

Sets the kernel.

kernel -- A string with the name of the classifier which
should be used. Possible values are in self.kernels

stop_training(self)

 
Transform the data and labels lists to array objects and reshape them.
Overrides: Node.stop_training

train(self, x, labels)

 
Cumulate all input data in a one dimensional list.
Overrides: Node.train

Class Variable Details [hide private]

classifiers

Value:
['C_SVC', 'NU_SVC', 'ONE_CLASS', 'EPSILON_SVR', 'NU_SVR']

kernels

Value:
['RBF', 'LINEAR', 'POLY', 'SIGMOID']