Machine learning algorithms in C++
Public Member Functions | Private Attributes
NaiveBayes Class Reference

Naive Bayes classifier. More...

#include <NaiveBayes.hpp>

Collaboration diagram for NaiveBayes:

Public Member Functions

 NaiveBayes (const string &csvPath, bool verbose=true)
 Naive Bayes classifier. More...
 
vector< string > predict (vector< vector< string >> data, bool verbose=true)
 Predict the classes of new data. More...
 

Private Attributes

MatrixI lookupTable
 
MatrixI yFrequency
 
vector< string > lookupColumns
 
vector< string > lookupRows
 

Detailed Description

Naive Bayes classifier.

Definition at line 19 of file NaiveBayes.hpp.

Constructor & Destructor Documentation

◆ NaiveBayes()

NaiveBayes::NaiveBayes ( const string &  csvPath,
bool  verbose = true 
)
inlineexplicit

Naive Bayes classifier.

Parameters
csvPathpath to a CSV file containing the data. The first row in the file must contain the names of the features
verbosewhether to output the generated lookup tables

Definition at line 31 of file NaiveBayes.hpp.

Member Function Documentation

◆ predict()

vector<string> NaiveBayes::predict ( vector< vector< string >>  data,
bool  verbose = true 
)
inline

Predict the classes of new data.

Parameters
dataa vector of vectors of strings, each vector representing an element to be classified
verbosewhether to output the class assignment probabilities for each element
Returns
a vector containing the classes of the elements in data
See also
CSVReader, a class that helps in the creation of vectors of vectors of strings from CSV files

Definition at line 90 of file NaiveBayes.hpp.

Field Documentation

◆ lookupColumns

vector<string> NaiveBayes::lookupColumns
private

Definition at line 22 of file NaiveBayes.hpp.

◆ lookupRows

vector<string> NaiveBayes::lookupRows
private

Definition at line 22 of file NaiveBayes.hpp.

◆ lookupTable

MatrixI NaiveBayes::lookupTable
private

Definition at line 21 of file NaiveBayes.hpp.

◆ yFrequency

MatrixI NaiveBayes::yFrequency
private

Definition at line 21 of file NaiveBayes.hpp.


The documentation for this class was generated from the following file: