CSVM Class Reference


Detailed Description

A generic Support Vector Machine Interface.

A support vector machine is defined as

\[ f({\bf x})=\sum_{i=0}^{N-1} \alpha_i k({\bf x}, {\bf x_i})+b \]

where $N$ is the number of training examples $\alpha_i$ are the weights assigned to each training example $k(x,x')$ is the kernel and $b$ the bias.

Using an a-priori choosen kernel, the $\alpha_i$ and bias are determined by solving the following quadratic program

\begin{eqnarray*} \max_{\bf \alpha} && \sum_{i=0}^{N-1} \alpha_i - \sum_{i=0}^{N-1}\sum_{j=0}^{N-1} \alpha_i y_i \alpha_j y_j k({\bf x_i}, {\bf x_j})\\ \mbox{s.t.} && 0\leq\alpha_i\leq C\\ && \sum_{i=0}^{N-1} \alpha_i y_i=0\\ \end{eqnarray*}

here C is a pre-specified regularization parameter.

Definition at line 46 of file SVM.h.

Inheritance diagram for CSVM:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 CSVM (int32_t num_sv=0)
 CSVM (float64_t C, CKernel *k, CLabels *lab)
virtual ~CSVM ()
void set_defaults (int32_t num_sv=0)
virtual std::vector< float64_tget_linear_term ()
virtual void set_linear_term (std::vector< float64_t > lin)
bool load (FILE *svm_file)
bool save (FILE *svm_file)
void set_nu (float64_t nue)
void set_C (float64_t c1, float64_t c2)
void set_epsilon (float64_t eps)
void set_tube_epsilon (float64_t eps)
void set_qpsize (int32_t qps)
float64_t get_epsilon ()
float64_t get_nu ()
float64_t get_C1 ()
float64_t get_C2 ()
int32_t get_qpsize ()
void set_shrinking_enabled (bool enable)
bool get_shrinking_enabled ()
float64_t compute_svm_dual_objective ()
float64_t compute_svm_primal_objective ()
void set_objective (float64_t v)
float64_t get_objective ()
void set_callback_function (CMKL *m, bool(*cb)(CMKL *mkl, const float64_t *sumw, const float64_t suma))
virtual const char * get_name () const

Protected Member Functions

virtual float64_tget_linear_term_array ()

Protected Attributes

std::vector< float64_tlinear_term
bool svm_loaded
float64_t epsilon
float64_t tube_epsilon
float64_t nu
float64_t C1
float64_t C2
float64_t objective
int32_t qpsize
bool use_shrinking
bool(* callback )(CMKL *mkl, const float64_t *sumw, const float64_t suma)
CMKLmkl

Constructor & Destructor Documentation

CSVM ( int32_t  num_sv = 0  ) 

Create an empty Support Vector Machine Object

Parameters:
num_sv with num_sv support vectors

Definition at line 31 of file SVM.cpp.

CSVM ( float64_t  C,
CKernel k,
CLabels lab 
)

Create a Support Vector Machine Object from a trained SVM

Parameters:
C the C parameter
k the Kernel object
lab the Label object

Definition at line 37 of file SVM.cpp.

~CSVM (  )  [virtual]

Definition at line 46 of file SVM.cpp.


Member Function Documentation

float64_t compute_svm_dual_objective (  ) 

compute svm dual objective

Returns:
computed dual objective

Definition at line 223 of file SVM.cpp.

float64_t compute_svm_primal_objective (  ) 

compute svm primal objective

Returns:
computed svm primal objective

Definition at line 248 of file SVM.cpp.

float64_t get_C1 (  ) 

get C1

Returns:
C1

Definition at line 145 of file SVM.h.

float64_t get_C2 (  ) 

get C2

Returns:
C2

Definition at line 151 of file SVM.h.

float64_t get_epsilon (  ) 

get epsilon

Returns:
epsilon

Definition at line 133 of file SVM.h.

std::vector< float64_t > get_linear_term (  )  [virtual]

get linear term

Returns:
lin the linear term

Definition at line 305 of file SVM.cpp.

float64_t * get_linear_term_array (  )  [protected, virtual]

get linear term copy as dynamic array

Returns:
linear term copied to a dynamic array

Definition at line 275 of file SVM.cpp.

virtual const char* get_name (  )  const [virtual]
Returns:
object name

Implements CSGObject.

Reimplemented in CMKL, CGMNPSVM, CGNPPSVM, CGPBTSVM, CLaRank, CLibSVM, CLibSVMMultiClass, CLibSVMOneClass, CMPDSVM, CScatterSVM, and CLibSVR.

Definition at line 218 of file SVM.h.

float64_t get_nu (  ) 

get nu

Returns:
nu

Definition at line 139 of file SVM.h.

float64_t get_objective (  ) 

get objective

Returns:
objective

Definition at line 202 of file SVM.h.

int32_t get_qpsize (  ) 

get qpsize

Returns:
qpsize

Definition at line 157 of file SVM.h.

bool get_shrinking_enabled (  ) 

get state of shrinking

Returns:
if shrinking is enabled

Definition at line 172 of file SVM.h.

bool load ( FILE *  svm_file  )  [virtual]

load a SVM from file

Parameters:
svm_file the file handle

Reimplemented from CClassifier.

Reimplemented in CMultiClassSVM.

Definition at line 77 of file SVM.cpp.

bool save ( FILE *  svm_file  )  [virtual]

write a SVM to a file

Parameters:
svm_file the file handle

Reimplemented from CClassifier.

Reimplemented in CMultiClassSVM.

Definition at line 190 of file SVM.cpp.

void set_C ( float64_t  c1,
float64_t  c2 
)

set C

Parameters:
c1 new C constant for negatively labelled examples
c2 new C constant for positively labelled examples

Note that not all SVMs support this (however at least CLibSVM and CSVMLight do)

Definition at line 109 of file SVM.h.

void set_callback_function ( CMKL m,
bool(*)(CMKL *mkl, const float64_t *sumw, const float64_t suma)  cb 
)

set callback function svm optimizers may call when they have a new (small) set of alphas

Parameters:
m pointer to mkl object
cb callback function

Definition at line 213 of file SVM.cpp.

void set_defaults ( int32_t  num_sv = 0  ) 

set default values for members a SVM object

Definition at line 51 of file SVM.cpp.

void set_epsilon ( float64_t  eps  ) 

set epsilon

Parameters:
eps new epsilon

Definition at line 115 of file SVM.h.

void set_linear_term ( std::vector< float64_t lin  )  [virtual]

set linear term of the QP

Parameters:
lin the linear term

Definition at line 286 of file SVM.cpp.

void set_nu ( float64_t  nue  ) 

set nu

Parameters:
nue new nu

Definition at line 99 of file SVM.h.

void set_objective ( float64_t  v  ) 

set objective

Parameters:
v objective

Definition at line 193 of file SVM.h.

void set_qpsize ( int32_t  qps  ) 

set qpsize

Parameters:
qps new qpsize

Definition at line 127 of file SVM.h.

void set_shrinking_enabled ( bool  enable  ) 

set state of shrinking

Parameters:
enable if shrinking will be enabled

Definition at line 163 of file SVM.h.

void set_tube_epsilon ( float64_t  eps  ) 

set tube epsilon

Parameters:
eps new tube epsilon

Definition at line 121 of file SVM.h.


Member Data Documentation

float64_t C1 [protected]

C1 regularization const

Definition at line 299 of file SVM.h.

float64_t C2 [protected]

C2

Definition at line 301 of file SVM.h.

bool(* callback)(CMKL *mkl, const float64_t *sumw, const float64_t suma) [protected]

callback function svm optimizers may call when they have a new (small) set of alphas

float64_t epsilon [protected]

epsilon

Definition at line 293 of file SVM.h.

std::vector<float64_t> linear_term [protected]

linear term in qp

Definition at line 288 of file SVM.h.

CMKL* mkl [protected]

mkl object that svm optimizers need to pass when calling the callback function

Definition at line 314 of file SVM.h.

float64_t nu [protected]

nu

Definition at line 297 of file SVM.h.

float64_t objective [protected]

objective

Definition at line 303 of file SVM.h.

int32_t qpsize [protected]

qpsize

Definition at line 305 of file SVM.h.

bool svm_loaded [protected]

if SVM is loaded

Definition at line 291 of file SVM.h.

float64_t tube_epsilon [protected]

tube epsilon for support vector regression

Definition at line 295 of file SVM.h.

bool use_shrinking [protected]

if shrinking shall be used

Definition at line 307 of file SVM.h.


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

SHOGUN Machine Learning Toolbox - Documentation