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