SHOGUN  v1.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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 
15 
16 namespace shogun
17 {
29 {
30  public:
34  {
35  m_parameters->add(&scale, "scale",
36  "Scale quotient by which kernel is scaled.");
37  }
38 
41  {
42  }
43 
46  virtual bool init(CKernel* k)
47  {
48  CFeatures* old_lhs=k->lhs;
49  CFeatures* old_rhs=k->rhs;
50  k->lhs=old_lhs;
51  k->rhs=old_lhs;
52 
53  scale=k->compute(0, 0);
54 
55  k->lhs=old_lhs;
56  k->rhs=old_rhs;
57 
58  return true;
59  }
60 
66  inline virtual float64_t normalize(
67  float64_t value, int32_t idx_lhs, int32_t idx_rhs)
68  {
69  return value/scale;
70  }
71 
76  inline virtual float64_t normalize_lhs(float64_t value, int32_t idx_lhs)
77  {
78  return value/sqrt(scale);
79  }
80 
85  inline virtual float64_t normalize_rhs(float64_t value, int32_t idx_rhs)
86  {
87  return value/sqrt(scale);
88  }
89 
91  inline virtual const char* get_name() const { return "FirstElementKernelNormalizer"; }
92 
93  protected:
96 };
97 }
98 #endif
virtual float64_t normalize_rhs(float64_t value, int32_t idx_rhs)
virtual float64_t compute(int32_t x, int32_t y)=0
Parameter * m_parameters
Definition: SGObject.h:297
void add(bool *param, const char *name, const char *description="")
Definition: Parameter.cpp:23
double float64_t
Definition: common.h:56
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:810
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:808
The class Features is the base class of all feature objects.
Definition: Features.h:56
The Kernel base class.
Definition: Kernel.h:172
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