source: trunk/lib/classifier/KernelWeighted_SEV.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.1 KB
Line 
1// $Id: KernelWeighted_SEV.h 539 2006-03-05 13:33:47Z peter $
2
3#ifndef _theplu_classifier_kernel_weighted_sev_
4#define _theplu_classifier_kernel_weighted_sev_
5
6#include <c++_tools/classifier/DataLookup1D.h>
7#include <c++_tools/classifier/Kernel.h>
8#include <c++_tools/classifier/MatrixLookup.h>
9#include <c++_tools/gslapi/matrix.h>
10#include <c++_tools/gslapi/vector.h>
11
12
13namespace theplu {
14namespace classifier {
15
16  class KernelFunction;
17
18  ///
19  ///   @brief Speed Efficient Kernel
20  ///   Class taking care of the \f$NxN\f$ kernel matrix, where
21  ///   \f$N\f$ is number of samples. Type of Kernel is defined by a
22  ///   KernelFunction. This Speed Efficient Version (SEV) calculated
23  ///   the kernel matrix once and the kernel is stored in
24  ///   memory. When \f$N\f$ is large and the kernel matrix cannot be
25  ///   stored in memory, use Kernel_MEV instead.
26  ///   
27  ///   @see also Kernel_MEV
28  ///
29  class KernelWeighted_SEV : public Kernel
30  {
31   
32  public:
33
34    ///
35    ///   Constructor taking the data matrix and KernelFunction as
36    ///   input. @note Can not handle NaNs. When dealing with missing values,
37    ///   use constructor taking a weight matrix.
38    ///
39    /// @note if @a data, @a kf, or @a weights is destroyed the
40    /// behaviour of the object is undefined
41    ///
42    KernelWeighted_SEV(const MatrixLookup& data, const KernelFunction& kf, 
43                       const MatrixLookup& weights);
44
45   
46    ///
47    /// @return element at position (\a row, \a column) in the Kernel
48    /// matrix
49    ///
50    inline double operator()(const size_t row,const size_t column) const
51    { return kernel_matrix_(row,column); }
52
53    ///
54    /// @return kernel element between data @a ve and training sample @a i
55    ///
56    inline double element(const DataLookup1D& vec, const size_t i) const
57    { 
58      return (*kf_)(vec, DataLookup1D(data_,i), 
59                    DataLookup1D(vec.size(),1.0),
60                    DataLookup1D(weights_,i)); 
61    }
62
63
64  private:
65    /// Copy constructor (not implemented)
66    KernelWeighted_SEV(const KernelWeighted_SEV&);
67
68    gslapi::matrix kernel_matrix_;
69    const MatrixLookup& weights_;
70
71  }; // class Kernel_SEV
72
73}} // of namespace classifier and namespace theplu
74
75#endif
Note: See TracBrowser for help on using the repository browser.