Public Member Functions | Protected Member Functions | Protected Attributes

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

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 float64_tget_linear_term_ptr (index_t *len)
virtual void set_linear_term (float64_t *linear_term, index_t len)
bool load (FILE *svm_file)
bool save (FILE *svm_file)
void set_nu (float64_t nue)
void set_C (float64_t c_neg, float64_t c_pos)
void set_epsilon (float64_t eps)
void set_tube_epsilon (float64_t eps)
float64_t get_tube_epsilon ()
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

index_t m_linear_term_len
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)

Constructor & Destructor Documentation

CSVM ( int32_t  num_sv = 0  ) 

Create an empty Support Vector Machine Object

num_sv with num_sv support vectors

Definition at line 27 of file SVM.cpp.

CSVM ( float64_t  C,
CKernel k,
CLabels lab 

Create a Support Vector Machine Object from a trained SVM

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

Definition at line 33 of file SVM.cpp.

~CSVM (  )  [virtual]

Definition at line 42 of file SVM.cpp.

Member Function Documentation

float64_t compute_svm_dual_objective (  ) 

compute svm dual objective

computed dual objective

Definition at line 247 of file SVM.cpp.

float64_t compute_svm_primal_objective (  ) 

compute svm primal objective

computed svm primal objective

Definition at line 272 of file SVM.cpp.

float64_t get_C1 (  ) 

get C1


Definition at line 156 of file SVM.h.

float64_t get_C2 (  ) 

get C2


Definition at line 162 of file SVM.h.

float64_t get_epsilon (  ) 

get epsilon


Definition at line 144 of file SVM.h.

float64_t * get_linear_term_array (  )  [protected, virtual]

get linear term copy as dynamic array

linear term copied to a dynamic array

Definition at line 298 of file SVM.cpp.

float64_t * get_linear_term_ptr ( index_t len  )  [virtual]

get linear term

len lenght of the linear term vector (returned)
the linear term

Definition at line 331 of file SVM.cpp.

virtual const char* get_name ( void   )  const [virtual]
object name

Reimplemented from CKernelMachine.

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

Definition at line 229 of file SVM.h.

float64_t get_nu (  ) 

get nu


Definition at line 150 of file SVM.h.

float64_t get_objective (  ) 

get objective


Definition at line 213 of file SVM.h.

int32_t get_qpsize (  ) 

get qpsize


Definition at line 168 of file SVM.h.

bool get_shrinking_enabled (  ) 

get state of shrinking

if shrinking is enabled

Definition at line 183 of file SVM.h.

float64_t get_tube_epsilon (  ) 

get tube epsilon

tube epsilon

Definition at line 132 of file SVM.h.

bool load ( FILE *  svm_file  )  [virtual]

load a SVM from file

svm_file the file handle

Reimplemented from CClassifier.

Reimplemented in CMultiClassSVM.

Definition at line 95 of file SVM.cpp.

bool save ( FILE *  svm_file  )  [virtual]

write a SVM to a file

svm_file the file handle

Reimplemented from CClassifier.

Reimplemented in CMultiClassSVM.

Definition at line 211 of file SVM.cpp.

void set_C ( float64_t  c_neg,
float64_t  c_pos 

set C

c_neg new C constant for negatively labeled examples
c_pos new C constant for positively labeled examples

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

Definition at line 113 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

m pointer to mkl object
cb callback function

Definition at line 237 of file SVM.cpp.

void set_defaults ( int32_t  num_sv = 0  ) 

set default values for members a SVM object

Definition at line 48 of file SVM.cpp.

void set_epsilon ( float64_t  eps  ) 

set epsilon

eps new epsilon

Definition at line 120 of file SVM.h.

void set_linear_term ( float64_t linear_term,
index_t  len 
) [virtual]

set linear term of the QP

linear_term the linear term
len lenght of the linear term vector

Definition at line 309 of file SVM.cpp.

void set_nu ( float64_t  nue  ) 

set nu

nue new nu

Definition at line 102 of file SVM.h.

void set_objective ( float64_t  v  ) 

set objective

v objective

Definition at line 204 of file SVM.h.

void set_qpsize ( int32_t  qps  ) 

set qpsize

qps new qpsize

Definition at line 138 of file SVM.h.

void set_shrinking_enabled ( bool  enable  ) 

set state of shrinking

enable if shrinking will be enabled

Definition at line 174 of file SVM.h.

void set_tube_epsilon ( float64_t  eps  ) 

set tube epsilon

eps new tube epsilon

Definition at line 126 of file SVM.h.

Member Data Documentation

float64_t C1 [protected]

C1 regularization const

Definition at line 253 of file SVM.h.

float64_t C2 [protected]


Definition at line 255 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

Definition at line 265 of file SVM.h.

float64_t epsilon [protected]


Definition at line 247 of file SVM.h.

float64_t* m_linear_term [protected]

linear term in qp

Definition at line 241 of file SVM.h.

Definition at line 242 of file SVM.h.

CMKL* mkl [protected]

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

Definition at line 268 of file SVM.h.

float64_t nu [protected]


Definition at line 251 of file SVM.h.

float64_t objective [protected]


Definition at line 257 of file SVM.h.

int32_t qpsize [protected]


Definition at line 259 of file SVM.h.

bool svm_loaded [protected]

if SVM is loaded

Definition at line 245 of file SVM.h.

float64_t tube_epsilon [protected]

tube epsilon for support vector regression

Definition at line 249 of file SVM.h.

bool use_shrinking [protected]

if shrinking shall be used

Definition at line 261 of file SVM.h.

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation