source: trunk/lib/classifier/Kernel_MEV.h @ 545

Last change on this file since 545 was 545, checked in by Peter, 17 years ago

added feature selection for SVM

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.1 KB
Line 
1// $Id: Kernel_MEV.h 545 2006-03-06 13:35:45Z peter $
2
3#ifndef _theplu_classifier_kernel_mev_
4#define _theplu_classifier_kernel_mev_
5
6#include <c++_tools/classifier/DataLookup1D.h>
7#include <c++_tools/classifier/Kernel.h>
8#include <c++_tools/classifier/KernelFunction.h>
9#include <c++_tools/gslapi/vector.h>
10#include <c++_tools/gslapi/matrix.h>
11
12namespace theplu {
13namespace classifier {
14
15  ///
16  ///   @brief Memory Efficient Kernel
17  ///   Class taking care of the \f$NxN\f$ kernel matrix, where
18  ///   \f$N\f$ is number of samples. Type of Kernel is defined by a
19  ///   KernelFunction. This Memory Efficient Version (MEV) does not
20  ///   store the kernel matrix in memory, but calculates each element
21  ///   when it is needed. When memory allows do always use Kernel_SEV
22  ///   instead.
23  ///   
24  ///   @see also Kernel_SEV
25  ///
26  class Kernel_MEV : public Kernel
27  {
28   
29  public:
30   
31    ///
32    ///   Constructor taking the data matrix and KernelFunction as
33    ///   input.Each column in the data matrix corresponds to one
34    ///   sample. @note Can not handle NaNs.
35    ///
36    inline Kernel_MEV(const MatrixLookup& data, const KernelFunction& kf)
37      : Kernel(data,kf) {}
38
39    ///
40    /// @todo doc
41    ///
42    Kernel_MEV(const Kernel_MEV& kernel, const std::vector<size_t>& index);
43
44
45    ///
46    ///   Destructor
47    ///
48    inline virtual ~Kernel_MEV(void) {};
49
50    ///
51    /// @return Element at position (\a row, \a column) of the Kernel
52    /// matrix
53    ///
54    double operator()(const size_t row, const size_t column) const;
55   
56    ///
57    /// @return kernel element between data @a ve and training sample @a i
58    ///
59    inline double element(const DataLookup1D& vec, const size_t i) const
60    { return kf_->operator()(vec, DataLookup1D(*data_,i)); }
61     
62    inline double element(const DataLookup1D& vec, const DataLookup1D& w, 
63                          const size_t i) const
64    {return (*kf_)(vec, DataLookup1D(*data_,i), w, DataLookup1D(w.size(),1.0));}
65
66    const Kernel_MEV* selected(const std::vector<size_t>& index) const;
67
68    inline bool weighted(void) const { return false; }
69
70  private:
71    ///
72    /// Copy constructor (not implemented)
73    ///
74    Kernel_MEV(const Kernel_MEV&);
75
76  }; // class Kernel_MEV
77
78}} // of namespace classifier and namespace theplu
79
80#endif
Note: See TracBrowser for help on using the repository browser.