source: trunk/lib/classifier/KernelWeighted_MEV.h @ 539

Last change on this file since 539 was 539, checked in by Peter, 16 years ago

re-introduced prediction in SVM

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