43 #include <unordered_map>
84 bool fit_prior_param =
true,
85 const std::vector<double> &class_prior = {});
97 void train(
const std::vector<std::vector<double>> &data,
98 const std::vector<std::string> &labels);
106 std::string
predict(
const std::vector<double> &newData)
const;
126 std::unordered_map<std::string, std::unordered_map<size_t, double>>
149 void train(
const std::vector<std::vector<size_t>> &data,
150 const std::vector<std::string> &labels);
157 std::string
predict(
const std::vector<size_t> &newData)
const;
187 std::unordered_map<std::string, std::vector<double>>
mean;
194 std::unordered_map<std::string, std::vector<double>>
variance;
212 void train(
const std::vector<std::vector<double>> &data,
213 const std::vector<std::string> &labels);
221 std::string
predict(
const std::vector<double> &newData)
const;
236 void mean_and_var(
const std::vector<std::vector<double>> &data,
237 const std::vector<std::string> &labels);
286 bool fit_prior_param =
true,
287 const std::vector<double> &class_prior = {});
300 void train(
const std::vector<std::vector<size_t>> &data,
301 const std::vector<std::string> &labels);
309 std::string
predict(
const std::vector<size_t> &new_data)
const;
BayesBernoulli(double alpha_param=1.0)
Constructor for BayesBernoulli class.
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.
void display() const
Display the learned probabilities.
std::string predict(const std::vector< size_t > &newData) const
Predict the class of a new data point.
std::unordered_map< std::string, double > class_probs
~BayesBernoulli()
Destructor for BayesBernoulli class.
std::unordered_map< std::string, std::unordered_map< size_t, double > > feat_probs
Bayes Classifier Class based on assumptions of independence.
~BayesClf()
Destructor for BayesClf class.
bool fit_prior
Whether to learn class prior probabilities or not.
void train(const std::vector< std::vector< double >> &data, const std::vector< std::string > &labels)
Train the classifier with a set of labeled data.
std::vector< double > class_log_prior
Vector of class log priors.
void display() const
Display the learned probabilities.
std::unordered_map< std::string, double > class_probs
Map of class labels to their probabilities.
std::unordered_map< std::string, std::vector< double > > feature_probs
Map of class labels to their feature probabilities.
std::string predict(const std::vector< double > &newData) const
Predict the class of a new data point.
BayesClf(double alpha_param=1.0, bool fit_prior_param=true, const std::vector< double > &class_prior={})
Constructor for BayesClf class.
double alpha
Additive smoothing parameter.
BayesGauss()=default
Constructor for BayesGauss class.
std::unordered_map< std::string, std::vector< double > > mean
Map storing the mean values for each feature in each class.
void display() const
Display the learned probabilities.
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.
std::string predict(const std::vector< double > &newData) const
Predict the class of a new data point.
void train(const std::vector< std::vector< double >> &data, const std::vector< std::string > &labels)
Train the classifier with a set of labeled data.
std::unordered_map< std::string, double > class_probs
Map storing the probabilities of each class.
~BayesGauss()=default
Destructor for BayesGauss class.
std::unordered_map< std::string, std::vector< double > > variance
Map storing the variance values for each feature in each class.
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.
std::vector< double > class_log_prior
Vector storing the logarithm of the class prior probabilities.
std::unordered_map< std::string, std::vector< double > > feature_probs
Map storing the probabilities of features for each class.
std::string predict(const std::vector< size_t > &new_data) const
Predict the class of a new data point.
bool fit_prior
Flag indicating whether to learn class prior probabilities during training.
std::unordered_map< std::string, double > class_probs
Map storing the probabilities of each class.
~BayesMultiNom()
Destructor for BayesMultiNom class.
void display() const
Display the learned probabilities.
BayesMultiNom(double alpha_param=1.0, bool fit_prior_param=true, const std::vector< double > &class_prior={})
Constructor for BayesMultiNom class.
double alpha
Additive smoothing parameter for the Multinomial distribution.
The source C++ openGPMP namespace.