MLPACK  1.0.8
naive_bayes_classifier.hpp
Go to the documentation of this file.
1 
24 #ifndef __MLPACK_METHODS_NAIVE_BAYES_NAIVE_BAYES_CLASSIFIER_HPP
25 #define __MLPACK_METHODS_NAIVE_BAYES_NAIVE_BAYES_CLASSIFIER_HPP
26 
27 #include <mlpack/core.hpp>
29 
30 namespace mlpack {
31 namespace naive_bayes {
32 
57 template<typename MatType = arma::mat>
59 {
60  private:
62  MatType means;
63 
65  MatType variances;
66 
68  arma::vec probabilities;
69 
70  public:
88  NaiveBayesClassifier(const MatType& data,
89  const arma::Col<size_t>& labels,
90  const size_t classes);
91 
106  void Classify(const MatType& data, arma::Col<size_t>& results);
107 
109  const MatType& Means() const { return means; }
111  MatType& Means() { return means; }
112 
114  const MatType& Variances() const { return variances; }
116  MatType& Variances() { return variances; }
117 
119  const arma::vec& Probabilities() const { return probabilities; }
121  arma::vec& Probabilities() { return probabilities; }
122 };
123 
124 }; // namespace naive_bayes
125 }; // namespace mlpack
126 
127 // Include implementation.
128 #include "naive_bayes_classifier_impl.hpp"
129 
130 #endif
MatType & Means()
Modify the sample means for each class.
void Classify(const MatType &data, arma::Col< size_t > &results)
Given a bunch of data points, this function evaluates the class of each of those data points...
const MatType & Means() const
Get the sample means for each class.
The simple Naive Bayes classifier.
MatType means
Sample mean for each class.
MatType & Variances()
Modify the sample variances for each class.
const MatType & Variances() const
Get the sample variances for each class.
arma::vec & Probabilities()
Modify the prior probabilities for each class.
NaiveBayesClassifier(const MatType &data, const arma::Col< size_t > &labels, const size_t classes)
Initializes the classifier as per the input and then trains it by calculating the sample mean and var...
MatType variances
Sample variances for each class.
const arma::vec & Probabilities() const
Get the prior probabilities for each class.