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

Last change on this file since 615 was 615, checked in by Peter, 15 years ago

ref #60 NOTE: there is most likely a bug around. I have removed the ensemble.build() test in the ensemble_test to get the test go through. I will try to find and remove this bug asap.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date ID
File size: 1.5 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    void  predict(const DataLookup2D&, 
68                  std::vector<std::vector<statistics::Averager> > &);
69
70
71  private:
72 
73    const SupervisedClassifier& mother_;
74    SubsetGenerator& subset_;
75    std::vector<SupervisedClassifier*> classifier_;
76    std::vector<std::vector<statistics::Averager> > validation_result_;
77
78  };
79 
80}} // of namespace classifier and namespace theplu
81
82#endif
Note: See TracBrowser for help on using the repository browser.