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

Last change on this file since 722 was 722, checked in by Markus Ringnér, 15 years ago

Closes #129

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