SHOGUN  4.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
FirstElementKernelNormalizer.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) 2008-2009 Soeren Sonnenburg
8  * Copyright (C) 2008-2009 Fraunhofer Institute FIRST and Max-Planck-Society
9  */
10 
11 #ifndef _FIRSTELEMENTKERNELNORMALIZER_H___
12 #define _FIRSTELEMENTKERNELNORMALIZER_H___
13 
14 #include <shogun/lib/config.h>
15 
17 
18 namespace shogun
19 {
31 {
32  public:
36  {
37  SG_ADD(&scale, "scale", "Scale quotient by which kernel is scaled.",
38  MS_AVAILABLE);
39  }
40 
43  {
44  }
45 
48  virtual bool init(CKernel* k)
49  {
50  CFeatures* old_lhs=k->lhs;
51  CFeatures* old_rhs=k->rhs;
52  k->lhs=old_lhs;
53  k->rhs=old_lhs;
54 
55  scale=k->compute(0, 0);
56 
57  k->lhs=old_lhs;
58  k->rhs=old_rhs;
59 
60  return true;
61  }
62 
69  float64_t value, int32_t idx_lhs, int32_t idx_rhs)
70  {
71  return value/scale;
72  }
73 
78  virtual float64_t normalize_lhs(float64_t value, int32_t idx_lhs)
79  {
80  return value/sqrt(scale);
81  }
82 
87  virtual float64_t normalize_rhs(float64_t value, int32_t idx_rhs)
88  {
89  return value/sqrt(scale);
90  }
91 
93  virtual const char* get_name() const { return "FirstElementKernelNormalizer"; }
94 
95  protected:
98 };
99 }
100 #endif
virtual float64_t normalize_rhs(float64_t value, int32_t idx_rhs)
virtual float64_t compute(int32_t x, int32_t y)=0
double float64_t
Definition: common.h:50
Normalize the kernel by a constant obtained from the first element of the kernel matrix, i.e. .
The class Kernel Normalizer defines a function to post-process kernel values.
CFeatures * rhs
feature vectors to occur on right hand side
Definition: Kernel.h:1062
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
virtual float64_t normalize(float64_t value, int32_t idx_lhs, int32_t idx_rhs)
CFeatures * lhs
feature vectors to occur on left hand side
Definition: Kernel.h:1060
The class Features is the base class of all feature objects.
Definition: Features.h:68
The Kernel base class.
Definition: Kernel.h:159
#define SG_ADD(...)
Definition: SGObject.h:84
virtual float64_t normalize_lhs(float64_t value, int32_t idx_lhs)
float64_t scale
scale constant obtained from k(0,0)

SHOGUN Machine Learning Toolbox - Documentation