MLPACK  1.0.11
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:
91  NaiveBayesClassifier(const MatType& data,
92  const arma::Col<size_t>& labels,
93  const size_t classes,
94  const bool incrementalVariance = false);
95 
110  void Classify(const MatType& data, arma::Col<size_t>& results);
111 
113  const MatType& Means() const { return means; }
115  MatType& Means() { return means; }
116 
118  const MatType& Variances() const { return variances; }
120  MatType& Variances() { return variances; }
121 
123  const arma::vec& Probabilities() const { return probabilities; }
125  arma::vec& Probabilities() { return probabilities; }
126 };
127 
128 }; // namespace naive_bayes
129 }; // namespace mlpack
130 
131 // Include implementation.
132 #include "naive_bayes_classifier_impl.hpp"
133 
134 #endif
MatType & Means()
Modify the sample means for each class.
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: load.hpp:31
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, const bool incrementalVariance=false)
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.