680 |
11 Oct 06 |
jari |
1 |
#ifndef _theplu_yat_classifier_kernel_sev_ |
680 |
11 Oct 06 |
jari |
2 |
#define _theplu_yat_classifier_kernel_sev_ |
306 |
03 May 05 |
peter |
3 |
|
616 |
31 Aug 06 |
jari |
// $Id$ |
616 |
31 Aug 06 |
jari |
5 |
|
675 |
10 Oct 06 |
jari |
6 |
/* |
4359 |
23 Aug 23 |
peter |
Copyright (C) 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 |
306 |
03 May 05 |
peter |
10 |
|
1437 |
25 Aug 08 |
peter |
This file is part of the yat library, http://dev.thep.lu.se/yat |
307 |
03 May 05 |
peter |
12 |
|
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 |
17 |
|
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 |
22 |
|
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 |
25 |
*/ |
675 |
10 Oct 06 |
jari |
26 |
|
680 |
11 Oct 06 |
jari |
27 |
#include "Kernel.h" |
1121 |
22 Feb 08 |
peter |
28 |
#include "yat/utility/Matrix.h" |
675 |
10 Oct 06 |
jari |
29 |
|
306 |
03 May 05 |
peter |
30 |
namespace theplu { |
680 |
11 Oct 06 |
jari |
31 |
namespace yat { |
450 |
15 Dec 05 |
peter |
32 |
namespace classifier { |
306 |
03 May 05 |
peter |
33 |
|
527 |
01 Mar 06 |
peter |
34 |
class DataLookup1D; |
306 |
03 May 05 |
peter |
35 |
class KernelFunction; |
306 |
03 May 05 |
peter |
36 |
|
592 |
24 Aug 06 |
peter |
37 |
/// |
322 |
26 May 05 |
peter |
/// @brief Speed Efficient Kernel |
648 |
14 Sep 06 |
peter |
39 |
/// |
597 |
28 Aug 06 |
markus |
/// Class taking care of the \f$ NxN \f$ kernel matrix, where |
597 |
28 Aug 06 |
markus |
/// \f$ N \f$ is number of samples. Type of Kernel is defined by a |
749 |
11 Feb 07 |
peter |
/// KernelFunction. This Speed Efficient Version (SEV) calculates |
592 |
24 Aug 06 |
peter |
/// the kernel matrix once by construction and the kernel is stored in |
597 |
28 Aug 06 |
markus |
/// memory. When \f$ N \f$ is large and the kernel matrix cannot be |
592 |
24 Aug 06 |
peter |
/// stored in memory, use Kernel_MEV instead. |
592 |
24 Aug 06 |
peter |
46 |
/// |
4200 |
19 Aug 22 |
peter |
47 |
class Kernel_SEV : public Kernel |
306 |
03 May 05 |
peter |
48 |
{ |
4200 |
19 Aug 22 |
peter |
49 |
|
306 |
03 May 05 |
peter |
50 |
public: |
333 |
02 Jun 05 |
jari |
51 |
|
306 |
03 May 05 |
peter |
52 |
/// |
592 |
24 Aug 06 |
peter |
/// Constructor taking the data matrix and KernelFunction as |
592 |
24 Aug 06 |
peter |
/// input. @note Can not handle NaNs. When dealing with missing values, |
592 |
24 Aug 06 |
peter |
/// use KernelWeighted_SEV instead. |
592 |
24 Aug 06 |
peter |
56 |
/// |
658 |
25 Sep 06 |
peter |
57 |
Kernel_SEV(const MatrixLookup&, const KernelFunction&,const bool own=false); |
4200 |
19 Aug 22 |
peter |
58 |
|
322 |
26 May 05 |
peter |
59 |
/// |
628 |
05 Sep 06 |
peter |
/// Constructor taking the data matrix and KernelFunction as |
628 |
05 Sep 06 |
peter |
/// input. @note Can not handle NaNs. When dealing with missing values, |
628 |
05 Sep 06 |
peter |
/// use KernelWeighted_SEV instead. |
545 |
06 Mar 06 |
peter |
63 |
/// |
658 |
25 Sep 06 |
peter |
64 |
Kernel_SEV(const MatrixLookupWeighted&, const KernelFunction&, |
658 |
25 Sep 06 |
peter |
65 |
const bool own=false); |
4200 |
19 Aug 22 |
peter |
66 |
|
628 |
05 Sep 06 |
peter |
67 |
/// |
648 |
14 Sep 06 |
peter |
/// Constructs a Kernel based on selected features defined by @a index |
628 |
05 Sep 06 |
peter |
69 |
/// |
545 |
06 Mar 06 |
peter |
70 |
Kernel_SEV(const Kernel_SEV& kernel, const std::vector<size_t>& index); |
306 |
03 May 05 |
peter |
71 |
|
658 |
25 Sep 06 |
peter |
72 |
|
307 |
03 May 05 |
peter |
73 |
/// |
658 |
25 Sep 06 |
peter |
/// An interface for making new classifier objects. This function |
658 |
25 Sep 06 |
peter |
/// allows for specification at run-time of which kernel to |
658 |
25 Sep 06 |
peter |
/// instatiate (see 'Prototype' in Design Patterns). |
658 |
25 Sep 06 |
peter |
77 |
/// |
1125 |
22 Feb 08 |
peter |
/// @note Returns a dynamically allocated Kernel, which has |
658 |
25 Sep 06 |
peter |
/// to be deleted by the caller to avoid memory leaks. |
658 |
25 Sep 06 |
peter |
80 |
/// |
4200 |
19 Aug 22 |
peter |
81 |
const Kernel_SEV* make_kernel(const MatrixLookup&, |
658 |
25 Sep 06 |
peter |
82 |
const bool own=false) const; |
658 |
25 Sep 06 |
peter |
83 |
|
658 |
25 Sep 06 |
peter |
84 |
|
658 |
25 Sep 06 |
peter |
85 |
/// |
658 |
25 Sep 06 |
peter |
/// An interface for making new classifier objects. This function |
658 |
25 Sep 06 |
peter |
/// allows for specification at run-time of which kernel to |
658 |
25 Sep 06 |
peter |
/// instatiate (see 'Prototype' in Design Patterns). |
658 |
25 Sep 06 |
peter |
89 |
/// |
1125 |
22 Feb 08 |
peter |
/// @note Returns a dynamically allocated Kernel, which has |
658 |
25 Sep 06 |
peter |
/// to be deleted by the caller to avoid memory leaks. |
658 |
25 Sep 06 |
peter |
92 |
/// |
4200 |
19 Aug 22 |
peter |
93 |
const Kernel_SEV* make_kernel(const MatrixLookupWeighted&, |
658 |
25 Sep 06 |
peter |
94 |
const bool own=false) const; |
658 |
25 Sep 06 |
peter |
95 |
|
658 |
25 Sep 06 |
peter |
96 |
|
658 |
25 Sep 06 |
peter |
97 |
/// |
322 |
26 May 05 |
peter |
/// @return element at position (\a row, \a column) in the Kernel |
307 |
03 May 05 |
peter |
/// matrix |
592 |
24 Aug 06 |
peter |
100 |
/// |
658 |
25 Sep 06 |
peter |
101 |
double operator()(const size_t row,const size_t column) const; |
336 |
03 Jun 05 |
peter |
102 |
|
658 |
25 Sep 06 |
peter |
103 |
|
306 |
03 May 05 |
peter |
104 |
private: |
548 |
06 Mar 06 |
peter |
105 |
/// |
548 |
06 Mar 06 |
peter |
/// Copy constructor (not implemented) |
548 |
06 Mar 06 |
peter |
107 |
/// |
548 |
06 Mar 06 |
peter |
108 |
Kernel_SEV(const Kernel_SEV&); |
555 |
08 Mar 06 |
peter |
109 |
const Kernel_SEV& operator=(const Kernel_SEV&); |
548 |
06 Mar 06 |
peter |
110 |
|
548 |
06 Mar 06 |
peter |
111 |
void build_kernel(void); |
548 |
06 Mar 06 |
peter |
112 |
|
1121 |
22 Feb 08 |
peter |
113 |
utility::Matrix kernel_matrix_; |
306 |
03 May 05 |
peter |
114 |
|
307 |
03 May 05 |
peter |
115 |
}; // class Kernel_SEV |
306 |
03 May 05 |
peter |
116 |
|
680 |
11 Oct 06 |
jari |
117 |
}}} // of namespace classifier, yat, and theplu |
306 |
03 May 05 |
peter |
118 |
|
306 |
03 May 05 |
peter |
119 |
#endif |