source: trunk/c++_tools/classifier/EnsembleBuilder.h @ 655

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

improved documentation on EnsembleBulder::predict

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date ID
File size: 1.8 KB
Line 
1// $Id$
2
3#ifndef _theplu_classifier_ensemblebuilder_
4#define _theplu_classifier_ensemblebuilder_
5
6#include <c++_tools/statistics/Averager.h>
7
8#include <vector>
9
10namespace theplu {
11namespace classifier { 
12
13  class SubsetGenerator;
14  class DataLookup2D;
15  class SupervisedClassifier;
16
17  ///
18  /// Class for ensembles of supervised classifiers
19  ///
20
21  class EnsembleBuilder
22  {
23 
24  public:
25    ///
26    /// Constructor.
27    ///
28    EnsembleBuilder(const SupervisedClassifier&, SubsetGenerator&);
29
30    ///
31    /// Destructor.
32    ///
33    virtual ~EnsembleBuilder(void);
34
35
36    ///
37    /// Generate ensemble. Function trains each member of the Ensemble.
38    ///
39    void build(void);
40
41    ///
42    /// @Return classifier
43    ///
44    inline const SupervisedClassifier& classifier(size_t i) const
45    {
46      return *(classifier_[i]);
47    }
48     
49    ///
50    /// @Return Number of classifiers in ensemble
51    ///
52    inline u_long size(void) const
53    {
54      return classifier_.size();
55    }
56
57    ///
58    /// @brief Generate validation data for ensemble
59    ///
60    /// validate()[i][j] return averager for class @a i for sample @a j
61    ///
62    const std::vector<std::vector<statistics::Averager> >& validate(void);
63   
64    /**
65       Predict a dataset using the ensemble.
66       
67       If @a data is a KernelLookup each column should correspond to a
68       test sample and each row should correspond to a training
69       sample. More exactly row \f$ i \f$ in @a data should correspond
70       to the same sample as row/column \f$ i \f$ in the training
71       kernel corresponds to.
72    */
73    void  predict(const DataLookup2D& data, 
74                  std::vector<std::vector<statistics::Averager> > &);
75
76
77  private:
78 
79    const SupervisedClassifier& mother_;
80    SubsetGenerator& subset_;
81    std::vector<SupervisedClassifier*> classifier_;
82    std::vector<std::vector<statistics::Averager> > validation_result_;
83
84  };
85 
86}} // of namespace classifier and namespace theplu
87
88#endif
Note: See TracBrowser for help on using the repository browser.