source: trunk/yat/classifier/Kernel_SEV.h @ 676

Last change on this file since 676 was 675, checked in by Jari Häkkinen, 15 years ago

References #83. Changing project name to yat. Compilation will fail in this revision.

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