yat
0.8.3pre
|
00001 #ifndef _theplu_yat_classifier_nbc_ 00002 #define _theplu_yat_classifier_nbc_ 00003 00004 // $Id: NBC.h 2119 2009-12-12 23:11:43Z peter $ 00005 00006 /* 00007 Copyright (C) 2006 Jari Häkkinen, Peter Johansson, Markus Ringnér 00008 Copyright (C) 2007 Jari Häkkinen, Peter Johansson 00009 Copyright (C) 2008 Jari Häkkinen, Peter Johansson, Markus Ringnér 00010 00011 This file is part of the yat library, http://dev.thep.lu.se/yat 00012 00013 The yat library is free software; you can redistribute it and/or 00014 modify it under the terms of the GNU General Public License as 00015 published by the Free Software Foundation; either version 3 of the 00016 License, or (at your option) any later version. 00017 00018 The yat library is distributed in the hope that it will be useful, 00019 but WITHOUT ANY WARRANTY; without even the implied warranty of 00020 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00021 General Public License for more details. 00022 00023 You should have received a copy of the GNU General Public License 00024 along with yat. If not, see <http://www.gnu.org/licenses/>. 00025 */ 00026 00027 #include "SupervisedClassifier.h" 00028 #include "yat/utility/Matrix.h" 00029 00030 namespace theplu { 00031 namespace yat { 00032 namespace classifier { 00033 00034 class MatrixLookup; 00035 class MatrixLookupWeighted; 00036 class Target; 00037 00046 class NBC : public SupervisedClassifier 00047 { 00048 00049 public: 00053 NBC(void); 00054 00055 00059 virtual ~NBC(); 00060 00061 00062 NBC* make_classifier(void) const; 00063 00074 void train(const MatrixLookup&, const Target&); 00075 00088 void train(const MatrixLookupWeighted&, const Target&); 00089 00110 void predict(const MatrixLookup& data, utility::Matrix& result) const; 00111 00133 void predict(const MatrixLookupWeighted& data,utility::Matrix& result) const; 00134 00135 00136 private: 00137 void standardize_lnP(utility::Matrix& prediction) const; 00138 00139 utility::Matrix centroids_; 00140 utility::Matrix sigma2_; 00141 00142 double sum_logsigma(size_t i) const; 00143 00144 00145 }; 00146 00147 }}} // of namespace classifier, yat, and theplu 00148 00149 #endif