1 | #ifndef _theplu_yat_classifier_kernel_sev_ |
---|
2 | #define _theplu_yat_classifier_kernel_sev_ |
---|
3 | |
---|
4 | // $Id$ |
---|
5 | |
---|
6 | /* |
---|
7 | Copyright (C) 2005 Jari Häkkinen, Peter Johansson |
---|
8 | Copyright (C) 2006 Jari Häkkinen, Peter Johansson, Markus Ringnér |
---|
9 | Copyright (C) 2007 Jari Häkkinen, Peter Johansson |
---|
10 | Copyright (C) 2008 Peter Johansson |
---|
11 | |
---|
12 | This file is part of the yat library, http://dev.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 "yat/utility/Matrix.h" |
---|
32 | |
---|
33 | namespace theplu { |
---|
34 | namespace yat { |
---|
35 | namespace classifier { |
---|
36 | |
---|
37 | class DataLookup1D; |
---|
38 | class KernelFunction; |
---|
39 | |
---|
40 | /// |
---|
41 | /// @brief Speed Efficient Kernel |
---|
42 | /// |
---|
43 | /// Class taking care of the \f$ NxN \f$ kernel matrix, where |
---|
44 | /// \f$ N \f$ is number of samples. Type of Kernel is defined by a |
---|
45 | /// KernelFunction. This Speed Efficient Version (SEV) calculates |
---|
46 | /// the kernel matrix once by construction and the kernel is stored in |
---|
47 | /// memory. When \f$ N \f$ is large and the kernel matrix cannot be |
---|
48 | /// stored in memory, use Kernel_MEV instead. |
---|
49 | /// |
---|
50 | class Kernel_SEV : public Kernel |
---|
51 | { |
---|
52 | |
---|
53 | public: |
---|
54 | |
---|
55 | /// |
---|
56 | /// Constructor taking the data matrix and KernelFunction as |
---|
57 | /// input. @note Can not handle NaNs. When dealing with missing values, |
---|
58 | /// use KernelWeighted_SEV instead. |
---|
59 | /// |
---|
60 | Kernel_SEV(const MatrixLookup&, const KernelFunction&,const bool own=false); |
---|
61 | |
---|
62 | /// |
---|
63 | /// Constructor taking the data matrix and KernelFunction as |
---|
64 | /// input. @note Can not handle NaNs. When dealing with missing values, |
---|
65 | /// use KernelWeighted_SEV instead. |
---|
66 | /// |
---|
67 | Kernel_SEV(const MatrixLookupWeighted&, const KernelFunction&, |
---|
68 | const bool own=false); |
---|
69 | |
---|
70 | /// |
---|
71 | /// Constructs a Kernel based on selected features defined by @a index |
---|
72 | /// |
---|
73 | Kernel_SEV(const Kernel_SEV& kernel, const std::vector<size_t>& index); |
---|
74 | |
---|
75 | |
---|
76 | /// |
---|
77 | /// An interface for making new classifier objects. This function |
---|
78 | /// allows for specification at run-time of which kernel to |
---|
79 | /// instatiate (see 'Prototype' in Design Patterns). |
---|
80 | /// |
---|
81 | /// @note Returns a dynamically allocated Kernel, which has |
---|
82 | /// to be deleted by the caller to avoid memory leaks. |
---|
83 | /// |
---|
84 | const Kernel_SEV* make_kernel(const MatrixLookup&, |
---|
85 | const bool own=false) const; |
---|
86 | |
---|
87 | |
---|
88 | /// |
---|
89 | /// An interface for making new classifier objects. This function |
---|
90 | /// allows for specification at run-time of which kernel to |
---|
91 | /// instatiate (see 'Prototype' in Design Patterns). |
---|
92 | /// |
---|
93 | /// @note Returns a dynamically allocated Kernel, which has |
---|
94 | /// to be deleted by the caller to avoid memory leaks. |
---|
95 | /// |
---|
96 | const Kernel_SEV* make_kernel(const MatrixLookupWeighted&, |
---|
97 | const bool own=false) const; |
---|
98 | |
---|
99 | |
---|
100 | /// |
---|
101 | /// @return element at position (\a row, \a column) in the Kernel |
---|
102 | /// matrix |
---|
103 | /// |
---|
104 | double operator()(const size_t row,const size_t column) const; |
---|
105 | |
---|
106 | |
---|
107 | private: |
---|
108 | /// |
---|
109 | /// Copy constructor (not implemented) |
---|
110 | /// |
---|
111 | Kernel_SEV(const Kernel_SEV&); |
---|
112 | const Kernel_SEV& operator=(const Kernel_SEV&); |
---|
113 | |
---|
114 | void build_kernel(void); |
---|
115 | |
---|
116 | utility::Matrix kernel_matrix_; |
---|
117 | |
---|
118 | }; // class Kernel_SEV |
---|
119 | |
---|
120 | }}} // of namespace classifier, yat, and theplu |
---|
121 | |
---|
122 | #endif |
---|