Public Member Functions | Static Public Member Functions | Protected 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 () 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 (SGVector< float64_t > alphas)
void set_support_vectors (SGVector< int32_t > svs)
SGVector< int32_t > get_support_vectors ()
SGVector< float64_tget_alphas ()
bool create_new_model (int32_t num)
bool init_kernel_optimization ()
virtual CLabelsapply ()
virtual CLabelsapply (CFeatures *data)
virtual float64_t apply (int32_t num)

Static Public Member Functions

static void * apply_helper (void *p)

Protected Member Functions

virtual void store_model_features ()

Protected Attributes

CKernelkernel
bool use_batch_computation
bool use_linadd
bool use_bias
float64_t m_bias
SGVector< float64_tm_alpha
SGVector< int32_t > m_svs

Constructor & Destructor Documentation

CKernelMachine (  ) 

default constructor

Definition at line 28 of file KernelMachine.cpp.

~CKernelMachine (  )  [virtual]

destructor

Definition at line 44 of file KernelMachine.cpp.


Member Function Documentation

CLabels * apply (  )  [virtual]

apply kernel machine to all objects

Returns:
result labels

Implements CMachine.

Reimplemented in CMultiClassSVM, and CKRR.

Definition at line 83 of file KernelMachine.cpp.

CLabels * apply ( CFeatures data  )  [virtual]

apply kernel machine to data

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

Implements CMachine.

Reimplemented in CDomainAdaptationSVM, and CMultiClassSVM.

Definition at line 222 of file KernelMachine.cpp.

float64_t apply ( int32_t  num  )  [virtual]

apply kernel machine to one example

Parameters:
num which example to apply to
Returns:
classified value

Reimplemented from CMachine.

Reimplemented in CMultiClassSVM, CScatterSVM, and CKRR.

Definition at line 202 of file KernelMachine.cpp.

void * apply_helper ( void *  p  )  [static]

apply 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 271 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.

SGVector<float64_t> get_alphas (  ) 

get all alphas

Definition at line 252 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 (  )  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 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 208 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.

SGVector<int32_t> get_support_vectors (  ) 

get all support vectors

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

void set_alphas ( SGVector< float64_t alphas  ) 

set alphas to given values

Parameters:
alphas float vector with all alphas to set

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

void set_support_vectors ( SGVector< int32_t >  svs  ) 

set support vectors to given values

Parameters:
svs integer vector with all support vectors indexes to set

Definition at line 226 of file KernelMachine.h.

void store_model_features (  )  [protected, virtual]

Stores feature data of the SV indices and sets it to the lhs of the underlying kernel. Then, all SV indices are set to identity.

Reimplemented from CMachine.

Definition at line 266 of file KernelMachine.cpp.


Member Data Documentation

CKernel* kernel [protected]

kernel

Definition at line 329 of file KernelMachine.h.

SGVector<float64_t> m_alpha [protected]

coefficients alpha

Definition at line 340 of file KernelMachine.h.

float64_t m_bias [protected]

bias term b

Definition at line 337 of file KernelMachine.h.

SGVector<int32_t> m_svs [protected]

array of ``support vectors'' (indices of feature objects)

Definition at line 343 of file KernelMachine.h.

bool use_batch_computation [protected]

if batch computation is enabled

Definition at line 331 of file KernelMachine.h.

bool use_bias [protected]

if bias shall be used

Definition at line 335 of file KernelMachine.h.

bool use_linadd [protected]

if linadd is enabled

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