Class GaussianNaiveBayes, a Gaussian Naive Bayes classifier.
This classifier assumes that a posteriori conditional probabilities are gaussian pdfs. For each vector gaussian naive bayes chooses the class C with maximal
Definition at line 34 of file GaussianNaiveBayes.h.
Public Member Functions | |
CGaussianNaiveBayes () | |
CGaussianNaiveBayes (CFeatures *train_examples, CLabels *train_labels) | |
virtual | ~CGaussianNaiveBayes () |
virtual void | set_features (CDotFeatures *features) |
virtual CDotFeatures * | get_features () |
virtual bool | train (CFeatures *data=NULL) |
virtual CLabels * | apply () |
virtual CLabels * | apply (CFeatures *data) |
virtual float64_t | apply (int32_t idx) |
virtual const char * | get_name () const |
virtual EClassifierType | get_classifier_type () |
Protected Member Functions | |
float64_t | normal_exp (float64_t x, int32_t l_idx, int32_t f_idx) |
Protected Attributes | |
CDotFeatures * | m_features |
features for training or classifying | |
int32_t | m_min_label |
minimal label | |
int32_t | m_num_classes |
number of different classes (labels) | |
int32_t | m_dim |
dimensionality of feature space | |
SGVector< float64_t > | m_means |
means for normal distributions of features | |
SGVector< float64_t > | m_variances |
variances for normal distributions of features | |
SGVector< float64_t > | m_label_prob |
a priori probabilities of labels | |
SGVector< float64_t > | m_rates |
label rates |
default constructor
Definition at line 20 of file GaussianNaiveBayes.cpp.
CGaussianNaiveBayes | ( | CFeatures * | train_examples, | |
CLabels * | train_labels | |||
) |
constructor
train_examples | train examples | |
train_labels | labels corresponding to train_examples |
Definition at line 28 of file GaussianNaiveBayes.cpp.
~CGaussianNaiveBayes | ( | ) | [virtual] |
destructor
Definition at line 40 of file GaussianNaiveBayes.cpp.
CLabels * apply | ( | ) | [virtual] |
classify all examples
Implements CMachine.
Definition at line 161 of file GaussianNaiveBayes.cpp.
classify specified examples
data | examples to be classified |
Implements CMachine.
Definition at line 176 of file GaussianNaiveBayes.cpp.
float64_t apply | ( | int32_t | idx | ) | [virtual] |
classifiy specified example
idx | example index |
Reimplemented from CMachine.
Definition at line 191 of file GaussianNaiveBayes.cpp.
virtual EClassifierType get_classifier_type | ( | ) | [virtual] |
get classifier type
Reimplemented from CMachine.
Definition at line 104 of file GaussianNaiveBayes.h.
virtual CDotFeatures* get_features | ( | ) | [virtual] |
get features for classify
Definition at line 67 of file GaussianNaiveBayes.h.
virtual const char* get_name | ( | void | ) | const [virtual] |
get name
Implements CSGObject.
Definition at line 99 of file GaussianNaiveBayes.h.
computes gaussian exponent by x, indexes, m_means and m_variances
x | feature value | |
l_idx | index of label | |
f_idx | index of feature |
Definition at line 135 of file GaussianNaiveBayes.h.
virtual void set_features | ( | CDotFeatures * | features | ) | [virtual] |
set features for classify
features | features to be set |
Definition at line 57 of file GaussianNaiveBayes.h.
bool train | ( | CFeatures * | data = NULL |
) | [virtual] |
train classifier
data | train examples |
Reimplemented from CMachine.
Definition at line 50 of file GaussianNaiveBayes.cpp.
int32_t m_dim [protected] |
dimensionality of feature space
Definition at line 118 of file GaussianNaiveBayes.h.
CDotFeatures* m_features [protected] |
features for training or classifying
Definition at line 104 of file GaussianNaiveBayes.h.
SGVector<float64_t> m_label_prob [protected] |
a priori probabilities of labels
Definition at line 127 of file GaussianNaiveBayes.h.
means for normal distributions of features
Definition at line 121 of file GaussianNaiveBayes.h.
int32_t m_min_label [protected] |
minimal label
Definition at line 112 of file GaussianNaiveBayes.h.
int32_t m_num_classes [protected] |
number of different classes (labels)
Definition at line 115 of file GaussianNaiveBayes.h.
label rates
Definition at line 141 of file GaussianNaiveBayes.h.
SGVector<float64_t> m_variances [protected] |
variances for normal distributions of features
Definition at line 124 of file GaussianNaiveBayes.h.