openGPMP
Open Source Mathematics Package
|
#include <bayes_clf.hpp>
Public Member Functions | |
BayesBernoulli (double alpha_param=1.0) | |
Constructor for BayesBernoulli class. More... | |
~BayesBernoulli () | |
Destructor for BayesBernoulli class. More... | |
void | train (const std::vector< std::vector< size_t >> &data, const std::vector< std::string > &labels) |
Train the classifier with a set of labeled data. More... | |
std::string | predict (const std::vector< size_t > &newData) const |
Predict the class of a new data point. More... | |
void | display () const |
Display the learned probabilities. More... | |
Public Attributes | |
std::unordered_map< std::string, double > | class_probs |
std::unordered_map< std::string, std::unordered_map< size_t, double > > | feat_probs |
double | alpha |
Bernoulli Naive Bayes is a part of the Naive Bayes family. It is based on the Bernoulli Distribution and accepts only binary values, i.e., 0 or 1. If the features of the dataset are binary, then we can assume that Bernoulli Naive Bayes is the algorithm to be used.
Definition at line 123 of file bayes_clf.hpp.
|
inline |
Constructor for BayesBernoulli class.
alpha | Additive (Laplace/Lidstone) smoothing parameter |
Definition at line 134 of file bayes_clf.hpp.
|
inline |
void gpmp::ml::BayesBernoulli::display | ( | ) | const |
Display the learned probabilities.
Definition at line 212 of file bayes_clf.cpp.
Referenced by main().
std::string gpmp::ml::BayesBernoulli::predict | ( | const std::vector< size_t > & | newData | ) | const |
Predict the class of a new data point.
newData | A vector of size_t representing the features of the new data point |
Definition at line 191 of file bayes_clf.cpp.
Referenced by main().
void gpmp::ml::BayesBernoulli::train | ( | const std::vector< std::vector< size_t >> & | data, |
const std::vector< std::string > & | labels | ||
) |
Train the classifier with a set of labeled data.
data | A vector of vectors representing the training instances |
labels | A vector of strings representing the corresponding class labels |
Definition at line 155 of file bayes_clf.cpp.
Referenced by main().
double gpmp::ml::BayesBernoulli::alpha |
Definition at line 128 of file bayes_clf.hpp.
std::unordered_map<std::string, double> gpmp::ml::BayesBernoulli::class_probs |
Definition at line 125 of file bayes_clf.hpp.
std::unordered_map<std::string, std::unordered_map<size_t, double> > gpmp::ml::BayesBernoulli::feat_probs |
Definition at line 127 of file bayes_clf.hpp.