680 |
11 Oct 06 |
jari |
1 |
#ifndef _theplu_yat_classifier_polynomial_kernel_function_ |
680 |
11 Oct 06 |
jari |
2 |
#define _theplu_yat_classifier_polynomial_kernel_function_ |
25 |
06 Aug 03 |
peter |
3 |
|
627 |
05 Sep 06 |
peter |
// $Id$ |
627 |
05 Sep 06 |
peter |
5 |
|
675 |
10 Oct 06 |
jari |
6 |
/* |
831 |
27 Mar 07 |
peter |
Copyright (C) 2003 Peter Johansson |
4359 |
23 Aug 23 |
peter |
Copyright (C) 2004, 2005, 2006 Jari Häkkinen, Peter Johansson |
4359 |
23 Aug 23 |
peter |
Copyright (C) 2007 Peter Johansson |
4359 |
23 Aug 23 |
peter |
Copyright (C) 2008 Jari Häkkinen, Peter Johansson |
25 |
06 Aug 03 |
peter |
11 |
|
1437 |
25 Aug 08 |
peter |
This file is part of the yat library, http://dev.thep.lu.se/yat |
527 |
01 Mar 06 |
peter |
13 |
|
675 |
10 Oct 06 |
jari |
The yat library is free software; you can redistribute it and/or |
675 |
10 Oct 06 |
jari |
modify it under the terms of the GNU General Public License as |
1486 |
09 Sep 08 |
jari |
published by the Free Software Foundation; either version 3 of the |
675 |
10 Oct 06 |
jari |
License, or (at your option) any later version. |
675 |
10 Oct 06 |
jari |
18 |
|
675 |
10 Oct 06 |
jari |
The yat library is distributed in the hope that it will be useful, |
675 |
10 Oct 06 |
jari |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
675 |
10 Oct 06 |
jari |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
675 |
10 Oct 06 |
jari |
General Public License for more details. |
675 |
10 Oct 06 |
jari |
23 |
|
675 |
10 Oct 06 |
jari |
You should have received a copy of the GNU General Public License |
1487 |
10 Sep 08 |
jari |
along with yat. If not, see <http://www.gnu.org/licenses/>. |
675 |
10 Oct 06 |
jari |
26 |
*/ |
675 |
10 Oct 06 |
jari |
27 |
|
680 |
11 Oct 06 |
jari |
28 |
#include "KernelFunction.h" |
675 |
10 Oct 06 |
jari |
29 |
|
345 |
08 Jun 05 |
jari |
30 |
#include <cmath> |
345 |
08 Jun 05 |
jari |
31 |
|
42 |
26 Feb 04 |
jari |
32 |
namespace theplu { |
680 |
11 Oct 06 |
jari |
33 |
namespace yat { |
450 |
15 Dec 05 |
peter |
34 |
namespace classifier { |
42 |
26 Feb 04 |
jari |
35 |
|
747 |
11 Feb 07 |
peter |
36 |
class DataLookup1D; |
747 |
11 Feb 07 |
peter |
37 |
|
67 |
27 Apr 04 |
peter |
38 |
/// |
767 |
22 Feb 07 |
peter |
/// @brief Class for polynomial kernel calculations |
163 |
22 Sep 04 |
peter |
40 |
/// |
25 |
06 Aug 03 |
peter |
41 |
|
4200 |
19 Aug 22 |
peter |
42 |
|
4200 |
19 Aug 22 |
peter |
43 |
class PolynomialKernelFunction : public KernelFunction |
25 |
06 Aug 03 |
peter |
44 |
{ |
4200 |
19 Aug 22 |
peter |
45 |
|
25 |
06 Aug 03 |
peter |
46 |
public: |
163 |
22 Sep 04 |
peter |
47 |
/// |
163 |
22 Sep 04 |
peter |
///Constructor taking the order of the polynomial as input. Default is |
67 |
27 Apr 04 |
peter |
///order=1 yielding the linear kernel function. |
67 |
27 Apr 04 |
peter |
50 |
/// |
25 |
06 Aug 03 |
peter |
51 |
PolynomialKernelFunction(int = 1); |
4200 |
19 Aug 22 |
peter |
52 |
|
100 |
10 Jun 04 |
peter |
53 |
/// |
67 |
27 Apr 04 |
peter |
///Destructor |
67 |
27 Apr 04 |
peter |
55 |
/// |
100 |
10 Jun 04 |
peter |
56 |
virtual ~PolynomialKernelFunction(void) {}; |
4200 |
19 Aug 22 |
peter |
57 |
|
163 |
22 Sep 04 |
peter |
58 |
/// |
627 |
05 Sep 06 |
peter |
/// returning the scalar product of two vectors in feature space using the |
627 |
05 Sep 06 |
peter |
/// polynomial kernel. @return If order is larger than one: \f$ (1+x \cdot |
627 |
05 Sep 06 |
peter |
/// y)^{order} \f$ \n If order is one (linear): \f$ x \cdot y \f$ |
4200 |
19 Aug 22 |
peter |
62 |
/// |
627 |
05 Sep 06 |
peter |
63 |
double operator()(const DataLookup1D& a1, const DataLookup1D& a2) const; |
67 |
27 Apr 04 |
peter |
64 |
|
627 |
05 Sep 06 |
peter |
65 |
/// |
627 |
05 Sep 06 |
peter |
/// @return If order is larger than one: \f$ (1+x \cdot y)^{order} |
648 |
14 Sep 06 |
peter |
/// \f$ \n If order is one (linear): \f$ \sum w_yxy \f$ |
627 |
05 Sep 06 |
peter |
68 |
/// |
627 |
05 Sep 06 |
peter |
69 |
/// |
4200 |
19 Aug 22 |
peter |
70 |
double operator()(const DataLookup1D& x, |
627 |
05 Sep 06 |
peter |
71 |
const DataLookupWeighted1D& y) const; |
627 |
05 Sep 06 |
peter |
72 |
/// |
627 |
05 Sep 06 |
peter |
/// returning the scalar product of two vectors in feature space |
627 |
05 Sep 06 |
peter |
/// using the polynomial kernel with weights. Having all weights |
627 |
05 Sep 06 |
peter |
/// equal to unity yields the same as non-weighted version. |
627 |
05 Sep 06 |
peter |
76 |
/// |
627 |
05 Sep 06 |
peter |
/// @return If order is larger than one: \f$ (1+x \cdot y)^{order} |
648 |
14 Sep 06 |
peter |
/// \f$ \n If order is one (linear): \f$ \sum w_xw_yxy \f$ |
627 |
05 Sep 06 |
peter |
79 |
/// |
4200 |
19 Aug 22 |
peter |
80 |
double operator()(const DataLookupWeighted1D& x, |
627 |
05 Sep 06 |
peter |
81 |
const DataLookupWeighted1D& y) const; |
345 |
08 Jun 05 |
jari |
82 |
|
627 |
05 Sep 06 |
peter |
83 |
|
25 |
06 Aug 03 |
peter |
84 |
private: |
25 |
06 Aug 03 |
peter |
85 |
int order_; |
25 |
06 Aug 03 |
peter |
86 |
|
25 |
06 Aug 03 |
peter |
87 |
}; // class PolynomialKernelFunction |
25 |
06 Aug 03 |
peter |
88 |
|
680 |
11 Oct 06 |
jari |
89 |
}}} // of namespace classifier, yat, and theplu |
25 |
06 Aug 03 |
peter |
90 |
|
25 |
06 Aug 03 |
peter |
91 |
#endif |