CCombinedKernel Class Reference

Inheritance diagram for CCombinedKernel:

Inheritance graph
[legend]

List of all members.

Public Member Functions

 CCombinedKernel (int32_t size=10, bool append_subkernel_weights=false)
 CCombinedKernel (CCombinedFeatures *l, CCombinedFeatures *r, bool append_subkernel_weights=false)
virtual ~CCombinedKernel ()
virtual bool init (CFeatures *lhs, CFeatures *rhs)
virtual void cleanup ()
virtual bool load_init (FILE *src)
virtual bool save_init (FILE *dest)
virtual EKernelType get_kernel_type ()
virtual EFeatureType get_feature_type ()
virtual EFeatureClass get_feature_class ()
virtual const char * get_name ()
void list_kernels ()
CKernelget_first_kernel ()
CKernelget_first_kernel (CListElement< CKernel * > *&current)
CKernelget_kernel (int32_t idx)
CKernelget_last_kernel ()
CKernelget_next_kernel (const CKernel *current)
CKernelget_next_kernel (CListElement< CKernel * > *&current)
bool insert_kernel (CKernel *k)
bool append_kernel (CKernel *k)
bool delete_kernel ()
bool get_append_subkernel_weights ()
int32_t get_num_subkernels ()
virtual void remove_lhs ()
virtual void remove_rhs ()
virtual bool init_optimization (int32_t count, int32_t *IDX, float64_t *weights)
virtual bool delete_optimization ()
virtual float64_t compute_optimized (int32_t idx)
virtual void compute_batch (int32_t num_vec, int32_t *vec_idx, float64_t *target, int32_t num_suppvec, int32_t *IDX, float64_t *alphas, float64_t factor=1.0)
void emulate_compute_batch (CKernel *k, int32_t num_vec, int32_t *vec_idx, float64_t *target, int32_t num_suppvec, int32_t *IDX, float64_t *weights)
virtual void add_to_normal (int32_t idx, float64_t weight)
virtual void clear_normal ()
virtual void compute_by_subkernel (int32_t idx, float64_t *subkernel_contrib)
virtual const float64_tget_subkernel_weights (int32_t &num_weights)
virtual void set_subkernel_weights (float64_t *weights, int32_t num_weights)
virtual void set_optimization_type (EOptimizationType t)
bool precompute_subkernels ()

Static Public Member Functions

static void * compute_optimized_kernel_helper (void *p)
static void * compute_kernel_helper (void *p)

Protected Member Functions

virtual float64_t compute (int32_t x, int32_t y)

Protected Attributes

CList< CKernel * > * kernel_list
int32_t sv_count
int32_t * sv_idx
float64_tsv_weight
float64_tsubkernel_weights_buffer
bool append_subkernel_weights


Detailed Description

The Combined kernel is used to combine a number of kernels into a single CombinedKernel object by linear combination. It keeps pointers to the added sub-kernels $k_m({\bf x}, {\bf x'})$ and for each sub-kernel - a kernel specific weight $\beta_m$.

It is especially useful to combine kernels working on different domains and to combine kernels looking at independent features and requires CCombinedFeatures to be used.

It is defined as:

\[ k_{combined}({\bf x}, {\bf x'}) = \sum_{m=1}^M \beta_m k_m({\bf x}, {\bf x'}) \]

Definition at line 38 of file CombinedKernel.h.


Constructor & Destructor Documentation

CCombinedKernel::CCombinedKernel ( int32_t  size = 10,
bool  append_subkernel_weights = false 
)

constructor

Parameters:
size cache size
append_subkernel_weights if subkernel weights shall be appended

Definition at line 41 of file CombinedKernel.cpp.

CCombinedKernel::CCombinedKernel ( CCombinedFeatures l,
CCombinedFeatures r,
bool  append_subkernel_weights = false 
)

constructor

Parameters:
l features for left-hand side
r features for right-hand side
append_subkernel_weights if subkernel weights shall be appended

Definition at line 52 of file CombinedKernel.cpp.

CCombinedKernel::~CCombinedKernel (  )  [virtual]

Definition at line 67 of file CombinedKernel.cpp.


Member Function Documentation

void CCombinedKernel::add_to_normal ( int32_t  idx,
float64_t  weight 
) [virtual]

add to normal vector

Parameters:
idx where to add
weight what to add

Reimplemented from CKernel.

Definition at line 545 of file CombinedKernel.cpp.

bool CCombinedKernel::append_kernel ( CKernel k  ) 

append kernel

Parameters:
k kernel
Returns:
if appending was successful

Definition at line 209 of file CombinedKernel.h.

void CCombinedKernel::cleanup (  )  [virtual]

clean up kernel

Reimplemented from CKernel.

Definition at line 186 of file CombinedKernel.cpp.

void CCombinedKernel::clear_normal (  )  [virtual]

clear normal vector

Reimplemented from CKernel.

Definition at line 558 of file CombinedKernel.cpp.

float64_t CCombinedKernel::compute ( int32_t  x,
int32_t  y 
) [protected, virtual]

compute kernel function

Parameters:
x x
y y
Returns:
computed kernel function

Implements CKernel.

Definition at line 219 of file CombinedKernel.cpp.

void CCombinedKernel::compute_batch ( int32_t  num_vec,
int32_t *  vec_idx,
float64_t target,
int32_t  num_suppvec,
int32_t *  IDX,
float64_t alphas,
float64_t  factor = 1.0 
) [virtual]

computes output for a batch of examples in an optimized fashion (favorable if kernel supports it, i.e. has KP_BATCHEVALUATION. to the outputvector target (of length num_vec elements) the output for the examples enumerated in vec_idx are added. therefore make sure that it is initialized with ZERO. the following num_suppvec, IDX, alphas arguments are the number of support vectors, their indices and weights

Reimplemented from CKernel.

Definition at line 309 of file CombinedKernel.cpp.

void CCombinedKernel::compute_by_subkernel ( int32_t  idx,
float64_t subkernel_contrib 
) [virtual]

compute by subkernel

Parameters:
idx index
subkernel_contrib subkernel contribution

Reimplemented from CKernel.

Definition at line 571 of file CombinedKernel.cpp.

void * CCombinedKernel::compute_kernel_helper ( void *  p  )  [static]

helper for compute kernel

Parameters:
p thread parameter

Definition at line 356 of file CombinedKernel.cpp.

float64_t CCombinedKernel::compute_optimized ( int32_t  idx  )  [virtual]

compute optimized

Parameters:
idx index to compute
Returns:
optimized value at given index

Reimplemented from CKernel.

Definition at line 503 of file CombinedKernel.cpp.

void * CCombinedKernel::compute_optimized_kernel_helper ( void *  p  )  [static]

helper for compute optimized kernel

Parameters:
p thread parameter

Definition at line 343 of file CombinedKernel.cpp.

bool CCombinedKernel::delete_kernel (  ) 

delete kernel

Returns:
if deleting was successful

Definition at line 224 of file CombinedKernel.h.

bool CCombinedKernel::delete_optimization (  )  [virtual]

delete optimization

Returns:
if deleting was successful

Reimplemented from CKernel.

Definition at line 284 of file CombinedKernel.cpp.

void CCombinedKernel::emulate_compute_batch ( CKernel k,
int32_t  num_vec,
int32_t *  vec_idx,
float64_t target,
int32_t  num_suppvec,
int32_t *  IDX,
float64_t weights 
)

emulates batch computation, via linadd optimization w^t x or even down to sum_i alpha_i K(x_i,x)

Parameters:
k kernel
num_vec number of vectors
vec_idx vector index
target target
num_suppvec number of support vectors
IDX IDX
weights weights

Definition at line 378 of file CombinedKernel.cpp.

bool CCombinedKernel::get_append_subkernel_weights (  ) 

check if subkernel weights are appended

Returns:
if subkernel weigths are appended

Definition at line 236 of file CombinedKernel.h.

virtual EFeatureClass CCombinedKernel::get_feature_class (  )  [virtual]

return feature class the kernel can deal with

Returns:
feature class COMBINED

Implements CKernel.

Definition at line 112 of file CombinedKernel.h.

virtual EFeatureType CCombinedKernel::get_feature_type (  )  [virtual]

return feature type the kernel can deal with

Returns:
feature type UNKNOWN

Implements CKernel.

Definition at line 103 of file CombinedKernel.h.

CKernel* CCombinedKernel::get_first_kernel ( CListElement< CKernel * > *&  current  ) 

get first kernel

Parameters:
current 
Returns:
first kernel

Definition at line 140 of file CombinedKernel.h.

CKernel* CCombinedKernel::get_first_kernel (  ) 

get first kernel

Returns:
first kernel

Definition at line 130 of file CombinedKernel.h.

CKernel* CCombinedKernel::get_kernel ( int32_t  idx  ) 

get kernel

Parameters:
idx index of kernel
Returns:
kernel at index idx

Definition at line 150 of file CombinedKernel.h.

virtual EKernelType CCombinedKernel::get_kernel_type (  )  [virtual]

return what type of kernel we are

Returns:
kernel type COMBINED

Implements CKernel.

Definition at line 94 of file CombinedKernel.h.

CKernel* CCombinedKernel::get_last_kernel (  ) 

get last kernel

Returns:
last kernel

Definition at line 162 of file CombinedKernel.h.

virtual const char* CCombinedKernel::get_name (  )  [virtual]

return the kernel's name

Returns:
name Combined

Implements CKernel.

Definition at line 121 of file CombinedKernel.h.

CKernel* CCombinedKernel::get_next_kernel ( CListElement< CKernel * > *&  current  ) 

get next kernel multi-thread safe

Parameters:
current 
Returns:
next kernel

Definition at line 183 of file CombinedKernel.h.

CKernel* CCombinedKernel::get_next_kernel ( const CKernel current  ) 

get next kernel

Parameters:
current 
Returns:
next kernel

Definition at line 172 of file CombinedKernel.h.

int32_t CCombinedKernel::get_num_subkernels (  )  [virtual]

get number of subkernels

Returns:
number of subkernels

Reimplemented from CKernel.

Definition at line 245 of file CombinedKernel.h.

const float64_t * CCombinedKernel::get_subkernel_weights ( int32_t &  num_weights  )  [virtual]

get subkernel weights

Parameters:
num_weights where number of weights is stored
Returns:
subkernel weights

Reimplemented from CKernel.

Definition at line 607 of file CombinedKernel.cpp.

bool CCombinedKernel::init ( CFeatures lhs,
CFeatures rhs 
) [virtual]

initialize kernel

Parameters:
lhs features of left-hand side
rhs features of right-hand side
Returns:
if initializing was successful

Reimplemented from CKernel.

Definition at line 78 of file CombinedKernel.cpp.

bool CCombinedKernel::init_optimization ( int32_t  count,
int32_t *  IDX,
float64_t weights 
) [virtual]

initialize optimization

Parameters:
count count
IDX index
weights weights
Returns:
if initializing was successful

Reimplemented from CKernel.

Definition at line 234 of file CombinedKernel.cpp.

bool CCombinedKernel::insert_kernel ( CKernel k  ) 

insert kernel

Parameters:
k kernel
Returns:
if inserting was successful

Definition at line 193 of file CombinedKernel.h.

void CCombinedKernel::list_kernels (  ) 

list kernels

Definition at line 202 of file CombinedKernel.cpp.

virtual bool CCombinedKernel::load_init ( FILE *  src  )  [virtual]

load kernel init_data

NOT IMPLEMENTED!

Parameters:
src file to load from
Returns:
if loading was successful

Implements CKernel.

Definition at line 79 of file CombinedKernel.h.

bool CCombinedKernel::precompute_subkernels (  ) 

precompute all sub-kernels

Definition at line 688 of file CombinedKernel.cpp.

void CCombinedKernel::remove_lhs (  )  [virtual]

remove lhs from kernel

Reimplemented from CKernel.

Definition at line 148 of file CombinedKernel.cpp.

void CCombinedKernel::remove_rhs (  )  [virtual]

remove rhs from kernel

Reimplemented from CKernel.

Definition at line 168 of file CombinedKernel.cpp.

virtual bool CCombinedKernel::save_init ( FILE *  dest  )  [virtual]

save kernel init_data

NOT IMPLEMENTED!

Parameters:
dest file to save to
Returns:
if saving was successful

Implements CKernel.

Definition at line 88 of file CombinedKernel.h.

void CCombinedKernel::set_optimization_type ( EOptimizationType  t  )  [virtual]

set optimization type

Parameters:
t optimization type

Reimplemented from CKernel.

Definition at line 675 of file CombinedKernel.cpp.

void CCombinedKernel::set_subkernel_weights ( float64_t weights,
int32_t  num_weights 
) [virtual]

set subkernel weights

Parameters:
weights new subkernel weights
num_weights number of subkernel weights

Reimplemented from CKernel.

Definition at line 645 of file CombinedKernel.cpp.


Member Data Documentation

if subkernel weights are appended

Definition at line 392 of file CombinedKernel.h.

list of kernels

Definition at line 382 of file CombinedKernel.h.

subkernel weights buffers

Definition at line 390 of file CombinedKernel.h.

int32_t CCombinedKernel::sv_count [protected]

support vector count

Definition at line 384 of file CombinedKernel.h.

int32_t* CCombinedKernel::sv_idx [protected]

support vector index

Definition at line 386 of file CombinedKernel.h.

support vector weights

Definition at line 388 of file CombinedKernel.h.


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

SHOGUN Machine Learning Toolbox - Documentation