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

Last change on this file since 675 was 675, checked in by Jari Häkkinen, 15 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 Id
File size: 2.2 KB
Line 
1#ifndef _theplu_classifier_nbc_
2#define _theplu_classifier_nbc_
3
4// $Id: NBC.h 675 2006-10-10 12:08:45Z jari $
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/classifier/SupervisedClassifier.h"
28#include "yat/utility/matrix.h"
29
30namespace theplu {
31namespace classifier { 
32
33  class DataLookup1D;
34  class DataLookup2D;
35  class MatrixLookup;
36  class MatrixLookupWeighted;
37  class Target;
38
39  ///
40  /// @brief Naive Bayesian Classification.
41  ///
42  class NBC : public SupervisedClassifier
43  {
44 
45  public:
46    ///
47    /// Constructor taking the training data, the target vector, and
48    /// the distance measure as input.
49    ///
50    NBC(const MatrixLookup&, const Target&);
51   
52    ///
53    /// Constructor taking the training data with weights, the target
54    /// vector, the distance measure, and a weight matrix for the
55    /// training data as input.
56    ///
57    NBC(const MatrixLookupWeighted&, const Target&);
58
59    virtual ~NBC();
60
61    SupervisedClassifier* make_classifier(const DataLookup2D&, 
62                                          const Target&) const;
63   
64    ///
65    /// Train the classifier using the training data.
66    ///
67    /// @return true if training succedeed.
68    ///
69    bool train();
70
71   
72    ///
73    /// For each sample, calculate the probabilies the sample belong
74    /// to the corresponding class.
75    ///
76    void predict(const DataLookup2D&, utility::matrix&) const;
77
78
79  private:
80    utility::matrix centroids_;
81    utility::matrix sigma_;
82    const DataLookup2D& data_;
83
84  };
85 
86}} // of namespace classifier and namespace theplu
87
88#endif
Note: See TracBrowser for help on using the repository browser.