MultiClassSVM Class Reference

Multi Class Support Vector Machine Model. More...

#include <Svm.h>

Inheritance diagram for MultiClassSVM:
Model

List of all members.

Public Member Functions

 MultiClassSVM (KernelFunction *pKernel, unsigned int numberOfClasses, bool bOrthogonalVectors, bool bNumberOutput=true)
 Constructor.
 MultiClassSVM (KernelFunction *pKernel, Array< double > prototypes, bool bNumberOutput=true)
 Constructor.
 ~MultiClassSVM ()
 Destructor.
void SetTrainingData (const Array< double > &input, bool copy=false)
 Make the training data known to the SVM.
void model (const Array< double > &input, Array< double > &output)
 compute the SVM prediction on data
unsigned int model (const Array< double > &input)
 compute the SVM prediction on data
void Normalize ()
 normalize the class-wise decision functions
KernelFunctiongetKernel ()
 return the kernel function object
const Array< double > & getPoints ()
 return the training data points
double getAlpha (unsigned int index, unsigned int c) const
 return the coefficient of a given example and label
double getOffset (unsigned int c) const
 return the solution offset vector
unsigned int getClasses () const
 return the number of classes
const ArrayReference< double > getClassPrototype (unsigned int c) const
 return the class representing prototype vector
unsigned int VectorToClass (const Array< double > &v)
 convert a label vector into a class index

Protected Member Functions

void Predict (const Array< double > &input, Array< double > &output)
void Predict (const Array< double > &input, ArrayReference< double > output)

Protected Attributes

KernelFunctionkernel
 kernel function
bool bOwnMemory
 true if x and y are allocated by LoadModel
const Array< double > * x
 training data points
bool numberOutput
 true if the SVM outputs the class label only false if the SVM outputs the value of the linear feature space function.
unsigned int examples
 number of training data points and labels
unsigned int classes
 number of classes
Array< double > prototypes
 vectors associated with the classes

Detailed Description

Multi Class Support Vector Machine Model.

Author:
T. Glasmachers
Date:
2007
The MultiClassSVM class provides a Support Vector
Machine as a parametric Model, that is, it computes a linear expansion of the kernel function with fixed training examples as one component. It can be viewed as a parametrized family of maps from the input space to the output space. In this formulation the output space is some $ R^n $.
In constrast to the binary classification or
regression SVM the MultiClassSVM maps inputs not to the reals but to a vector space. For each class there exists a prototype label vector in this space. The classifier predicts the class label whose prototype vector has the largest inner product to the output vector. That is, the label prototype most similar to the output vector is used for prediction.
Due to the fact that the number of classes is
always finite we use the linear kernel on the outputs without loss of generality. However, there are two concurrent standard initializations of the label prototypes: Either the standard basis of $ R^n $ can be used, or the corners of a symmetric simplex in $ R^{n-1} $ centered at the origin, which coincides with the labels $ \pm 1 \in R $ of the binary case.
The parameters of this machine are organized
into one decision function per class. Therefore there exist as many parameters as there are training examples times classes. For some formulations of multi class SVMs some of these are dummy variables which are always zero. Furthermore, for most training procedures available by now the offset or bias term is set to zero.

Definition at line 374 of file Svm.h.


Constructor & Destructor Documentation

MultiClassSVM::MultiClassSVM ( KernelFunction pKernel,
unsigned int  numberOfClasses,
bool  bOrthogonalVectors,
bool  bNumberOutput = true 
)

Constructor.

Parameters:
pKernel input space kernel
numberOfClasses number of classes with indices starting from 0
bOrthogonalVectors true: standard basis prototypes; false: simplex prototypes
bNumberOutput true: output class index; false: output vector

Definition at line 702 of file Svm.cpp.

References bOwnMemory, classes, examples, i, Model::inputDimension, kernel, numberOutput, Model::outputDimension, prototypes, and x.

MultiClassSVM::MultiClassSVM ( KernelFunction pKernel,
Array< double >  prototypes,
bool  bNumberOutput = true 
)

Constructor.

Parameters:
pKernel input space kernel
prototypes label prototype vectors
bNumberOutput true: output class index; false: output vector

Definition at line 727 of file Svm.cpp.

References bOwnMemory, classes, examples, Model::inputDimension, kernel, numberOutput, Model::outputDimension, and x.

MultiClassSVM::~MultiClassSVM (  ) 

Destructor.

Definition at line 744 of file Svm.cpp.

References bOwnMemory, and x.


Member Function Documentation

double MultiClassSVM::getAlpha ( unsigned int  index,
unsigned int  c 
) const [inline]

return the coefficient of a given example and label

Parameters:
index index of the corresponding training example
c zero-based class index (0, ..., classes-1)

Definition at line 429 of file Svm.h.

References classes, and Model::parameter.

Referenced by Predict().

unsigned int MultiClassSVM::getClasses (  )  const [inline]

return the number of classes

Definition at line 442 of file Svm.h.

References classes.

Referenced by SVM_Optimizer::optimize().

const ArrayReference<double> MultiClassSVM::getClassPrototype ( unsigned int  c  )  const [inline]

return the class representing prototype vector

Parameters:
c zero-based class index (0, ..., classes-1)

Definition at line 449 of file Svm.h.

KernelFunction* MultiClassSVM::getKernel (  )  [inline]

return the kernel function object

Definition at line 415 of file Svm.h.

References kernel.

Referenced by MetaSVM::MetaSVM(), and SVM_Optimizer::optimize().

double MultiClassSVM::getOffset ( unsigned int  c  )  const [inline]

return the solution offset vector

Parameters:
c zero-based class index (0, ..., classes-1)

Definition at line 436 of file Svm.h.

References classes, examples, and Model::parameter.

Referenced by Predict().

const Array<double>& MultiClassSVM::getPoints (  )  [inline]

return the training data points

Definition at line 421 of file Svm.h.

References x.

unsigned int MultiClassSVM::model ( const Array< double > &  input  ) 

compute the SVM prediction on data

Definition at line 816 of file Svm.cpp.

References classes, Model::inputDimension, Predict(), and VectorToClass().

void MultiClassSVM::model ( const Array< double > &  input,
Array< double > &  output 
) [virtual]

compute the SVM prediction on data

Implements Model.

Definition at line 773 of file Svm.cpp.

References classes, i, numberOutput, Predict(), and VectorToClass().

void MultiClassSVM::Normalize (  ) 

normalize the class-wise decision functions

Definition at line 826 of file Svm.cpp.

References classes, KernelFunction::eval(), examples, i, kernel, Model::parameter, and x.

void MultiClassSVM::Predict ( const Array< double > &  input,
ArrayReference< double >  output 
) [protected]

Definition at line 903 of file Svm.cpp.

References classes, KernelFunction::eval(), examples, getAlpha(), getOffset(), kernel, prototypes, and x.

void MultiClassSVM::Predict ( const Array< double > &  input,
Array< double > &  output 
) [protected]

Definition at line 876 of file Svm.cpp.

References classes, KernelFunction::eval(), examples, getAlpha(), getOffset(), kernel, prototypes, and x.

Referenced by model().

void MultiClassSVM::SetTrainingData ( const Array< double > &  input,
bool  copy = false 
)

Make the training data known to the SVM.

The training data are needed in order to represent the SVM model because the parameter vector stores only coefficients relative to these data.

Parameters:
input training data points
copy maintain a copy of the input data

Definition at line 750 of file Svm.cpp.

References bOwnMemory, classes, examples, Model::inputDimension, Model::parameter, and x.

Referenced by SVM_Optimizer::optimize().

unsigned int MultiClassSVM::VectorToClass ( const Array< double > &  v  ) 

convert a label vector into a class index

Definition at line 851 of file Svm.cpp.

References classes, i, and prototypes.

Referenced by model().


Member Data Documentation

bool MultiClassSVM::bOwnMemory [protected]

true if x and y are allocated by LoadModel

Definition at line 465 of file Svm.h.

Referenced by MultiClassSVM(), SetTrainingData(), and ~MultiClassSVM().

unsigned int MultiClassSVM::classes [protected]

number of classes

Definition at line 478 of file Svm.h.

Referenced by getAlpha(), getClasses(), getOffset(), model(), MultiClassSVM(), Normalize(), Predict(), SetTrainingData(), and VectorToClass().

unsigned int MultiClassSVM::examples [protected]

number of training data points and labels

Definition at line 475 of file Svm.h.

Referenced by getOffset(), MultiClassSVM(), Normalize(), Predict(), and SetTrainingData().

kernel function

Definition at line 462 of file Svm.h.

Referenced by getKernel(), MultiClassSVM(), Normalize(), and Predict().

bool MultiClassSVM::numberOutput [protected]

true if the SVM outputs the class label only false if the SVM outputs the value of the linear feature space function.

Definition at line 472 of file Svm.h.

Referenced by model(), and MultiClassSVM().

Array<double> MultiClassSVM::prototypes [protected]

vectors associated with the classes

Definition at line 481 of file Svm.h.

Referenced by MultiClassSVM(), Predict(), and VectorToClass().

const Array<double>* MultiClassSVM::x [protected]

training data points

Definition at line 468 of file Svm.h.

Referenced by getPoints(), MultiClassSVM(), Normalize(), Predict(), SetTrainingData(), and ~MultiClassSVM().


The documentation for this class was generated from the following files: