Direct Graphical Models  v.1.7.0
TrainNodeNaiveBayes.h
1 // Bayes training class interface
2 // Written by Sergey G. Kosov in 2012 - 2015 for Project X
3 #pragma once
4 
5 #include "TrainNode.h"
6 #include "PriorNode.h"
7 
8 namespace DirectGraphicalModels
9 {
10  class IPDF;
11 
12  // ====================== Bayes Train Class =====================
20  class CTrainNodeBayes : public CTrainNode, private CPriorNode
21  {
22  public:
28  DllExport CTrainNodeBayes(byte nStates, word nFeatures);
29  DllExport virtual ~CTrainNodeBayes(void);
30 
31  DllExport virtual void reset(void);
32 
33  DllExport virtual void addFeatureVec(const Mat &featureVector, byte gt);
34  DllExport virtual void train(bool doClean = false);
35 
42  DllExport IPDF * getPDF(byte state, word feature) const { return m_pPDF[state][feature]; }
49  DllExport IPDF * getPDF2D(byte state) const { return m_pPDF2D[state]; }
54  DllExport void smooth(int nIt = 1);
55 
56  protected:
57  DllExport virtual void saveFile(FILE *pFile) const;
58  DllExport virtual void loadFile(FILE *pFile);
71  DllExport void calculateNodePotentials(const Mat &featureVector, Mat &potential, Mat &mask) const;
72 
73 
74  private:
75  IPDF *** m_pPDF;
77  Mat m_prior;
78  };
79 }
void smooth(int nIt=1)
Smothes the underlying Probability Density Functions (PDFs)
IPDF *** m_pPDF
The 1D PDF for node potentials [state][feature].
virtual void train(bool doClean=false)
Random model training.
IPDF * getPDF2D(byte state) const
Returns the 2D normalized probability density function (PDF) for specific state (class) ...
virtual void reset(void)
Resets class variables.
Mat m_prior
The class prior probability vector.
virtual void saveFile(FILE *pFile) const
Saves the random model into the file.
virtual void addFeatureVec(const Mat &featureVector, byte gt)
Adds new feature vector.
CTrainNodeBayes(byte nStates, word nFeatures)
Constructor.
IPDF * getPDF(byte state, word feature) const
Returns the normalized probability density function (PDF) for specific state (class) and feature...
virtual void loadFile(FILE *pFile)
Loads the random model from the file.
Node prior probability estimation class
Definition: PriorNode.h:14
Interface class for Probability Density Function (PDF)
Definition: IPDF.h:16
IPDF ** m_pPDF2D
The 2D data histogram for node potentials and 2 features[state].
Base abstract class for node potentials training.
Definition: TrainNode.h:47
void calculateNodePotentials(const Mat &featureVector, Mat &potential, Mat &mask) const
Calculates the node potential, based on the feature vector.