CKernelMachine Class Reference


Detailed Description

A generic KernelMachine interface.

A kernel 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 in a training procedure.

Definition at line 43 of file KernelMachine.h.

Inheritance diagram for CKernelMachine:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 CKernelMachine ()
virtual ~CKernelMachine ()
void set_kernel (CKernel *k)
CKernelget_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 CLabelsclassify ()
virtual CLabelsclassify (CFeatures *data)
virtual float64_t classify_example (int32_t num)

Static Public Member Functions

static void * classify_example_helper (void *p)

Protected Attributes

CKernelkernel
bool use_batch_computation
bool use_linadd
bool use_bias
float64_t m_bias
float64_tm_alpha
int32_t * m_svs
int32_t num_svs

Constructor & Destructor Documentation

CKernelMachine (  ) 

default constructor

Definition at line 35 of file KernelMachine.cpp.

~CKernelMachine (  )  [virtual]

destructor

Definition at line 44 of file KernelMachine.cpp.


Member Function Documentation

CLabels * classify ( CFeatures data  )  [virtual]

classify objects

Parameters:
data (test)data to be classified
Returns:
classified labels

Implements CClassifier.

Reimplemented in CKRR.

Definition at line 222 of file KernelMachine.cpp.

CLabels * classify (  )  [virtual]

classify kernel machine

Returns:
result labels

Implements CClassifier.

Reimplemented in CMultiClassSVM, and CKRR.

Definition at line 83 of file KernelMachine.cpp.

float64_t classify_example ( int32_t  num  )  [virtual]

classify one example

Parameters:
num which example to classify
Returns:
classified value

Reimplemented from CClassifier.

Reimplemented in CKernelPerceptron, CMultiClassSVM, CScatterSVM, and CKRR.

Definition at line 202 of file KernelMachine.cpp.

void * classify_example_helper ( void *  p  )  [static]

classify example helper, used in threads

Parameters:
p params of the thread
Returns:
nothing really

Definition at line 239 of file KernelMachine.cpp.

bool create_new_model ( int32_t  num  ) 

create new model

Parameters:
num number of alphas and support vectors in new model

Definition at line 278 of file KernelMachine.h.

float64_t get_alpha ( int32_t  idx  ) 

get alpha at given index

Parameters:
idx index of alpha
Returns:
alpha

Definition at line 155 of file KernelMachine.h.

void 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 258 of file KernelMachine.h.

bool get_batch_computation_enabled (  ) 

check if batch computation is enabled

Returns:
if batch computation is enabled

Definition at line 86 of file KernelMachine.h.

float64_t get_bias (  ) 

get bias

Returns:
bias

Definition at line 125 of file KernelMachine.h.

bool get_bias_enabled (  ) 

get state of bias

Returns:
state of bias

Definition at line 119 of file KernelMachine.h.

CKernel* get_kernel (  ) 

get kernel

Returns:
kernel

Definition at line 67 of file KernelMachine.h.

bool get_linadd_enabled (  ) 

check if linadd is enabled

Returns:
if linadd is enabled

Definition at line 104 of file KernelMachine.h.

int32_t get_num_support_vectors (  ) 

get number of support vectors

Returns:
number of support vectors

Definition at line 197 of file KernelMachine.h.

int32_t get_support_vector ( int32_t  idx  ) 

get support vector at given index

Parameters:
idx index of support vector
Returns:
support vector

Definition at line 144 of file KernelMachine.h.

void 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 237 of file KernelMachine.h.

bool init_kernel_optimization (  ) 

initialise kernel optimisation

Returns:
if operation was successful

Definition at line 52 of file KernelMachine.cpp.

bool 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 183 of file KernelMachine.h.

void 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 207 of file KernelMachine.h.

void set_batch_computation_enabled ( bool  enable  ) 

set batch computation enabled

Parameters:
enable if batch computation shall be enabled

Definition at line 77 of file KernelMachine.h.

void set_bias ( float64_t  bias  ) 

set bias to given value

Parameters:
bias new bias

Definition at line 134 of file KernelMachine.h.

void set_bias_enabled ( bool  enable_bias  ) 

set state of bias

Parameters:
enable_bias if bias shall be enabled

Definition at line 113 of file KernelMachine.h.

void set_kernel ( CKernel k  ) 

set kernel

Parameters:
k kernel

Definition at line 56 of file KernelMachine.h.

void set_linadd_enabled ( bool  enable  ) 

set linadd enabled

Parameters:
enable if linadd shall be enabled

Definition at line 95 of file KernelMachine.h.

bool 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 167 of file KernelMachine.h.

void 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 222 of file KernelMachine.h.


Member Data Documentation

CKernel* kernel [protected]

kernel

Definition at line 426 of file KernelMachine.h.

float64_t* m_alpha [protected]

array of coefficients alpha

Definition at line 436 of file KernelMachine.h.

float64_t m_bias [protected]

bias term b

Definition at line 434 of file KernelMachine.h.

int32_t* m_svs [protected]

array of ``support vectors''

Definition at line 438 of file KernelMachine.h.

int32_t num_svs [protected]

number of ``support vectors''

Definition at line 440 of file KernelMachine.h.

bool use_batch_computation [protected]

if batch computation is enabled

Definition at line 428 of file KernelMachine.h.

bool use_bias [protected]

if bias shall be used

Definition at line 432 of file KernelMachine.h.

bool use_linadd [protected]

if linadd is enabled

Definition at line 430 of file KernelMachine.h.


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

SHOGUN Machine Learning Toolbox - Documentation