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

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

trac moved to new location.

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