680 |
11 Oct 06 |
jari |
1 |
#ifndef _theplu_yat_classifier_kernel_mev_ |
680 |
11 Oct 06 |
jari |
2 |
#define _theplu_yat_classifier_kernel_mev_ |
25 |
06 Aug 03 |
peter |
3 |
|
616 |
31 Aug 06 |
jari |
// $Id$ |
616 |
31 Aug 06 |
jari |
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 |
675 |
10 Oct 06 |
jari |
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 "Kernel.h" |
680 |
11 Oct 06 |
jari |
29 |
#include "KernelFunction.h" |
675 |
10 Oct 06 |
jari |
30 |
|
42 |
26 Feb 04 |
jari |
31 |
namespace theplu { |
680 |
11 Oct 06 |
jari |
32 |
namespace yat { |
450 |
15 Dec 05 |
peter |
33 |
namespace classifier { |
628 |
05 Sep 06 |
peter |
34 |
class MatrixLookup; |
628 |
05 Sep 06 |
peter |
35 |
class MatrixLookupWeighted; |
25 |
06 Aug 03 |
peter |
36 |
|
51 |
11 Mar 04 |
peter |
37 |
/// |
4200 |
19 Aug 22 |
peter |
/// @brief Memory Efficient Kernel |
651 |
21 Sep 06 |
peter |
39 |
/// |
651 |
21 Sep 06 |
peter |
/// Class taking care of the |
597 |
28 Aug 06 |
markus |
/// \f$ NxN \f$ kernel matrix, where \f$ N \f$ is number of |
592 |
24 Aug 06 |
peter |
/// samples. Type of Kernel is defined by a KernelFunction. This |
592 |
24 Aug 06 |
peter |
/// Memory Efficient Version (MEV) does not store the kernel |
592 |
24 Aug 06 |
peter |
/// matrix in memory, but calculates an element when it is |
592 |
24 Aug 06 |
peter |
/// needed. When memory allows do always use Kernel_SEV |
4200 |
19 Aug 22 |
peter |
/// instead. |
51 |
11 Mar 04 |
peter |
47 |
/// |
4200 |
19 Aug 22 |
peter |
48 |
class Kernel_MEV : public Kernel |
25 |
06 Aug 03 |
peter |
49 |
{ |
4200 |
19 Aug 22 |
peter |
50 |
|
25 |
06 Aug 03 |
peter |
51 |
public: |
4200 |
19 Aug 22 |
peter |
52 |
|
330 |
01 Jun 05 |
peter |
53 |
/// |
592 |
24 Aug 06 |
peter |
/// Constructor taking the data matrix and KernelFunction as |
749 |
11 Feb 07 |
peter |
/// input. Each column in the data matrix corresponds to one |
4200 |
19 Aug 22 |
peter |
/// sample. @note Can not handle NaNs. |
307 |
03 May 05 |
peter |
57 |
/// |
4200 |
19 Aug 22 |
peter |
58 |
Kernel_MEV(const MatrixLookup& data, const KernelFunction& kf, |
658 |
25 Sep 06 |
peter |
59 |
const bool own=false); |
420 |
02 Dec 05 |
jari |
60 |
|
628 |
05 Sep 06 |
peter |
61 |
|
545 |
06 Mar 06 |
peter |
62 |
/// |
628 |
05 Sep 06 |
peter |
/// Constructor taking the data matrix and KernelFunction as |
749 |
11 Feb 07 |
peter |
/// input. Each column in the data matrix corresponds to one |
4200 |
19 Aug 22 |
peter |
/// sample. @note Can not handle NaNs. |
545 |
06 Mar 06 |
peter |
66 |
/// |
658 |
25 Sep 06 |
peter |
67 |
Kernel_MEV(const MatrixLookupWeighted& data, const KernelFunction& kf, |
658 |
25 Sep 06 |
peter |
68 |
const bool own=false); |
628 |
05 Sep 06 |
peter |
69 |
|
628 |
05 Sep 06 |
peter |
70 |
|
628 |
05 Sep 06 |
peter |
71 |
/// |
648 |
14 Sep 06 |
peter |
/// Constructing a new Kernel based on selected features @a |
648 |
14 Sep 06 |
peter |
/// index. All other seeting are the same. |
628 |
05 Sep 06 |
peter |
74 |
/// |
545 |
06 Mar 06 |
peter |
75 |
Kernel_MEV(const Kernel_MEV& kernel, const std::vector<size_t>& index); |
545 |
06 Mar 06 |
peter |
76 |
|
545 |
06 Mar 06 |
peter |
77 |
|
307 |
03 May 05 |
peter |
78 |
/// |
420 |
02 Dec 05 |
jari |
/// @return Element at position (\a row, \a column) of the Kernel |
307 |
03 May 05 |
peter |
/// matrix |
51 |
11 Mar 04 |
peter |
81 |
/// |
527 |
01 Mar 06 |
peter |
82 |
double operator()(const size_t row, const size_t column) const; |
4200 |
19 Aug 22 |
peter |
83 |
|
658 |
25 Sep 06 |
peter |
84 |
/// |
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 |
88 |
/// |
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 |
91 |
/// |
4200 |
19 Aug 22 |
peter |
92 |
const Kernel_MEV* make_kernel(const MatrixLookup&, |
658 |
25 Sep 06 |
peter |
93 |
const bool own=false) const; |
658 |
25 Sep 06 |
peter |
94 |
|
658 |
25 Sep 06 |
peter |
95 |
|
658 |
25 Sep 06 |
peter |
96 |
/// |
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 |
100 |
/// |
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 |
103 |
/// |
4200 |
19 Aug 22 |
peter |
104 |
const Kernel_MEV* make_kernel(const MatrixLookupWeighted&, |
658 |
25 Sep 06 |
peter |
105 |
const bool own=false) const; |
658 |
25 Sep 06 |
peter |
106 |
|
658 |
25 Sep 06 |
peter |
107 |
|
513 |
18 Feb 06 |
peter |
108 |
private: |
336 |
03 Jun 05 |
peter |
109 |
/// |
513 |
18 Feb 06 |
peter |
/// Copy constructor (not implemented) |
336 |
03 Jun 05 |
peter |
111 |
/// |
513 |
18 Feb 06 |
peter |
112 |
Kernel_MEV(const Kernel_MEV&); |
555 |
08 Mar 06 |
peter |
113 |
const Kernel_MEV& operator=(const Kernel_MEV&); |
25 |
06 Aug 03 |
peter |
114 |
|
307 |
03 May 05 |
peter |
115 |
}; // class Kernel_MEV |
25 |
06 Aug 03 |
peter |
116 |
|
680 |
11 Oct 06 |
jari |
117 |
}}} // of namespace classifier, yat, and theplu |
25 |
06 Aug 03 |
peter |
118 |
|
25 |
06 Aug 03 |
peter |
119 |
#endif |