yat  0.13.2pre
NBC.h
1 #ifndef _theplu_yat_classifier_nbc_
2 #define _theplu_yat_classifier_nbc_
3 
4 // $Id: NBC.h 2119 2009-12-12 23:11:43Z peter $
5 
6 /*
7  Copyright (C) 2006 Jari Häkkinen, Peter Johansson, Markus Ringnér
8  Copyright (C) 2007 Jari Häkkinen, Peter Johansson
9  Copyright (C) 2008 Jari Häkkinen, Peter Johansson, Markus Ringnér
10 
11  This file is part of the yat library, http://dev.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 3 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 yat. If not, see <http://www.gnu.org/licenses/>.
25 */
26 
27 #include "SupervisedClassifier.h"
28 #include "yat/utility/Matrix.h"
29 
30 namespace theplu {
31 namespace yat {
32 namespace classifier {
33 
34  class MatrixLookup;
35  class MatrixLookupWeighted;
36  class Target;
37 
46  class NBC : public SupervisedClassifier
47  {
48 
49  public:
53  NBC(void);
54 
55 
59  virtual ~NBC();
60 
61 
62  NBC* make_classifier(void) const;
63 
74  void train(const MatrixLookup&, const Target&);
75 
88  void train(const MatrixLookupWeighted&, const Target&);
89 
110  void predict(const MatrixLookup& data, utility::Matrix& result) const;
111 
133  void predict(const MatrixLookupWeighted& data,utility::Matrix& result) const;
134 
135 
136  private:
137  void standardize_lnP(utility::Matrix& prediction) const;
138 
139  utility::Matrix centroids_;
140  utility::Matrix sigma2_;
141 
142  double sum_logsigma(size_t i) const;
143 
144 
145  };
146 
147 }}} // of namespace classifier, yat, and theplu
148 
149 #endif
General view into utility::Matrix.
Definition: MatrixLookup.h:70
Class for containing sample labels.
Definition: Target.h:47
void predict(const MatrixLookup &data, utility::Matrix &result) const
Predict samples using unweighted data.
void train(const MatrixLookup &, const Target &)
Train the NBC using training data and targets.
Interface class for supervised classifiers that use data in a matrix format.
Definition: SupervisedClassifier.h:56
NBC * make_classifier(void) const
Create an untrained copy of the classifier.
General view into utility::MatrixWeighted.
Definition: MatrixLookupWeighted.h:63
NBC(void)
Constructor.
virtual ~NBC()
Destructor.
Interface to GSL matrix.
Definition: Matrix.h:63
Naive Bayesian Classifier.
Definition: NBC.h:46

Generated on Wed Jan 4 2017 02:23:06 for yat by  doxygen 1.8.5