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