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

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

Fixes #170. Almost all inlines removed, some classes have no cc file.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date ID
File size: 2.6 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    /// Generate ensemble. Function trains each member of the Ensemble.
59    ///
60    void build(void);
61
62    ///
63    /// @Return classifier
64    ///
65    const SupervisedClassifier& classifier(size_t i) const;
66     
67    ///
68    /// @Return Number of classifiers in ensemble
69    ///
70    u_long size(void) const;
71
72    ///
73    /// @brief Generate validation data for ensemble
74    ///
75    /// validate()[i][j] return averager for class @a i for sample @a j
76    ///
77    const std::vector<std::vector<statistics::Averager> >& validate(void);
78   
79    /**
80       Predict a dataset using the ensemble.
81       
82       If @a data is a KernelLookup each column should correspond to a
83       test sample and each row should correspond to a training
84       sample. More exactly row \f$ i \f$ in @a data should correspond
85       to the same sample as row/column \f$ i \f$ in the training
86       kernel corresponds to.
87    */
88    void predict(const DataLookup2D& data, 
89                 std::vector<std::vector<statistics::Averager> > &);
90
91  private:
92 
93    const SupervisedClassifier& mother_;
94    SubsetGenerator& subset_;
95    std::vector<SupervisedClassifier*> classifier_;
96    std::vector<std::vector<statistics::Averager> > validation_result_;
97
98  };
99 
100}}} // of namespace classifier, yat, and theplu
101
102#endif
Note: See TracBrowser for help on using the repository browser.