Public Member Functions | Static Public Member Functions | Protected Attributes

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 ()
virtual const char * get_name (void) const
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 30 of file KernelMachine.cpp.

~CKernelMachine (  )  [virtual]

destructor

Definition at line 53 of file KernelMachine.cpp.


Member Function Documentation

CLabels * classify (  )  [virtual]

classify kernel machine

Returns:
result labels

Implements CClassifier.

Reimplemented in CMultiClassSVM, and CKRR.

Definition at line 92 of file KernelMachine.cpp.

CLabels * classify ( CFeatures data  )  [virtual]

classify objects

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

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

Parameters:
num which example to classify
Returns:
classified value

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

Parameters:
p params of the thread
Returns:
nothing really

Definition at line 248 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 286 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 163 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 266 of file KernelMachine.h.

bool get_batch_computation_enabled (  ) 

check if batch computation is enabled

Returns:
if batch computation is enabled

Definition at line 94 of file KernelMachine.h.

float64_t get_bias (  ) 

get bias

Returns:
bias

Definition at line 133 of file KernelMachine.h.

bool get_bias_enabled (  ) 

get state of bias

Returns:
state of bias

Definition at line 127 of file KernelMachine.h.

CKernel* get_kernel (  ) 

get kernel

Returns:
kernel

Definition at line 75 of file KernelMachine.h.

bool get_linadd_enabled (  ) 

check if linadd is enabled

Returns:
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'.

Returns:
name of the SGSerializable

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

Returns:
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

Parameters:
idx index of support vector
Returns:
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)

Parameters:
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

Returns:
if operation was successful

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

Parameters:
idx index of alpha vector
val new value of alpha vector
Returns:
if operation was successful

Definition at line 191 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 215 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 85 of file KernelMachine.h.

void set_bias ( float64_t  bias  ) 

set bias to given value

Parameters:
bias new bias

Definition at line 142 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 121 of file KernelMachine.h.

void set_kernel ( CKernel k  ) 

set kernel

Parameters:
k kernel

Definition at line 64 of file KernelMachine.h.

void set_linadd_enabled ( bool  enable  ) 

set linadd enabled

Parameters:
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

Parameters:
idx index of support vector
val new value of support vector
Returns:
if operation was successful

Definition at line 175 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 230 of file KernelMachine.h.


Member Data Documentation

CKernel* kernel [protected]

kernel

Definition at line 343 of file KernelMachine.h.

float64_t* m_alpha [protected]

array of coefficients alpha

Definition at line 353 of file KernelMachine.h.

float64_t m_bias [protected]

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.


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