SHOGUN  4.1.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;
49 {
50  public:
53 
59  CGaussianKernel(int32_t size, float64_t width);
60 
69  float64_t width, int32_t size=10);
70 
71  virtual ~CGaussianKernel();
72 
78 
80  virtual CSGObject* shallow_copy() const;
81 
88  virtual bool init(CFeatures* l, CFeatures* r);
89 
91  virtual void cleanup();
92 
97  virtual EKernelType get_kernel_type() { return K_GAUSSIAN; }
98 
103  virtual const char* get_name() const { return "GaussianKernel"; }
104 
109  virtual void set_width(float64_t w) { width=w; }
110 
115  virtual float64_t get_width() const { return width; }
116 
121  inline void set_compact_enabled(bool compact) { m_compact=compact; }
122 
127  inline bool get_compact_enabled() { return m_compact; }
128 
137  const TParameter* param, index_t index=-1);
138 
139  protected:
148  virtual float64_t compute(int32_t idx_a, int32_t idx_b);
149 
156  virtual void load_serializable_post() throw (ShogunException);
157 
158 
173  virtual float64_t distance(int32_t idx_a, int32_t idx_b);
174  private:
178  void precompute_squared();
179 
186  void precompute_squared_helper(float64_t* &buf, CDotFeatures* df);
187 
188  void init();
189 
190  protected:
192  float64_t width;
198  bool m_compact;
199 };
200 }
201 #endif /* _GAUSSIANKERNEL_H__ */
void set_compact_enabled(bool compact)
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:206
virtual float64_t get_width() const
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:158
virtual bool init(CFeatures *l, CFeatures *r)
virtual void set_width(float64_t w)

SHOGUN Machine Learning Toolbox - Documentation