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

Last change on this file since 749 was 749, checked in by Peter, 15 years ago

fixes #72

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date ID
File size: 3.5 KB
Line 
1#ifndef _theplu_yat_classifier_kernel_sev_
2#define _theplu_yat_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 "Kernel.h"
28#include "yat/utility/matrix.h"
29
30namespace theplu {
31namespace yat {
32namespace classifier {
33
34  class DataLookup1D;
35  class KernelFunction;
36
37  ///
38  ///   @brief Speed Efficient Kernel
39  ///
40  ///   Class taking care of the \f$ NxN \f$ kernel matrix, where
41  ///   \f$ N \f$ is number of samples. Type of Kernel is defined by a
42  ///   KernelFunction. This Speed Efficient Version (SEV) calculates
43  ///   the kernel matrix once by construction and the kernel is stored in
44  ///   memory. When \f$ N \f$ is large and the kernel matrix cannot be
45  ///   stored in memory, use Kernel_MEV instead.
46  ///
47  class Kernel_SEV : public Kernel
48  {
49   
50  public:
51
52    ///
53    /// Constructor taking the data matrix and KernelFunction as
54    /// input. @note Can not handle NaNs. When dealing with missing values,
55    /// use KernelWeighted_SEV instead.
56    ///
57    Kernel_SEV(const MatrixLookup&, const KernelFunction&,const bool own=false);
58   
59    ///
60    /// Constructor taking the data matrix and KernelFunction as
61    /// input. @note Can not handle NaNs. When dealing with missing values,
62    /// use KernelWeighted_SEV instead.
63    ///
64    Kernel_SEV(const MatrixLookupWeighted&, const KernelFunction&,
65               const bool own=false);
66   
67    ///
68    /// Constructs a Kernel based on selected features defined by @a index
69    ///
70    Kernel_SEV(const Kernel_SEV& kernel, const std::vector<size_t>& index);
71
72
73    ///
74    /// An interface for making new classifier objects. This function
75    /// allows for specification at run-time of which kernel to
76    /// instatiate (see 'Prototype' in Design Patterns).
77    ///
78    /// @Note Returns a dynamically allocated Kernel, which has
79    /// to be deleted by the caller to avoid memory leaks.
80    ///
81    const Kernel_SEV* make_kernel(const MatrixLookup&, 
82                                  const bool own=false) const;
83
84
85    ///
86    /// An interface for making new classifier objects. This function
87    /// allows for specification at run-time of which kernel to
88    /// instatiate (see 'Prototype' in Design Patterns).
89    ///
90    /// @Note Returns a dynamically allocated Kernel, which has
91    /// to be deleted by the caller to avoid memory leaks.
92    ///
93    const Kernel_SEV* make_kernel(const MatrixLookupWeighted&, 
94                                  const bool own=false) const;
95
96
97    ///
98    /// @return element at position (\a row, \a column) in the Kernel
99    /// matrix
100    ///
101    double operator()(const size_t row,const size_t column) const;
102
103
104  private:
105    ///
106    /// Copy constructor (not implemented)
107    ///
108    Kernel_SEV(const Kernel_SEV&);
109    const Kernel_SEV& operator=(const Kernel_SEV&);
110
111    void build_kernel(void);
112
113    utility::matrix kernel_matrix_;
114
115  }; // class Kernel_SEV
116
117}}} // of namespace classifier, yat, and theplu
118
119#endif
Note: See TracBrowser for help on using the repository browser.