SHOGUN  4.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
GaussianKernel.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * Written (W) 1999-2010 Soeren Sonnenburg
8  * Written (W) 2011 Abhinav Maurya
9  * Written (W) 2012 Heiko Strathmann
10  * Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society
11  * Copyright (C) 2010 Berlin Institute of Technology
12  */
13 
14 #ifndef GAUSSIANKERNEL_H
15 #define GAUSSIANKERNEL_H
16 
17 #include <shogun/lib/config.h>
18 
19 #include <shogun/lib/common.h>
20 #include <shogun/kernel/Kernel.h>
23 
24 namespace shogun
25 {
26  class CDotFeatures;
40 {
41  public:
44 
50  CGaussianKernel(int32_t size, float64_t width);
51 
60  float64_t width, int32_t size=10);
61 
62  virtual ~CGaussianKernel();
63 
69 
71  virtual CSGObject* shallow_copy() const;
72 
79  virtual bool init(CFeatures* l, CFeatures* r);
80 
82  virtual void cleanup();
83 
88  virtual EKernelType get_kernel_type() { return K_GAUSSIAN; }
89 
94  virtual const char* get_name() const { return "GaussianKernel"; }
95 
100  virtual void set_width(float64_t w);
101 
106  virtual float64_t get_width() const;
107 
116  const TParameter* param, index_t index=-1);
117 
118  protected:
127  virtual float64_t compute(int32_t idx_a, int32_t idx_b);
128 
135  virtual void load_serializable_post() throw (ShogunException);
136 
137 
152  virtual float64_t distance(int32_t idx_a, int32_t idx_b);
153  private:
157  void precompute_squared();
158 
165  void precompute_squared_helper(float64_t* &buf, CDotFeatures* df);
166 
167  void init();
168 
169  protected:
176 };
177 }
178 #endif /* _GAUSSIANKERNEL_H__ */
EKernelType
Definition: Kernel.h:57
int32_t index_t
Definition: common.h:62
virtual void load_serializable_post()
Class ShogunException defines an exception which is thrown whenever an error inside of shogun occurs...
virtual float64_t distance(int32_t idx_a, int32_t idx_b)
parameter struct
float64_t kernel(int32_t idx_a, int32_t idx_b)
Definition: Kernel.h:207
virtual float64_t compute(int32_t idx_a, int32_t idx_b)
Features that support dot products among other operations.
Definition: DotFeatures.h:44
Template class DotKernel is the base class for kernels working on DotFeatures.
Definition: DotKernel.h:31
Class SGObject is the base class of all shogun objects.
Definition: SGObject.h:112
virtual EKernelType get_kernel_type()
virtual SGMatrix< float64_t > get_parameter_gradient(const TParameter *param, index_t index=-1)
double float64_t
Definition: common.h:50
virtual CSGObject * shallow_copy() const
The well known Gaussian kernel (swiss army knife for SVMs) computed on CDotFeatures.
static CGaussianKernel * obtain_from_generic(CKernel *kernel)
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
The class Features is the base class of all feature objects.
Definition: Features.h:68
virtual const char * get_name() const
The Kernel base class.
Definition: Kernel.h:159
virtual bool init(CFeatures *l, CFeatures *r)
virtual void set_width(float64_t w)
virtual float64_t get_width() const

SHOGUN Machine Learning Toolbox - Documentation