#include <Svm.h>

Public Member Functions | |
| SVM (KernelFunction *pKernel, bool bSignOutput=false) | |
| Constructor. | |
| SVM (KernelFunction *pKernel, const Array< double > &input, bool bSignOutput=false) | |
| Constructor. | |
| ~SVM () | |
| Destructor. | |
| void | SetTrainingData (const Array< double > &input, bool copy=false) |
| void | model (const Array< double > &input, Array< double > &output) |
| compute the SVM prediction on data | |
| double | model (const Array< double > &input) |
| compute the SVM prediction on data | |
| void | modelDerivative (const Array< double > &input, Array< double > &derivative) |
| void | modelDerivative (const Array< double > &input, Array< double > &output, Array< double > &derivative) |
| double | getAlpha (int index) |
| double | getOffset () |
| KernelFunction * | getKernel () |
| return the kernel function object | |
| const Array< double > & | getPoints () |
| return the training data points | |
| unsigned int | getExamples () |
| return the number of training examples | |
| unsigned int | getDimension () |
| return the input space dimension | |
| void | MakeSparse () |
| Discard zero coefficients and corresponding training data. | |
| bool | LoadSVMModel (std::istream &is) |
| bool | SaveSVMModel (std::ostream &os) |
Static Public Member Functions | |
| static SVM * | ImportLibsvmModel (std::istream &is) |
| static SVM * | ImportSvmlightModel (std::istream &is) |
Static Protected Member Functions | |
| static int | ReadToken (std::istream &is, char *buffer, int maxlength, const char *separators) |
| Read a token from a stream. | |
| static int | DiscardUntil (std::istream &is, const char *separators) |
| Discard characters with stopping condition. | |
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 | signOutput |
true if the SVM outputs the binary label only, false if the SVM outputs the value of the linear feature space function. | |
| unsigned int | examples |
| number of training data points x and labels y | |
Friends | |
| class | SvmApproximation |
and a real valued offset b. Note that different SVM training procedures impose constraints on the possible values these parameters are allowed to take.CrossValidation.cpp, KernelOptimization.cpp, SvmApproximationExample.cpp, SVMclassification-gnuplot.cpp, SVMclassification.cpp, SVMregression-gnuplot.cpp, and SVMregression.cpp.
Definition at line 88 of file Svm.h.
| SVM::SVM | ( | KernelFunction * | pKernel, | |
| bool | bSignOutput = false | |||
| ) |
Constructor.
| pKernel | kernel function to use for training and prediction | |
| bSignOutput | true if the SVM should output binary labels, false if it should output real valued function evaluations |
Definition at line 57 of file Svm.cpp.
References bOwnMemory, examples, Model::inputDimension, kernel, Model::outputDimension, Model::parameter, signOutput, and x.
Referenced by ImportLibsvmModel(), and ImportSvmlightModel().
| SVM::SVM | ( | KernelFunction * | pKernel, | |
| const Array< double > & | input, | |||
| bool | bSignOutput = false | |||
| ) |
Constructor.
| pKernel | kernel function to use for training and prediction | |
| input | training data points | |
| bSignOutput | true if the SVM should output binary labels, false if it should output real valued function evaluations |
Definition at line 73 of file Svm.cpp.
References bOwnMemory, examples, Model::inputDimension, kernel, Model::outputDimension, SetTrainingData(), signOutput, and x.
| SVM::~SVM | ( | ) |
| int SVM::DiscardUntil | ( | std::istream & | is, | |
| const char * | separators | |||
| ) | [static, protected] |
Discard characters with stopping condition.
| is | stream to read from | |
| separators | termination characters |
Definition at line 685 of file Svm.cpp.
Referenced by ImportSvmlightModel().
| double SVM::getAlpha | ( | int | index | ) | [inline] |

Definition at line 180 of file Svm.h.
References Model::parameter.
Referenced by SvmApproximation::addVecFixPointIteration(), SvmApproximation::calcOffsetForReducedModel(), SvmApproximation::calcOptimalAlphaOfApproximatedSVM(), SvmApproximation::chooseVectorForNextIteration(), SvmApproximation::createIndexListWithKMeans(), SvmApproximation::createIndexListWithStochasticUniversalSampling(), SvmApproximation::error(), SpanBound1::error(), SpanBound::error(), SvmApproximationErrorFunctionGlobal::errorDerivative(), SvmApproximationErrorFunction::errorDerivative(), SpanBound1::errorDerivative(), SvmApproximation::getClassificationRateOnSVsCorrectlyClassifiedByOrigSVM(), SvmApproximation::gradientDescent(), C_SVM::modelDerivative(), C_SVM::PrepareDerivative(), and SvmApproximation::SvmApproximation().
| unsigned int SVM::getDimension | ( | ) | [inline] |
return the input space dimension
Definition at line 216 of file Svm.h.
References Model::inputDimension.
Referenced by SvmApproximationErrorFunctionGlobal::errorDerivative(), SvmApproximationErrorFunction::errorDerivative(), and SvmApproximation::SvmApproximation().
| unsigned int SVM::getExamples | ( | ) | [inline] |
return the number of training examples
Definition at line 210 of file Svm.h.
References examples.
Referenced by GaussianProcessEvidence::dEvidenceDTheta(), SpanBound1::error(), GaussianProcessVariance::error(), SvmApproximationErrorFunctionGlobal::errorDerivative(), SvmApproximationErrorFunction::errorDerivative(), SpanBound1::errorDerivative(), GaussianProcessEvidence::evidence(), MakeSparse(), C_SVM::modelDerivative(), C_SVM::PrepareDerivative(), and SvmApproximation::SvmApproximation().
| KernelFunction* SVM::getKernel | ( | ) | [inline] |
return the kernel function object
Definition at line 198 of file Svm.h.
References kernel.
Referenced by SpanBound1::bound(), SpanBound1::boundDerivative(), GaussianProcessEvidence::dEvidenceDTheta(), NegativePolarization::error(), LOO::error(), NegativeBKTA::error(), NegativeKTA::error(), GaussianProcessVariance::error(), SvmApproximationErrorFunctionGlobal::errorDerivative(), SvmApproximationErrorFunction::errorDerivative(), RadiusMargin::errorDerivative(), NegativePolarization::errorDerivative(), NegativeBKTA::errorDerivative(), NegativeKTA::errorDerivative(), MetaSVM::MetaSVM(), SVM_Optimizer::optimize(), RadiusMargin::solveProblems(), and SvmApproximation::SvmApproximation().
| double SVM::getOffset | ( | ) | [inline] |

Definition at line 192 of file Svm.h.
References examples, and Model::parameter.
Referenced by SvmApproximation::calcOffsetForReducedModel(), and C_SVM::PrepareDerivative().
| const Array<double>& SVM::getPoints | ( | ) | [inline] |
return the training data points
Definition at line 204 of file Svm.h.
References x.
Referenced by SvmApproximation::addVecFixPointIteration(), SvmApproximation::calcOffsetForReducedModel(), SvmApproximation::calcOptimalAlphaOfApproximatedSVM(), SvmApproximation::chooseVectorForNextIteration(), SvmApproximation::createIndexListWithKMeans(), GaussianProcessEvidence::dEvidenceDTheta(), SvmApproximation::error(), GaussianProcessVariance::error(), SvmApproximationErrorFunctionGlobal::errorDerivative(), SvmApproximationErrorFunction::errorDerivative(), SvmApproximation::getClassificationRateOnSVsCorrectlyClassifiedByOrigSVM(), C_SVM::modelDerivative(), and C_SVM::PrepareDerivative().
| SVM * SVM::ImportLibsvmModel | ( | std::istream & | is | ) | [static] |
Definition at line 346 of file Svm.cpp.
References bOwnMemory, examples, i, Model::inputDimension, Model::parameter, ReadToken(), Model::setParameter(), PolynomialKernel::setParameter(), SVM(), and x.
| SVM * SVM::ImportSvmlightModel | ( | std::istream & | is | ) | [static] |
Definition at line 503 of file Svm.cpp.
References bOwnMemory, DiscardUntil(), examples, i, Model::inputDimension, kernel, Model::parameter, ReadToken(), SVM(), and x.
| bool SVM::LoadSVMModel | ( | std::istream & | is | ) |
Definition at line 221 of file Svm.cpp.
References bOwnMemory, examples, Model::inputDimension, Model::parameter, and x.
| void SVM::MakeSparse | ( | ) |
Discard zero coefficients and corresponding training data.
Definition at line 627 of file Svm.cpp.
References bOwnMemory, examples, getExamples(), i, Model::parameter, and x.
Referenced by SVM_Optimizer::optimize().
| double SVM::model | ( | const Array< double > & | input | ) |
compute the SVM prediction on data
Definition at line 159 of file Svm.cpp.
References KernelFunction::eval(), examples, i, kernel, Model::parameter, signOutput, and x.
| void SVM::model | ( | const Array< double > & | input, | |
| Array< double > & | output | |||
| ) | [virtual] |
compute the SVM prediction on data
Implements Model.
Definition at line 116 of file Svm.cpp.
References KernelFunction::eval(), examples, i, kernel, Model::parameter, signOutput, and x.
Referenced by SpanBound1::error(), SpanBound::error(), NoisySvmLikelihood::error(), SpanBound1::errorDerivative(), NoisySvmLikelihood::errorDerivative(), SvmApproximation::getClassificationRateOnSVsCorrectlyClassifiedByOrigSVM(), GaussianProcess::operator()(), and Perceptron::optimize().
| void SVM::modelDerivative | ( | const Array< double > & | input, | |
| Array< double > & | output, | |||
| Array< double > & | derivative | |||
| ) | [virtual] |
Reimplemented from Model.
Definition at line 199 of file Svm.cpp.
References KernelFunction::eval(), examples, i, kernel, Model::parameter, and x.
| void SVM::modelDerivative | ( | const Array< double > & | input, | |
| Array< double > & | derivative | |||
| ) | [virtual] |
Reimplemented from Model.
Definition at line 181 of file Svm.cpp.
References KernelFunction::eval(), examples, i, kernel, and x.
| int SVM::ReadToken | ( | std::istream & | is, | |
| char * | buffer, | |||
| int | maxlength, | |||
| const char * | separators | |||
| ) | [static, protected] |
Read a token from a stream.
| is | stream to read from | |
| buffer | buffer to store the token | |
| maxlength | size of the buffer | |
| separators | characters terminating the token |
Definition at line 663 of file Svm.cpp.
References i.
Referenced by ImportLibsvmModel(), and ImportSvmlightModel().
| bool SVM::SaveSVMModel | ( | std::ostream & | os | ) |
Definition at line 295 of file Svm.cpp.
References examples, Model::inputDimension, and Model::parameter.
| void SVM::SetTrainingData | ( | const Array< double > & | input, | |
| bool | copy = false | |||
| ) |
| input | training data points | |
| copy | maintain a copy of the input data |
Definition at line 94 of file Svm.cpp.
References bOwnMemory, examples, Model::inputDimension, Model::parameter, and x.
Referenced by LOO::error(), SVM_Optimizer::optimize(), Perceptron::optimize(), SVM(), SvmApproximation::SvmApproximation(), and GaussianProcess::train().
friend class SvmApproximation [friend] |
bool SVM::bOwnMemory [protected] |
true if x and y are allocated by LoadModel
Definition at line 318 of file Svm.h.
Referenced by ImportLibsvmModel(), ImportSvmlightModel(), LoadSVMModel(), MakeSparse(), SetTrainingData(), SVM(), and ~SVM().
unsigned int SVM::examples [protected] |
number of training data points x and labels y
Definition at line 328 of file Svm.h.
Referenced by getExamples(), getOffset(), ImportLibsvmModel(), ImportSvmlightModel(), LoadSVMModel(), MakeSparse(), model(), modelDerivative(), SaveSVMModel(), SetTrainingData(), SVM(), and SvmApproximation::SvmApproximation().
KernelFunction* SVM::kernel [protected] |
kernel function
Definition at line 315 of file Svm.h.
Referenced by getKernel(), ImportSvmlightModel(), model(), modelDerivative(), and SVM().
bool SVM::signOutput [protected] |
const Array<double>* SVM::x [protected] |
training data points
Definition at line 321 of file Svm.h.
Referenced by getPoints(), ImportLibsvmModel(), ImportSvmlightModel(), LoadSVMModel(), MakeSparse(), model(), modelDerivative(), SetTrainingData(), SVM(), and ~SVM().