source: trunk/lib/classifier/KernelWeighted_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 Id
File size: 2.4 KB
Line 
1// $Id: KernelWeighted_MEV.h 545 2006-03-06 13:35:45Z peter $
2
3#ifndef _theplu_classifier_kernel_weighted_mev_
4#define _theplu_classifier_kernel_weighted_mev_
5
6#include <c++_tools/classifier/Kernel.h>
7
8#include <c++_tools/classifier/DataLookup1D.h>
9#include <c++_tools/classifier/KernelFunction.h>
10#include <c++_tools/classifier/MatrixLookup.h>
11//#include <c++_tools/gslapi/matrix.h>
12
13namespace theplu {
14namespace classifier {
15
16  ///
17  ///   @brief Memory Efficient Kernel
18  ///   Class taking care of the \f$NxN\f$ kernel matrix, where
19  ///   \f$N\f$ is number of samples. Type of Kernel is defined by a
20  ///   KernelFunction. This Memory Efficient Version (MEV) does not
21  ///   store the kernel matrix in memory, but calculates each element
22  ///   when it is needed. When memory allows do always use Kernel_SEV
23  ///   instead.
24  ///   
25  ///   @see also KernelWeighted_SEV
26  ///
27  class KernelWeighted_MEV : public Kernel
28  {
29   
30  public:
31   
32    ///
33    ///   Constructor taking the \a data matrix, the KernelFunction and a
34    ///   \a weight matrix as input. Each column in the data matrix
35    ///   corresponds to one sample.
36    ///
37    /// @note if @a data, @a kf, or @a weights is destroyed the
38    /// behaviour of the object is undefined
39    ///
40    KernelWeighted_MEV(const MatrixLookup& data, 
41                       const KernelFunction& kf, 
42                       const MatrixLookup& weights);
43
44    ///
45    /// @todo doc
46    ///
47    KernelWeighted_MEV(const KernelWeighted_MEV& other, 
48                       const std::vector<size_t>& index);
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    { 
61      return (*kf_)(vec, DataLookup1D(*data_,i), 
62                    DataLookup1D(vec.size(),1.0),
63                    DataLookup1D(*weights_,i)); 
64    }
65
66    ///
67    /// @todo doc
68    ///
69    inline double element(const DataLookup1D& vec, const DataLookup1D& w, 
70                          const size_t i) const
71    { 
72      return (*kf_)(vec, DataLookup1D(*data_,i),w,DataLookup1D(*weights_,i)); 
73    }
74
75    ///
76    /// @todo doc
77    ///
78    const Kernel* selected(const std::vector<size_t>& index) const;
79
80    inline bool weighted(void) const { return true; }
81
82  private:
83    ///
84    /// Copy constructor (not implemented)
85    ///
86    KernelWeighted_MEV(const KernelWeighted_MEV&);
87
88
89  };
90
91}} // of namespace classifier and namespace theplu
92
93#endif
Note: See TracBrowser for help on using the repository browser.