source: trunk/lib/classifier/KernelLookup.h @ 517

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

fixed bug in DataLookup2D and created test for EnsembleBuilder?

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.4 KB
Line 
1// $Id: KernelLookup.h 517 2006-02-21 16:35:34Z peter $
2
3#ifndef _theplu_classifier_kernel_lookup_
4#define _theplu_classifier_kernel_lookup_
5
6#include <c++_tools/classifier/Kernel.h>
7#include <c++_tools/classifier/DataLookup2D.h>
8#include <vector>
9
10namespace theplu {
11namespace classifier {
12
13  class KernelFunction;
14
15  ///
16  /// @brief View into sub Kernel
17  ///
18  class KernelLookup : public DataLookup2D
19  {
20
21  public:
22   
23    ///
24    /// Constructor
25    ///
26    KernelLookup(const Kernel&);
27
28    ///
29    /// Contructor taking the Kernel to view into, row index vector,
30    /// and column index vector.
31    ///
32    /// @note For training usage row index shall always be equal to
33    /// column index.
34    ///
35    KernelLookup(const Kernel& kernel, const std::vector<size_t>& row, 
36                 const std::vector<size_t>& column);
37   
38    ///
39    /// Contructor building a sub-KernelLookup from a KernelLookup
40    /// defined by row index vector and column index vector. The
41    /// resulting KernelLookup is independent of the old KernelLookup,
42    /// but is undefined in case underlying Kernel is destroyed.
43    ///
44    /// @note For training usage row index shall always be equal to
45    /// column index.
46    ///
47    KernelLookup(const KernelLookup& kernel, const std::vector<size_t>& row, 
48                 const std::vector<size_t>& column);
49   
50    ///
51    /// Copy constructor
52    ///
53    KernelLookup(const KernelLookup&);
54
55
56    ///
57    /// @return sub-Lookup of the DataLookup2D
58    ///
59    /// @Note Returns a dynamically allocated DataLookup2D, which has
60    /// to be deleted by the caller to avoid memory leaks.
61    ///
62    const KernelLookup* training_data(const std::vector<size_t>& train) const;
63
64
65    ///
66    /// In returned kernel each row corresponds to a training sample
67    /// and each column corresponds to a validation sample.
68    ///
69    /// @return sub-Lookup of the DataLookup2D
70    ///
71    /// @Note Returns a dynamically allocated DataLookup2D, which has
72    /// to be deleted by the caller to avoid memory leaks.
73    ///
74    const KernelLookup* 
75    validation_data(const std::vector<size_t>& train, 
76                    const std::vector<size_t>& validation) const;
77
78
79    ///
80    /// @return element at position (\a row, \a column) in the Kernel
81    /// matrix
82    ///
83    inline double operator()(const size_t row,const size_t column) const
84    { return (*kernel_)(row_index_[row],column_index_[column]); }
85
86   
87
88  private:
89    ///
90    /// Default constructor. Not implemented.
91    ///
92    KernelLookup(void);
93
94    const Kernel* kernel_;
95
96  }; // class KernelLookup
97
98}} // of namespace classifier and namespace theplu
99
100#endif
Note: See TracBrowser for help on using the repository browser.