source: trunk/yat/classifier/EnsembleBuilder.h @ 680

Last change on this file since 680 was 680, checked in by Jari Häkkinen, 15 years ago

Addresses #153. Introduced yat namespace. Removed alignment namespace. Clean up of code.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date ID
File size: 2.7 KB
Line 
1#ifndef _theplu_yat_classifier_ensemblebuilder_
2#define _theplu_yat_classifier_ensemblebuilder_
3
4// $Id$
5
6/*
7  Copyright (C) The authors contributing to this file.
8
9  This file is part of the yat library, http://lev.thep.lu.se/trac/yat
10
11  The yat library is free software; you can redistribute it and/or
12  modify it under the terms of the GNU General Public License as
13  published by the Free Software Foundation; either version 2 of the
14  License, or (at your option) any later version.
15
16  The yat library is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  General Public License for more details.
20
21  You should have received a copy of the GNU General Public License
22  along with this program; if not, write to the Free Software
23  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
24  02111-1307, USA.
25*/
26
27#include "yat/statistics/Averager.h"
28
29#include <vector>
30
31namespace theplu {
32namespace yat {
33namespace classifier { 
34
35  class SubsetGenerator;
36  class DataLookup2D;
37  class SupervisedClassifier;
38
39  ///
40  /// Class for ensembles of supervised classifiers
41  ///
42
43  class EnsembleBuilder
44  {
45 
46  public:
47    ///
48    /// Constructor.
49    ///
50    EnsembleBuilder(const SupervisedClassifier&, SubsetGenerator&);
51
52    ///
53    /// Destructor.
54    ///
55    virtual ~EnsembleBuilder(void);
56
57
58    ///
59    /// Generate ensemble. Function trains each member of the Ensemble.
60    ///
61    void build(void);
62
63    ///
64    /// @Return classifier
65    ///
66    inline const SupervisedClassifier& classifier(size_t i) const
67    {
68      return *(classifier_[i]);
69    }
70     
71    ///
72    /// @Return Number of classifiers in ensemble
73    ///
74    inline u_long size(void) const
75    {
76      return classifier_.size();
77    }
78
79    ///
80    /// @brief Generate validation data for ensemble
81    ///
82    /// validate()[i][j] return averager for class @a i for sample @a j
83    ///
84    const std::vector<std::vector<statistics::Averager> >& validate(void);
85   
86    /**
87       Predict a dataset using the ensemble.
88       
89       If @a data is a KernelLookup each column should correspond to a
90       test sample and each row should correspond to a training
91       sample. More exactly row \f$ i \f$ in @a data should correspond
92       to the same sample as row/column \f$ i \f$ in the training
93       kernel corresponds to.
94    */
95    void  predict(const DataLookup2D& data, 
96                  std::vector<std::vector<statistics::Averager> > &);
97
98
99  private:
100 
101    const SupervisedClassifier& mother_;
102    SubsetGenerator& subset_;
103    std::vector<SupervisedClassifier*> classifier_;
104    std::vector<std::vector<statistics::Averager> > validation_result_;
105
106  };
107 
108}}} // of namespace classifier, yat, and theplu
109
110#endif
Note: See TracBrowser for help on using the repository browser.