openGPMP
Open Source Mathematics Package
|
#include <bayes_clf.hpp>
Public Member Functions | |
BayesGauss ()=default | |
Constructor for BayesGauss class. More... | |
~BayesGauss ()=default | |
Destructor for BayesGauss class. More... | |
void | train (const std::vector< std::vector< double >> &data, const std::vector< std::string > &labels) |
Train the classifier with a set of labeled data. More... | |
std::string | predict (const std::vector< double > &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 |
Map storing the probabilities of each class. More... | |
std::unordered_map< std::string, std::vector< double > > | mean |
Map storing the mean values for each feature in each class. More... | |
std::unordered_map< std::string, std::vector< double > > | variance |
Map storing the variance values for each feature in each class. More... | |
Private Member Functions | |
void | mean_and_var (const std::vector< std::vector< double >> &data, const std::vector< std::string > &labels) |
Calculate the mean and variance for each class. More... | |
Classification technique that assumes that each parameter (also called features or predictors) has an independent capacity of predicting the output variable.
Definition at line 172 of file bayes_clf.hpp.
|
default |
Constructor for BayesGauss class.
|
default |
Destructor for BayesGauss class.
void gpmp::ml::BayesGauss::display | ( | ) | const |
Display the learned probabilities.
Definition at line 323 of file bayes_clf.cpp.
Referenced by main().
|
private |
Calculate the mean and variance for each class.
data | A vector of vectors representing the training instances |
labels | A vector of strings representing the corresponding class labels |
Definition at line 245 of file bayes_clf.cpp.
std::string gpmp::ml::BayesGauss::predict | ( | const std::vector< double > & | newData | ) | const |
Predict the class of a new data point.
newData | A vector of doubles representing the features of the new data point |
Definition at line 299 of file bayes_clf.cpp.
Referenced by main().
void gpmp::ml::BayesGauss::train | ( | const std::vector< std::vector< double >> & | 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 228 of file bayes_clf.cpp.
Referenced by main().
gpmp::ml::BayesGauss::class_probs |
Map storing the probabilities of each class.
The key is the class label (string), and the value is the probability (double)
Definition at line 180 of file bayes_clf.hpp.
gpmp::ml::BayesGauss::mean |
Map storing the mean values for each feature in each class.
The key is the class label (string), and the value is a vector of mean values
Definition at line 187 of file bayes_clf.hpp.
gpmp::ml::BayesGauss::variance |
Map storing the variance values for each feature in each class.
The key is the class label (string), and the value is a vector of variance values
Definition at line 194 of file bayes_clf.hpp.