yat  0.21pre
NBC.h
1 #ifndef _theplu_yat_classifier_nbc_
2 #define _theplu_yat_classifier_nbc_
3 
4 // $Id: NBC.h 4207 2022-08-26 04:36:28Z 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  Copyright (C) 2022 Peter Johansson
11 
12  This file is part of the yat library, http://dev.thep.lu.se/yat
13 
14  The yat library is free software; you can redistribute it and/or
15  modify it under the terms of the GNU General Public License as
16  published by the Free Software Foundation; either version 3 of the
17  License, or (at your option) any later version.
18 
19  The yat library is distributed in the hope that it will be useful,
20  but WITHOUT ANY WARRANTY; without even the implied warranty of
21  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22  General Public License for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with yat. If not, see <http://www.gnu.org/licenses/>.
26 */
27 
28 #include "SupervisedClassifier.h"
29 #include "yat/utility/Matrix.h"
30 
31 namespace theplu {
32 namespace yat {
33 namespace classifier {
34 
35  class MatrixLookup;
36  class MatrixLookupWeighted;
37  class Target;
38 
47  class NBC : public SupervisedClassifier
48  {
49 
50  public:
54  NBC(void);
55 
56 
60  virtual ~NBC();
61 
62 
63  NBC* make_classifier(void) const;
64 
75  void train(const MatrixLookup&, const Target&);
76 
89  void train(const MatrixLookupWeighted&, const Target&);
90 
111  void predict(const MatrixLookup& data, utility::Matrix& result) const;
112 
134  void predict(const MatrixLookupWeighted& data,utility::Matrix& result) const;
135 
136 
137  private:
138  void standardize_lnP(utility::Matrix& prediction) const;
139 
140  utility::Matrix centroids_;
141  utility::Matrix sigma2_;
142 
143  double sum_logsigma(size_t i) const;
144 
145 
146  };
147 
148 }}} // of namespace classifier, yat, and theplu
149 
150 #endif
General view into utility::Matrix.
Definition: MatrixLookup.h:70
Class for containing sample labels.
Definition: Target.h:47
The Department of Theoretical Physics namespace as we define it.
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:57
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:104
Naive Bayesian Classifier.
Definition: NBC.h:47

Generated on Wed Jan 25 2023 03:34:29 for yat by  doxygen 1.8.14