mlpack  1.0.12
naive_bayes_classifier.hpp
Go to the documentation of this file.
1 
16 #ifndef __MLPACK_METHODS_NAIVE_BAYES_NAIVE_BAYES_CLASSIFIER_HPP
17 #define __MLPACK_METHODS_NAIVE_BAYES_NAIVE_BAYES_CLASSIFIER_HPP
18 
19 #include <mlpack/core.hpp>
21 
22 namespace mlpack {
23 namespace naive_bayes {
24 
49 template<typename MatType = arma::mat>
51 {
52  private:
54  MatType means;
55 
57  MatType variances;
58 
60  arma::vec probabilities;
61 
62  public:
83  NaiveBayesClassifier(const MatType& data,
84  const arma::Col<size_t>& labels,
85  const size_t classes,
86  const bool incrementalVariance = false);
87 
102  void Classify(const MatType& data, arma::Col<size_t>& results);
103 
105  const MatType& Means() const { return means; }
107  MatType& Means() { return means; }
108 
110  const MatType& Variances() const { return variances; }
112  MatType& Variances() { return variances; }
113 
115  const arma::vec& Probabilities() const { return probabilities; }
117  arma::vec& Probabilities() { return probabilities; }
118 };
119 
120 }; // namespace naive_bayes
121 }; // namespace mlpack
122 
123 // Include implementation.
124 #include "naive_bayes_classifier_impl.hpp"
125 
126 #endif
MatType & Means()
Modify the sample means for each class.
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: load.hpp:23
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.