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

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

Fixes #176

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date ID
File size: 2.8 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 DataLookup2D;
36  class FeatureSelector;
37  class Sampler;
38  class SupervisedClassifier;
39  class SubsetGenerator;
40
41  ///
42  /// Class for ensembles of supervised classifiers
43  ///
44
45  class EnsembleBuilder
46  {
47 
48  public:
49    ///
50    /// Constructor.
51    ///
52    EnsembleBuilder(const SupervisedClassifier&, const Sampler&);
53
54    ///
55    /// Constructor.
56    ///
57    EnsembleBuilder(const SupervisedClassifier&, const Sampler&, 
58                    FeatureSelector&);
59
60    ///
61    /// Destructor.
62    ///
63    virtual ~EnsembleBuilder(void);
64
65    ///
66    /// Generate ensemble. Function trains each member of the Ensemble.
67    ///
68    void build(void);
69
70    ///
71    /// @Return classifier
72    ///
73    const SupervisedClassifier& classifier(size_t i) const;
74     
75    ///
76    /// @Return Number of classifiers in ensemble
77    ///
78    u_long size(void) const;
79
80    ///
81    /// @brief Generate validation data for ensemble
82    ///
83    /// validate()[i][j] return averager for class @a i for sample @a j
84    ///
85    const std::vector<std::vector<statistics::Averager> >& validate(void);
86   
87    /**
88       Predict a dataset using the ensemble.
89       
90       If @a data is a KernelLookup each column should correspond to a
91       test sample and each row should correspond to a training
92       sample. More exactly row \f$ i \f$ in @a data should correspond
93       to the same sample as row/column \f$ i \f$ in the training
94       kernel corresponds to.
95    */
96    void predict(const DataLookup2D& data, 
97                 std::vector<std::vector<statistics::Averager> > &);
98
99  private:
100    EnsembleBuilder(const EnsembleBuilder&);
101    const EnsembleBuilder& operator=(const EnsembleBuilder&);
102   
103
104    const SupervisedClassifier& mother_;
105    SubsetGenerator* subset_;
106    std::vector<SupervisedClassifier*> classifier_;
107    std::vector<std::vector<statistics::Averager> > validation_result_;
108
109  };
110 
111}}} // of namespace classifier, yat, and theplu
112
113#endif
Note: See TracBrowser for help on using the repository browser.