Xmipp
v3.23.11-Nereus
|
#include <naive_bayes.h>
Public Member Functions | |
NaiveBayes (const std::vector< MultidimArray< double > > &features, const Matrix1D< double > &priorProbs, int discreteLevels) | |
Constructor. More... | |
void | setCostMatrix (const Matrix2D< double > &cost) |
Set cost matrix. More... | |
int | doInference (const MultidimArray< double > &newFeatures, double &cost, Matrix1D< double > &classesProbs, Matrix1D< double > &allCosts) |
Public Attributes | |
int | K |
Number of classes. More... | |
int | Nfeatures |
Number of features. More... | |
Matrix1D< double > | __priorProbsLog10 |
Prior probabilities of the classes. More... | |
MultidimArray< double > | __weights |
Weight of each feature. More... | |
std::vector< LeafNode > | __leafs |
The vector containing the Leafs (as many leafs as features) More... | |
Matrix2D< double > | __cost |
Friends | |
std::ostream & | operator<< (std::ostream &_out, const NaiveBayes &naive) |
Show. More... | |
Naive Bayes classifier class.
Definition at line 80 of file naive_bayes.h.
NaiveBayes::NaiveBayes | ( | const std::vector< MultidimArray< double > > & | features, |
const Matrix1D< double > & | priorProbs, | ||
int | discreteLevels | ||
) |
Constructor.
Definition at line 280 of file naive_bayes.cpp.
int NaiveBayes::doInference | ( | const MultidimArray< double > & | newFeatures, |
double & | cost, | ||
Matrix1D< double > & | classesProbs, | ||
Matrix1D< double > & | allCosts | ||
) |
Returns the class with the largest probability given a set of features. classesProbs and allCosts are auxiliary vectors to avoid continuous allocating of memory.
Definition at line 345 of file naive_bayes.cpp.
void NaiveBayes::setCostMatrix | ( | const Matrix2D< double > & | cost | ) |
|
friend |
Show.
Definition at line 419 of file naive_bayes.cpp.
Matrix2D<double> NaiveBayes::__cost |
Cost matrix C(i,j) is the cost of predicting class j when the true class is class i.
Definition at line 101 of file naive_bayes.h.
std::vector<LeafNode> NaiveBayes::__leafs |
The vector containing the Leafs (as many leafs as features)
Definition at line 96 of file naive_bayes.h.
Matrix1D<double> NaiveBayes::__priorProbsLog10 |
Prior probabilities of the classes.
Definition at line 90 of file naive_bayes.h.
MultidimArray<double> NaiveBayes::__weights |
Weight of each feature.
Definition at line 93 of file naive_bayes.h.
int NaiveBayes::K |
Number of classes.
Definition at line 84 of file naive_bayes.h.
int NaiveBayes::Nfeatures |
Number of features.
Definition at line 87 of file naive_bayes.h.