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

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

added predict function in SVM supporting weight

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 1.9 KB
Line 
1// $Id: Kernel_MEV.h 542 2006-03-05 15:46:47Z 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    ///   Destructor
41    ///
42    inline virtual ~Kernel_MEV(void) {};
43
44    ///
45    /// @return Element at position (\a row, \a column) of the Kernel
46    /// matrix
47    ///
48    double operator()(const size_t row, const size_t column) const;
49   
50    ///
51    /// @return kernel element between data @a ve and training sample @a i
52    ///
53    inline double element(const DataLookup1D& vec, const size_t i) const
54    { return kf_->operator()(vec, DataLookup1D(data_,i)); }
55     
56    inline double element(const DataLookup1D& vec, const DataLookup1D& w, 
57                          const size_t i) const
58    {return (*kf_)(vec, DataLookup1D(data_,i), w, DataLookup1D(w.size(),1.0));}
59
60  private:
61    ///
62    /// Copy constructor (not implemented)
63    ///
64    Kernel_MEV(const Kernel_MEV&);
65
66  }; // class Kernel_MEV
67
68}} // of namespace classifier and namespace theplu
69
70#endif
Note: See TracBrowser for help on using the repository browser.