Multi Class Support Vector Machine Model. More...
#include <Svm.h>
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 | |
| KernelFunction * | getKernel () |
| 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 | |
| KernelFunction * | kernel |
| 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 | |
Multi Class Support Vector Machine Model.
.
can be used, or the corners of a symmetric simplex in
centered at the origin, which coincides with the labels
of the binary case.Definition at line 374 of file Svm.h.
| MultiClassSVM::MultiClassSVM | ( | KernelFunction * | pKernel, | |
| unsigned int | numberOfClasses, | |||
| bool | bOrthogonalVectors, | |||
| bool | bNumberOutput = true | |||
| ) |
Constructor.
| 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.
| 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 | ( | ) |
| double MultiClassSVM::getAlpha | ( | unsigned int | index, | |
| unsigned int | c | |||
| ) | const [inline] |
return the coefficient of a given example and label
| 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] |
| 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] |
| const Array<double>& MultiClassSVM::getPoints | ( | ) | [inline] |
| 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.
| 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 | ) |
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().
KernelFunction* MultiClassSVM::kernel [protected] |
kernel function
Definition at line 462 of file Svm.h.
Referenced by getKernel(), MultiClassSVM(), Normalize(), and Predict().
bool MultiClassSVM::numberOutput [protected] |
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().