Public Member Functions | Protected Member Functions | Protected Attributes

CGaussianNaiveBayes Class Reference

Detailed Description

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

\[ P(c) \prod_{i} P(x_i|c) \]

Definition at line 34 of file GaussianNaiveBayes.h.

Inheritance diagram for CGaussianNaiveBayes:
Inheritance graph

List of all members.

Public Member Functions

 CGaussianNaiveBayes ()
 CGaussianNaiveBayes (CFeatures *train_examples, CLabels *train_labels)
virtual ~CGaussianNaiveBayes ()
virtual void set_features (CDotFeatures *features)
virtual CDotFeaturesget_features ()
virtual bool train (CFeatures *data=NULL)
virtual CLabelsapply ()
virtual CLabelsapply (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

 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_tm_means
 means for normal distributions of features
SGVector< float64_tm_variances
 variances for normal distributions of features
SGVector< float64_tm_label_prob
 a priori probabilities of labels
SGVector< float64_tm_rates
 label rates

Constructor & Destructor Documentation

default constructor

Definition at line 20 of file GaussianNaiveBayes.cpp.

CGaussianNaiveBayes ( CFeatures train_examples,
CLabels train_labels 


train_examples train examples
train_labels labels corresponding to train_examples

Definition at line 28 of file GaussianNaiveBayes.cpp.

~CGaussianNaiveBayes (  )  [virtual]


Definition at line 40 of file GaussianNaiveBayes.cpp.

Member Function Documentation

CLabels * apply (  )  [virtual]

classify all examples


Implements CMachine.

Definition at line 161 of file GaussianNaiveBayes.cpp.

CLabels * apply ( CFeatures data  )  [virtual]

classify specified examples

data examples to be classified
labels corresponding to data

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

classifier type

Reimplemented from CMachine.

Definition at line 104 of file GaussianNaiveBayes.h.

virtual CDotFeatures* get_features (  )  [virtual]

get features for classify

current features

Definition at line 67 of file GaussianNaiveBayes.h.

virtual const char* get_name ( void   )  const [virtual]

get name

classifier name

Implements CSGObject.

Definition at line 99 of file GaussianNaiveBayes.h.

float64_t normal_exp ( float64_t  x,
int32_t  l_idx,
int32_t  f_idx 
) [protected]

computes gaussian exponent by x, indexes, m_means and m_variances

x feature value
l_idx index of label
f_idx index of feature
exponent value

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
true if successful

Reimplemented from CMachine.

Definition at line 50 of file GaussianNaiveBayes.cpp.

Member Data Documentation

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.

a priori probabilities of labels

Definition at line 127 of file GaussianNaiveBayes.h.

SGVector<float64_t> m_means [protected]

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.

SGVector<float64_t> m_rates [protected]

label rates

Definition at line 141 of file GaussianNaiveBayes.h.

variances for normal distributions of features

Definition at line 124 of file GaussianNaiveBayes.h.

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation