CSVM Class Reference
Detailed Description
A generic Support Vector Machine Interface.
A support vector machine is defined as
where
is the number of training examples
are the weights assigned to each training example
is the kernel and
the bias.
Using an a-priori choosen kernel, the
and bias are determined by solving the following quadratic program
here C is a pre-specified regularization parameter.
Definition at line 43 of file SVM.h.
List of all members.
Classes |
struct | TModel |
| an SVM is defined by support vectors, their coefficients alpha and the bias b ( + CKernelMachine::kernel) More...
|
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) |
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_weight_epsilon (float64_t eps) |
void | set_epsilon (float64_t eps) |
void | set_tube_epsilon (float64_t eps) |
void | set_C_mkl (float64_t C) |
void | set_mkl_norm (float64_t norm) |
void | set_qpsize (int32_t qps) |
void | set_bias_enabled (bool enable_bias) |
bool | get_bias_enabled () |
float64_t | get_weight_epsilon () |
float64_t | get_epsilon () |
float64_t | get_nu () |
float64_t | get_C1 () |
float64_t | get_C2 () |
int32_t | get_qpsize () |
int32_t | get_support_vector (int32_t idx) |
float64_t | get_alpha (int32_t idx) |
bool | set_support_vector (int32_t idx, int32_t val) |
bool | set_alpha (int32_t idx, float64_t val) |
float64_t | get_bias () |
void | set_bias (float64_t bias) |
int32_t | get_num_support_vectors () |
void | set_alphas (float64_t *alphas, int32_t d) |
void | set_support_vectors (int32_t *svs, int32_t d) |
void | get_support_vectors (int32_t **svs, int32_t *num) |
void | get_alphas (float64_t **alphas, int32_t *d1) |
bool | create_new_model (int32_t num) |
void | set_shrinking_enabled (bool enable) |
bool | get_shrinking_enabled () |
void | set_mkl_enabled (bool enable) |
bool | get_mkl_enabled () |
float64_t | compute_objective () |
void | set_objective (float64_t v) |
float64_t | get_objective () |
bool | init_kernel_optimization () |
virtual CLabels * | classify (CLabels *lab=NULL) |
virtual float64_t | classify_example (int32_t num) |
virtual const char * | get_name () const |
int32_t | get_mkl_iterations () |
Static Public Member Functions |
static void * | classify_example_helper (void *p) |
Protected Attributes |
TModel | svm_model |
bool | svm_loaded |
float64_t | weight_epsilon |
float64_t | epsilon |
float64_t | tube_epsilon |
float64_t | nu |
float64_t | C1 |
float64_t | C2 |
float64_t | mkl_norm |
float64_t | C_mkl |
float64_t | objective |
int32_t | qpsize |
bool | use_bias |
bool | use_shrinking |
bool | use_mkl |
int32_t | mkl_iterations |
Constructor & Destructor Documentation
CSVM::CSVM |
( |
int32_t |
num_sv = 0 |
) |
|
Create an empty Support Vector Machine Object
- Parameters:
-
| num_sv | with num_sv support vectors |
Definition at line 35 of file SVM.cpp.
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 41 of file SVM.cpp.
CSVM::~CSVM |
( |
|
) |
[virtual] |
Member Function Documentation
float64_t CSVM::classify_example |
( |
int32_t |
num |
) |
[virtual] |
classify one example
- Parameters:
-
| num | which example to classify |
- Returns:
- classified value
Reimplemented from CClassifier.
Reimplemented in CMultiClassSVM.
Definition at line 407 of file SVM.cpp.
void * CSVM::classify_example_helper |
( |
void * |
p |
) |
[static] |
classify example helper, used in threads
- Parameters:
-
- Returns:
- nothing really
Definition at line 256 of file SVM.cpp.
compute objective
- Returns:
- computed objective
Definition at line 427 of file SVM.cpp.
bool CSVM::create_new_model |
( |
int32_t |
num |
) |
|
create new model
- Parameters:
-
| num | number of alphas and support vectors in new model |
Definition at line 335 of file SVM.h.
get alpha at given index
- Parameters:
-
- Returns:
- alpha
Definition at line 196 of file SVM.h.
void CSVM::get_alphas |
( |
float64_t ** |
alphas, |
|
|
int32_t * |
d1 | |
|
) |
| | |
get all alphas (swig compatible)
- Parameters:
-
| alphas | array to contain a copy of the alphas |
| d1 | number of alphas in the array |
Definition at line 315 of file SVM.h.
get bias
- Returns:
- bias
Definition at line 238 of file SVM.h.
bool CSVM::get_bias_enabled |
( |
|
) |
|
get state of bias
- Returns:
- state of bias
Definition at line 142 of file SVM.h.
get C1
- Returns:
- C1
Definition at line 166 of file SVM.h.
get C2
- Returns:
- C2
Definition at line 172 of file SVM.h.
get epsilon
- Returns:
- epsilon
Definition at line 154 of file SVM.h.
bool CSVM::get_mkl_enabled |
( |
|
) |
|
get state of mkl
- Returns:
- if mkl is enabled
Definition at line 388 of file SVM.h.
int32_t CSVM::get_mkl_iterations |
( |
|
) |
|
get number of MKL iterations
- Returns:
- mkl_iterations
Definition at line 451 of file SVM.h.
virtual const char* CSVM::get_name |
( |
|
) |
const [virtual] |
get nu
- Returns:
- nu
Definition at line 160 of file SVM.h.
int32_t CSVM::get_num_support_vectors |
( |
|
) |
|
get number of support vectors
- Returns:
- number of support vectors
Definition at line 256 of file SVM.h.
get objective
- Returns:
- objective
Definition at line 412 of file SVM.h.
int32_t CSVM::get_qpsize |
( |
|
) |
|
get qpsize
- Returns:
- qpsize
Definition at line 178 of file SVM.h.
bool CSVM::get_shrinking_enabled |
( |
|
) |
|
get state of shrinking
- Returns:
- if shrinking is enabled
Definition at line 370 of file SVM.h.
int32_t CSVM::get_support_vector |
( |
int32_t |
idx |
) |
|
get support vector at given index
- Parameters:
-
| idx | index of support vector |
- Returns:
- support vector
Definition at line 185 of file SVM.h.
void CSVM::get_support_vectors |
( |
int32_t ** |
svs, |
|
|
int32_t * |
num | |
|
) |
| | |
get all support vectors (swig compatible)
- Parameters:
-
| svs | array to contain a copy of the support vectors |
| num | number of support vectors in the array |
Definition at line 294 of file SVM.h.
get epsilon for weights
- Returns:
- epsilon for weights
Definition at line 148 of file SVM.h.
bool CSVM::init_kernel_optimization |
( |
|
) |
|
initialise kernel optimisation
- Returns:
- if operation was successful
Definition at line 225 of file SVM.cpp.
bool CSVM::load |
( |
FILE * |
svm_file |
) |
[virtual] |
bool CSVM::save |
( |
FILE * |
svm_file |
) |
[virtual] |
bool CSVM::set_alpha |
( |
int32_t |
idx, |
|
|
float64_t |
val | |
|
) |
| | |
set alpha at given index to given value
- Parameters:
-
| idx | index of alpha vector |
| val | new value of alpha vector |
- Returns:
- if operation was successful
Definition at line 224 of file SVM.h.
void CSVM::set_alphas |
( |
float64_t * |
alphas, |
|
|
int32_t |
d | |
|
) |
| | |
set alphas to given values
- Parameters:
-
| alphas | array with all alphas to set |
| d | number of alphas (== number of support vectors) |
Definition at line 266 of file SVM.h.
set bias to given value
- Parameters:
-
Definition at line 247 of file SVM.h.
void CSVM::set_bias_enabled |
( |
bool |
enable_bias |
) |
|
set state of bias
- Parameters:
-
| enable_bias | if bias shall be enabled |
Definition at line 136 of file SVM.h.
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 89 of file SVM.h.
set C mkl
- Parameters:
-
Definition at line 113 of file SVM.h.
void CSVM::set_defaults |
( |
int32_t |
num_sv = 0 |
) |
|
set default values for members a SVM object
Definition at line 58 of file SVM.cpp.
set epsilon
- Parameters:
-
Definition at line 101 of file SVM.h.
void CSVM::set_mkl_enabled |
( |
bool |
enable |
) |
|
set state of mkl
- Parameters:
-
| enable | if mkl shall be enabled |
Definition at line 379 of file SVM.h.
set mkl norm
- Parameters:
-
| norm | new mkl norm (1 or 2) |
Definition at line 119 of file SVM.h.
set nu
- Parameters:
-
Definition at line 79 of file SVM.h.
set objective
- Parameters:
-
Definition at line 403 of file SVM.h.
void CSVM::set_qpsize |
( |
int32_t |
qps |
) |
|
set qpsize
- Parameters:
-
Definition at line 130 of file SVM.h.
void CSVM::set_shrinking_enabled |
( |
bool |
enable |
) |
|
set state of shrinking
- Parameters:
-
| enable | if shrinking will be enabled |
Definition at line 361 of file SVM.h.
bool CSVM::set_support_vector |
( |
int32_t |
idx, |
|
|
int32_t |
val | |
|
) |
| | |
set support vector at given index to given value
- Parameters:
-
| idx | index of support vector |
| val | new value of support vector |
- Returns:
- if operation was successful
Definition at line 208 of file SVM.h.
void CSVM::set_support_vectors |
( |
int32_t * |
svs, |
|
|
int32_t |
d | |
|
) |
| | |
set support vectors to given values
- Parameters:
-
| svs | array with all support vectors to set |
| d | number of support vectors |
Definition at line 280 of file SVM.h.
void CSVM::set_tube_epsilon |
( |
float64_t |
eps |
) |
|
set tube epsilon
- Parameters:
-
Definition at line 107 of file SVM.h.
void CSVM::set_weight_epsilon |
( |
float64_t |
eps |
) |
|
set epsilon for weights
- Parameters:
-
Definition at line 95 of file SVM.h.
Member Data Documentation
C1 regularization const
Definition at line 481 of file SVM.h.
C2
Definition at line 483 of file SVM.h.
C_mkl
Definition at line 487 of file SVM.h.
epsilon
Definition at line 475 of file SVM.h.
number of mkl steps
Definition at line 499 of file SVM.h.
norm used in mkl must be > 0
Definition at line 485 of file SVM.h.
nu
Definition at line 479 of file SVM.h.
objective
Definition at line 489 of file SVM.h.
qpsize
Definition at line 491 of file SVM.h.
if SVM is loaded
Definition at line 471 of file SVM.h.
SVM's model
Definition at line 469 of file SVM.h.
tube epsilon for support vector regression
Definition at line 477 of file SVM.h.
if bias shall be used
Definition at line 493 of file SVM.h.
if mkl shall be used
Definition at line 497 of file SVM.h.
if shrinking shall be used
Definition at line 495 of file SVM.h.
epsilon for multiple kernel learning
Definition at line 473 of file SVM.h.
The documentation for this class was generated from the following files: