1 | #ifndef _theplu_yat_classifier_kernel_mev_ |
---|
2 | #define _theplu_yat_classifier_kernel_mev_ |
---|
3 | |
---|
4 | // $Id$ |
---|
5 | |
---|
6 | /* |
---|
7 | Copyright (C) 2003 Peter Johansson |
---|
8 | Copyright (C) 2004, 2005 Jari Häkkinen, Peter Johansson |
---|
9 | Copyright (C) 2006 Jari Häkkinen, Markus Ringnér, Peter Johansson |
---|
10 | Copyright (C) 2007 Peter Johansson |
---|
11 | |
---|
12 | This file is part of the yat library, http://trac.thep.lu.se/yat |
---|
13 | |
---|
14 | The yat library is free software; you can redistribute it and/or |
---|
15 | modify it under the terms of the GNU General Public License as |
---|
16 | published by the Free Software Foundation; either version 2 of the |
---|
17 | License, or (at your option) any later version. |
---|
18 | |
---|
19 | The yat library is distributed in the hope that it will be useful, |
---|
20 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
21 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
22 | General Public License for more details. |
---|
23 | |
---|
24 | You should have received a copy of the GNU General Public License |
---|
25 | along with this program; if not, write to the Free Software |
---|
26 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
---|
27 | 02111-1307, USA. |
---|
28 | */ |
---|
29 | |
---|
30 | #include "Kernel.h" |
---|
31 | #include "KernelFunction.h" |
---|
32 | |
---|
33 | namespace theplu { |
---|
34 | namespace yat { |
---|
35 | namespace classifier { |
---|
36 | class MatrixLookup; |
---|
37 | class MatrixLookupWeighted; |
---|
38 | |
---|
39 | /// |
---|
40 | /// @brief Memory Efficient Kernel |
---|
41 | /// |
---|
42 | /// Class taking care of the |
---|
43 | /// \f$ NxN \f$ kernel matrix, where \f$ N \f$ is number of |
---|
44 | /// samples. Type of Kernel is defined by a KernelFunction. This |
---|
45 | /// Memory Efficient Version (MEV) does not store the kernel |
---|
46 | /// matrix in memory, but calculates an element when it is |
---|
47 | /// needed. When memory allows do always use Kernel_SEV |
---|
48 | /// instead. |
---|
49 | /// |
---|
50 | class Kernel_MEV : public Kernel |
---|
51 | { |
---|
52 | |
---|
53 | public: |
---|
54 | |
---|
55 | /// |
---|
56 | /// Constructor taking the data matrix and KernelFunction as |
---|
57 | /// input. Each column in the data matrix corresponds to one |
---|
58 | /// sample. @note Can not handle NaNs. |
---|
59 | /// |
---|
60 | Kernel_MEV(const MatrixLookup& data, const KernelFunction& kf, |
---|
61 | const bool own=false); |
---|
62 | |
---|
63 | |
---|
64 | /// |
---|
65 | /// Constructor taking the data matrix and KernelFunction as |
---|
66 | /// input. Each column in the data matrix corresponds to one |
---|
67 | /// sample. @note Can not handle NaNs. |
---|
68 | /// |
---|
69 | Kernel_MEV(const MatrixLookupWeighted& data, const KernelFunction& kf, |
---|
70 | const bool own=false); |
---|
71 | |
---|
72 | |
---|
73 | /// |
---|
74 | /// Constructing a new Kernel based on selected features @a |
---|
75 | /// index. All other seeting are the same. |
---|
76 | /// |
---|
77 | Kernel_MEV(const Kernel_MEV& kernel, const std::vector<size_t>& index); |
---|
78 | |
---|
79 | |
---|
80 | /// |
---|
81 | /// @return Element at position (\a row, \a column) of the Kernel |
---|
82 | /// matrix |
---|
83 | /// |
---|
84 | double operator()(const size_t row, const size_t column) const; |
---|
85 | |
---|
86 | /// |
---|
87 | /// An interface for making new classifier objects. This function |
---|
88 | /// allows for specification at run-time of which kernel to |
---|
89 | /// instatiate (see 'Prototype' in Design Patterns). |
---|
90 | /// |
---|
91 | /// @note Returns a dynamically allocated Kernel, which has |
---|
92 | /// to be deleted by the caller to avoid memory leaks. |
---|
93 | /// |
---|
94 | const Kernel_MEV* make_kernel(const MatrixLookup&, |
---|
95 | const bool own=false) const; |
---|
96 | |
---|
97 | |
---|
98 | /// |
---|
99 | /// An interface for making new classifier objects. This function |
---|
100 | /// allows for specification at run-time of which kernel to |
---|
101 | /// instatiate (see 'Prototype' in Design Patterns). |
---|
102 | /// |
---|
103 | /// @note Returns a dynamically allocated Kernel, which has |
---|
104 | /// to be deleted by the caller to avoid memory leaks. |
---|
105 | /// |
---|
106 | const Kernel_MEV* make_kernel(const MatrixLookupWeighted&, |
---|
107 | const bool own=false) const; |
---|
108 | |
---|
109 | |
---|
110 | private: |
---|
111 | /// |
---|
112 | /// Copy constructor (not implemented) |
---|
113 | /// |
---|
114 | Kernel_MEV(const Kernel_MEV&); |
---|
115 | const Kernel_MEV& operator=(const Kernel_MEV&); |
---|
116 | |
---|
117 | }; // class Kernel_MEV |
---|
118 | |
---|
119 | }}} // of namespace classifier, yat, and theplu |
---|
120 | |
---|
121 | #endif |
---|