GClasses
|
A naive Bayes classifier. More...
#include <GNaiveBayes.h>
Public Member Functions | |
GNaiveBayes (GRand &rand) | |
GNaiveBayes (GDomNode *pNode, GLearnerLoader &ll) | |
Load from a DOM. | |
virtual | ~GNaiveBayes () |
virtual GDomNode * | serialize (GDom *pDoc) |
Marshal this object into a DOM, which can then be converted to a variety of serial formats. | |
virtual void | trainSparse (GSparseMatrix &features, GMatrix &labels) |
See the comment for GIncrementalLearner::trainSparse This method assumes that the values in pData are all binary values (0 or 1). | |
void | setEquivalentSampleSize (double d) |
To ensure that unsampled values don't dominate the joint distribution by multiplying by a zero, each value is given at least as much representation as specified here. (The default is 0.5, which is as if there were half of a sample for each value.) | |
double | equivalentSampleSize () |
Returns the equivalent sample size. (The number of samples of each possible value that is added by default to prevent zeros.) | |
virtual void | clear () |
See the comment for GSupervisedLearner::clear. | |
void | autoTune (GMatrix &features, GMatrix &labels) |
Uses cross-validation to find a set of parameters that works well with the provided data. | |
Static Public Member Functions | |
static void | test () |
Performs unit tests for this class. Throws an exception if there is a failure. | |
Protected Member Functions | |
virtual void | trainInner (GMatrix &features, GMatrix &labels) |
See the comment for GSupervisedLearner::trainInner. | |
virtual void | predictInner (const double *pIn, double *pOut) |
See the comment for GSupervisedLearner::predictInner. | |
virtual void | predictDistributionInner (const double *pIn, GPrediction *pOut) |
See the comment for GSupervisedLearner::predictDistributionInner. | |
virtual bool | canImplicitlyHandleContinuousFeatures () |
See the comment for GTransducer::canImplicitlyHandleContinuousFeatures. | |
virtual bool | canImplicitlyHandleContinuousLabels () |
See the comment for GTransducer::canImplicitlyHandleContinuousLabels. | |
virtual void | beginIncrementalLearningInner (sp_relation &pFeatureRel, sp_relation &pLabelRel) |
See the comment for GIncrementalLearner::beginIncrementalLearningInner. | |
virtual void | trainIncrementalInner (const double *pIn, const double *pOut) |
Adds a single training sample to the collection. | |
Protected Attributes | |
sp_relation | m_pFeatureRel |
sp_relation | m_pLabelRel |
size_t | m_nSampleCount |
GNaiveBayesOutputAttr ** | m_pOutputs |
double | m_equivalentSampleSize |
A naive Bayes classifier.
GClasses::GNaiveBayes::GNaiveBayes | ( | GRand & | rand | ) |
GClasses::GNaiveBayes::GNaiveBayes | ( | GDomNode * | pNode, |
GLearnerLoader & | ll | ||
) |
Load from a DOM.
virtual GClasses::GNaiveBayes::~GNaiveBayes | ( | ) | [virtual] |
Uses cross-validation to find a set of parameters that works well with the provided data.
virtual void GClasses::GNaiveBayes::beginIncrementalLearningInner | ( | sp_relation & | pFeatureRel, |
sp_relation & | pLabelRel | ||
) | [protected, virtual] |
See the comment for GIncrementalLearner::beginIncrementalLearningInner.
Implements GClasses::GIncrementalLearner.
virtual bool GClasses::GNaiveBayes::canImplicitlyHandleContinuousFeatures | ( | ) | [inline, protected, virtual] |
See the comment for GTransducer::canImplicitlyHandleContinuousFeatures.
Reimplemented from GClasses::GTransducer.
virtual bool GClasses::GNaiveBayes::canImplicitlyHandleContinuousLabels | ( | ) | [inline, protected, virtual] |
See the comment for GTransducer::canImplicitlyHandleContinuousLabels.
Reimplemented from GClasses::GTransducer.
virtual void GClasses::GNaiveBayes::clear | ( | ) | [virtual] |
See the comment for GSupervisedLearner::clear.
Implements GClasses::GSupervisedLearner.
double GClasses::GNaiveBayes::equivalentSampleSize | ( | ) | [inline] |
Returns the equivalent sample size. (The number of samples of each possible value that is added by default to prevent zeros.)
virtual void GClasses::GNaiveBayes::predictDistributionInner | ( | const double * | pIn, |
GPrediction * | pOut | ||
) | [protected, virtual] |
See the comment for GSupervisedLearner::predictDistributionInner.
Implements GClasses::GSupervisedLearner.
virtual void GClasses::GNaiveBayes::predictInner | ( | const double * | pIn, |
double * | pOut | ||
) | [protected, virtual] |
See the comment for GSupervisedLearner::predictInner.
Implements GClasses::GSupervisedLearner.
Marshal this object into a DOM, which can then be converted to a variety of serial formats.
Implements GClasses::GSupervisedLearner.
void GClasses::GNaiveBayes::setEquivalentSampleSize | ( | double | d | ) | [inline] |
To ensure that unsampled values don't dominate the joint distribution by multiplying by a zero, each value is given at least as much representation as specified here. (The default is 0.5, which is as if there were half of a sample for each value.)
static void GClasses::GNaiveBayes::test | ( | ) | [static] |
Performs unit tests for this class. Throws an exception if there is a failure.
Reimplemented from GClasses::GSupervisedLearner.
virtual void GClasses::GNaiveBayes::trainIncrementalInner | ( | const double * | pIn, |
const double * | pOut | ||
) | [protected, virtual] |
Adds a single training sample to the collection.
Implements GClasses::GIncrementalLearner.
virtual void GClasses::GNaiveBayes::trainInner | ( | GMatrix & | features, |
GMatrix & | labels | ||
) | [protected, virtual] |
See the comment for GSupervisedLearner::trainInner.
Implements GClasses::GSupervisedLearner.
virtual void GClasses::GNaiveBayes::trainSparse | ( | GSparseMatrix & | features, |
GMatrix & | labels | ||
) | [virtual] |
See the comment for GIncrementalLearner::trainSparse This method assumes that the values in pData are all binary values (0 or 1).
Implements GClasses::GIncrementalLearner.
double GClasses::GNaiveBayes::m_equivalentSampleSize [protected] |
size_t GClasses::GNaiveBayes::m_nSampleCount [protected] |
sp_relation GClasses::GNaiveBayes::m_pFeatureRel [protected] |
sp_relation GClasses::GNaiveBayes::m_pLabelRel [protected] |
GNaiveBayesOutputAttr** GClasses::GNaiveBayes::m_pOutputs [protected] |