yat
0.14.5pre
|
Naive Bayesian Classifier. More...
#include <yat/classifier/NBC.h>
Public Member Functions | |
NBC (void) | |
Constructor. | |
virtual | ~NBC () |
Destructor. | |
NBC * | make_classifier (void) const |
Create an untrained copy of the classifier. More... | |
void | train (const MatrixLookup &, const Target &) |
Train the NBC using training data and targets. More... | |
void | train (const MatrixLookupWeighted &, const Target &) |
Train the NBC using weighted training data and targets. More... | |
void | predict (const MatrixLookup &data, utility::Matrix &result) const |
Predict samples using unweighted data. More... | |
void | predict (const MatrixLookupWeighted &data, utility::Matrix &result) const |
Predict samples using weighted data. More... | |
Naive Bayesian Classifier.
Each class is modelled as a multinormal distribution with features being independent:
|
virtual |
Create an untrained copy of the classifier.
An interface for making new classifier objects. This function allows for specification at run-time of which classifier type to instatiate (see 'Prototype' in Design Patterns). Derived classes should implement this function with DerivedClass* as the return type and not SupervisedClassifier*. A dynamically allocated DerivedClassifier should be returned. The implementation of this function should correspond to a copy constructor with the exception that the returned classifier is not trained.
Implements theplu::yat::classifier::SupervisedClassifier.
|
virtual |
Predict samples using unweighted data.
Each sample (column) in data is predicted and predictions are returned in the corresponding column in passed result. Each row in result corresponds to a class. The prediction is the estimated probability that sample belong to class :
, where and are the estimated mean and variance, respectively. Z is chosen such that total probability equals unity, .
Implements theplu::yat::classifier::SupervisedClassifier.
|
virtual |
Predict samples using weighted data.
Each sample (column) in data is predicted and predictions are returned in the corresponding column in passed result. Each row in result corresponds to a class. The prediction is the estimated probability that sample belong to class :
, where and are the estimated mean and variance, respectively. Z is chosen such that total probability equals unity, .
Implements theplu::yat::classifier::SupervisedClassifier.
|
virtual |
Train the NBC using training data and targets.
For each class mean and variance are estimated for each feature (see statistics::Averager for details).
If there is only one (or zero) samples in a class, parameters cannot be estimated. In that case, parameters are set to NaN for that particular class.
Implements theplu::yat::classifier::SupervisedClassifier.
|
virtual |
Train the NBC using weighted training data and targets.
For each class mean and variance are estimated for each feature (see statistics::AveragerWeighted for details).
To estimate the parameters of a class, each feature of the class must have at least two non-zero data points. Otherwise the parameters are set to NaN and any prediction will result in NaN for that particular class.
Implements theplu::yat::classifier::SupervisedClassifier.