Public Member Functions | Protected Member Functions | Protected Attributes

CGaussianKernel Class Reference


Detailed Description

The well known Gaussian kernel (swiss army knife for SVMs) computed on CDotFeatures.

It is computed as

\[ k({\bf x},{\bf x'})= exp(-\frac{||{\bf x}-{\bf x'}||^2}{\tau}) \]

where $\tau$ is the kernel width.

The compact version as given in Bart Hamers' thesis Kernel Models for Large Scale Applications (Eq. 4.10) is computed as

\[ k({\bf x},{\bf x'})= max(0, (1-\frac{||{\bf x}-{\bf x'}||}{3\tau})^v)) * exp(-\frac{||{\bf x}-{\bf x'}||^2}{\tau}) \]

where $\tau$ is the kernel width.

Definition at line 44 of file GaussianKernel.h.

Inheritance diagram for CGaussianKernel:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 CGaussianKernel ()
 CGaussianKernel (int32_t size, float64_t width)
 CGaussianKernel (CDotFeatures *l, CDotFeatures *r, float64_t width, int32_t size=10)
virtual ~CGaussianKernel ()
virtual bool init (CFeatures *l, CFeatures *r)
virtual void cleanup ()
virtual EKernelType get_kernel_type ()
virtual const char * get_name () const
virtual void set_width (float64_t w)
virtual float64_t get_width () const
void set_compact_enabled (bool compact)
bool get_compact_enabled ()

Protected Member Functions

virtual float64_t compute (int32_t idx_a, int32_t idx_b)
virtual void load_serializable_post (void) throw (ShogunException)

Protected Attributes

float64_t width
float64_tsq_lhs
float64_tsq_rhs
bool m_compact

Constructor & Destructor Documentation

CGaussianKernel (  ) 

default constructor

Definition at line 22 of file GaussianKernel.cpp.

CGaussianKernel ( int32_t  size,
float64_t  width 
)

constructor

Parameters:
size cache size
width width

Definition at line 28 of file GaussianKernel.cpp.

CGaussianKernel ( CDotFeatures l,
CDotFeatures r,
float64_t  width,
int32_t  size = 10 
)

constructor

Parameters:
l features of left-hand side
r features of right-hand side
width width
size cache size

Definition at line 35 of file GaussianKernel.cpp.

~CGaussianKernel (  )  [virtual]

Definition at line 44 of file GaussianKernel.cpp.


Member Function Documentation

void cleanup (  )  [virtual]

clean up kernel

Reimplemented from CKernel.

Definition at line 49 of file GaussianKernel.cpp.

float64_t compute ( int32_t  idx_a,
int32_t  idx_b 
) [protected, virtual]

compute kernel function for features a and b idx_{a,b} denote the index of the feature vectors in the corresponding feature object

Parameters:
idx_a index a
idx_b index b
Returns:
computed kernel function at indices a,b

Reimplemented from CDotKernel.

Reimplemented in CGaussianShiftKernel.

Definition at line 81 of file GaussianKernel.cpp.

bool get_compact_enabled (  ) 

return value of the compact option

Returns:
whether the compact option is enabled

Definition at line 125 of file GaussianKernel.h.

virtual EKernelType get_kernel_type (  )  [virtual]

return what type of kernel we are

Returns:
kernel type GAUSSIAN

Implements CDotKernel.

Reimplemented in CGaussianShiftKernel.

Definition at line 86 of file GaussianKernel.h.

virtual const char* get_name ( void   )  const [virtual]

return the kernel's name

Returns:
name Gaussian

Reimplemented from CDotKernel.

Reimplemented in CGaussianShiftKernel.

Definition at line 92 of file GaussianKernel.h.

virtual float64_t get_width ( void   )  const [virtual]

return the kernel's width

Returns:
kernel width

Definition at line 107 of file GaussianKernel.h.

bool init ( CFeatures l,
CFeatures r 
) [virtual]

initialize kernel

Parameters:
l features of left-hand side
r features of right-hand side
Returns:
if initializing was successful

free sq_{r,l}hs first

Reimplemented from CDotKernel.

Definition at line 71 of file GaussianKernel.cpp.

void load_serializable_post ( void   )  throw (ShogunException) [protected, virtual]

Can (optionally) be overridden to post-initialize some member variables which are not PARAMETER::ADD'ed. Make sure that at first the overridden method BASE_CLASS::LOAD_SERIALIZABLE_POST is called.

Exceptions:
ShogunException Will be thrown if an error occurres.

Reimplemented from CKernel.

Definition at line 105 of file GaussianKernel.cpp.

void set_compact_enabled ( bool  compact  ) 

set the compact option

Parameters:
compact value of the compact option

Definition at line 116 of file GaussianKernel.h.

virtual void set_width ( float64_t  w  )  [virtual]

set the kernel's width

Parameters:
w kernel width

Definition at line 98 of file GaussianKernel.h.


Member Data Documentation

bool m_compact [protected]

whether compact output enabled

Definition at line 175 of file GaussianKernel.h.

float64_t* sq_lhs [protected]

squared left-hand side

Definition at line 171 of file GaussianKernel.h.

float64_t* sq_rhs [protected]

squared right-hand side

Definition at line 173 of file GaussianKernel.h.

float64_t width [protected]

width

Definition at line 169 of file GaussianKernel.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