14 #ifndef MLPACK_METHODS_NAIVE_BAYES_NAIVE_BAYES_CLASSIFIER_HPP 15 #define MLPACK_METHODS_NAIVE_BAYES_NAIVE_BAYES_CLASSIFIER_HPP 20 namespace naive_bayes {
46 template<
typename MatType = arma::mat>
69 const arma::Row<size_t>& labels,
71 const bool incrementalVariance =
false);
80 const size_t classes = 0);
97 void Train(
const MatType& data,
98 const arma::Row<size_t>& labels,
99 const bool incremental =
true);
109 template<
typename VecType>
110 void Train(
const VecType& point,
const size_t label);
126 void Classify(
const MatType& data, arma::Row<size_t>& results);
144 template<
typename Archive>
145 void Serialize(Archive& ar,
const unsigned int );
162 #include "naive_bayes_classifier_impl.hpp" MatType & Means()
Modify the sample means for each class.
Linear algebra utility functions, generally performed on matrices or vectors.
void Serialize(Archive &ar, const unsigned int)
Serialize the classifier.
const MatType & Means() const
Get the sample means for each class.
The core includes that mlpack expects; standard C++ includes and Armadillo.
The simple Naive Bayes classifier.
arma::vec probabilities
Class probabilities.
void Train(const MatType &data, const arma::Row< size_t > &labels, const bool incremental=true)
Train the Naive Bayes classifier on the given dataset.
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::Row< 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...
size_t trainingPoints
Number of training points seen so far.
void Classify(const MatType &data, arma::Row< size_t > &results)
Given a bunch of data points, this function evaluates the class of each of those data points...
MatType variances
Sample variances for each class.
const arma::vec & Probabilities() const
Get the prior probabilities for each class.