00001 /* 00002 * This program is free software; you can redistribute it and/or modify 00003 * it under the terms of the GNU General Public License as published by 00004 * the Free Software Foundation; either version 3 of the License, or 00005 * (at your option) any later version. 00006 * 00007 * Written (W) 2011 Sergey Lisitsyn 00008 * Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society 00009 */ 00010 00011 #ifndef GAUSSIANNAIVEBAYES_H_ 00012 #define GAUSSIANNAIVEBAYES_H_ 00013 00014 #include <shogun/machine/NativeMulticlassMachine.h> 00015 #include <shogun/mathematics/Math.h> 00016 #include <shogun/features/DotFeatures.h> 00017 00018 namespace shogun { 00019 00020 class CLabels; 00021 class CDotFeatures; 00022 class CFeatures; 00023 00035 class CGaussianNaiveBayes : public CNativeMulticlassMachine 00036 { 00037 00038 public: 00039 MACHINE_PROBLEM_TYPE(PT_MULTICLASS) 00040 00041 00044 CGaussianNaiveBayes(); 00045 00050 CGaussianNaiveBayes(CFeatures* train_examples, CLabels* train_labels); 00051 00055 virtual ~CGaussianNaiveBayes(); 00056 00060 virtual void set_features(CFeatures* features); 00061 00065 virtual CFeatures* get_features(); 00066 00071 virtual CMulticlassLabels* apply_multiclass(CFeatures* data=NULL); 00072 00077 virtual float64_t apply_one(int32_t idx); 00078 00082 virtual const char* get_name() const { return "GaussianNaiveBayes"; }; 00083 00087 virtual EMachineType get_classifier_type() { return CT_GAUSSIANNAIVEBAYES; }; 00088 00089 protected: 00090 00095 virtual bool train_machine(CFeatures* data=NULL); 00096 00097 protected: 00098 00100 CDotFeatures* m_features; 00101 00103 int32_t m_min_label; 00104 00106 int32_t m_num_classes; 00107 00109 int32_t m_dim; 00110 00112 SGMatrix<float64_t> m_means; 00113 00115 SGMatrix<float64_t> m_variances; 00116 00118 SGVector<float64_t> m_label_prob; 00119 00121 SGVector<float64_t> m_rates; 00122 }; 00123 00124 } 00125 00126 #endif /* GAUSSIANNAIVEBAYES_H_ */