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

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

References #83. Changing project name to yat. Compilation will fail in this revision.

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