A generic KernelMachine interface.
A kernel 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 in a training procedure.
Definition at line 43 of file KernelMachine.h.
Public Member Functions | |
CKernelMachine () | |
virtual | ~CKernelMachine () |
virtual const char * | get_name (void) const |
void | set_kernel (CKernel *k) |
CKernel * | get_kernel () |
void | set_batch_computation_enabled (bool enable) |
bool | get_batch_computation_enabled () |
void | set_linadd_enabled (bool enable) |
bool | get_linadd_enabled () |
void | set_bias_enabled (bool enable_bias) |
bool | get_bias_enabled () |
float64_t | get_bias () |
void | set_bias (float64_t bias) |
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) |
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) |
bool | init_kernel_optimization () |
virtual CLabels * | classify () |
virtual CLabels * | classify (CFeatures *data) |
virtual float64_t | classify_example (int32_t num) |
Static Public Member Functions | |
static void * | classify_example_helper (void *p) |
Protected Attributes | |
CKernel * | kernel |
bool | use_batch_computation |
bool | use_linadd |
bool | use_bias |
float64_t | m_bias |
float64_t * | m_alpha |
int32_t * | m_svs |
int32_t | num_svs |
CKernelMachine | ( | ) |
default constructor
Definition at line 30 of file KernelMachine.cpp.
~CKernelMachine | ( | ) | [virtual] |
destructor
Definition at line 53 of file KernelMachine.cpp.
CLabels * classify | ( | ) | [virtual] |
classify kernel machine
Implements CClassifier.
Reimplemented in CMultiClassSVM, and CKRR.
Definition at line 92 of file KernelMachine.cpp.
classify objects
data | (test)data to be classified |
Implements CClassifier.
Reimplemented in CDomainAdaptationSVM, and CKRR.
Definition at line 231 of file KernelMachine.cpp.
float64_t classify_example | ( | int32_t | num | ) | [virtual] |
classify one example
num | which example to classify |
Reimplemented from CClassifier.
Reimplemented in CKernelPerceptron, CMultiClassSVM, CScatterSVM, and CKRR.
Definition at line 211 of file KernelMachine.cpp.
void * classify_example_helper | ( | void * | p | ) | [static] |
classify example helper, used in threads
p | params of the thread |
Definition at line 248 of file KernelMachine.cpp.
bool create_new_model | ( | int32_t | num | ) |
create new model
num | number of alphas and support vectors in new model |
Definition at line 286 of file KernelMachine.h.
float64_t get_alpha | ( | int32_t | idx | ) |
get alpha at given index
idx | index of alpha |
Definition at line 163 of file KernelMachine.h.
void get_alphas | ( | float64_t ** | alphas, | |
int32_t * | d1 | |||
) |
get all alphas (swig compatible)
alphas | array to contain a copy of the alphas | |
d1 | number of alphas in the array |
Definition at line 266 of file KernelMachine.h.
bool get_batch_computation_enabled | ( | ) |
check if batch computation is enabled
Definition at line 94 of file KernelMachine.h.
float64_t get_bias | ( | ) |
bool get_bias_enabled | ( | ) |
CKernel* get_kernel | ( | ) |
bool get_linadd_enabled | ( | ) |
check if linadd is enabled
Definition at line 112 of file KernelMachine.h.
virtual const char* get_name | ( | void | ) | const [virtual] |
Returns the name of the SGSerializable instance. It MUST BE the CLASS NAME without the prefixed `C'.
Implements CSGObject.
Reimplemented in CKernelPerceptron, CMKL, CDomainAdaptationSVM, CGMNPSVM, CGNPPSVM, CGPBTSVM, CLaRank, CLibSVM, CLibSVMMultiClass, CLibSVMOneClass, CMPDSVM, CScatterSVM, CSVM, CSVMLight, CKRR, CLibSVR, and CSVRLight.
Definition at line 57 of file KernelMachine.h.
int32_t get_num_support_vectors | ( | ) |
get number of support vectors
Definition at line 205 of file KernelMachine.h.
int32_t get_support_vector | ( | int32_t | idx | ) |
get support vector at given index
idx | index of support vector |
Definition at line 152 of file KernelMachine.h.
void get_support_vectors | ( | int32_t ** | svs, | |
int32_t * | num | |||
) |
get all support vectors (swig compatible)
svs | array to contain a copy of the support vectors | |
num | number of support vectors in the array |
Definition at line 245 of file KernelMachine.h.
bool init_kernel_optimization | ( | ) |
initialise kernel optimisation
Definition at line 61 of file KernelMachine.cpp.
bool set_alpha | ( | int32_t | idx, | |
float64_t | val | |||
) |
set alpha at given index to given value
idx | index of alpha vector | |
val | new value of alpha vector |
Definition at line 191 of file KernelMachine.h.
void set_alphas | ( | float64_t * | alphas, | |
int32_t | d | |||
) |
set alphas to given values
alphas | array with all alphas to set | |
d | number of alphas (== number of support vectors) |
Definition at line 215 of file KernelMachine.h.
void set_batch_computation_enabled | ( | bool | enable | ) |
set batch computation enabled
enable | if batch computation shall be enabled |
Definition at line 85 of file KernelMachine.h.
void set_bias | ( | float64_t | bias | ) |
void set_bias_enabled | ( | bool | enable_bias | ) |
set state of bias
enable_bias | if bias shall be enabled |
Definition at line 121 of file KernelMachine.h.
void set_kernel | ( | CKernel * | k | ) |
void set_linadd_enabled | ( | bool | enable | ) |
set linadd enabled
enable | if linadd shall be enabled |
Definition at line 103 of file KernelMachine.h.
bool set_support_vector | ( | int32_t | idx, | |
int32_t | val | |||
) |
set support vector at given index to given value
idx | index of support vector | |
val | new value of support vector |
Definition at line 175 of file KernelMachine.h.
void set_support_vectors | ( | int32_t * | svs, | |
int32_t | d | |||
) |
set support vectors to given values
svs | array with all support vectors to set | |
d | number of support vectors |
Definition at line 230 of file KernelMachine.h.
kernel
Definition at line 343 of file KernelMachine.h.
array of coefficients alpha
Definition at line 353 of file KernelMachine.h.
bias term b
Definition at line 351 of file KernelMachine.h.
int32_t* m_svs [protected] |
array of ``support vectors''
Definition at line 355 of file KernelMachine.h.
int32_t num_svs [protected] |
number of ``support vectors''
Definition at line 357 of file KernelMachine.h.
bool use_batch_computation [protected] |
if batch computation is enabled
Definition at line 345 of file KernelMachine.h.
bool use_bias [protected] |
if bias shall be used
Definition at line 349 of file KernelMachine.h.
bool use_linadd [protected] |
if linadd is enabled
Definition at line 347 of file KernelMachine.h.