Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   Related Pages  

IndependentBayesClassifier.hpp

00001 #ifndef __IndependentBayesClassifier__
00002 #define __IndependentBayesClassifier__
00003 
00022 #include <stdio.h>
00023 
00024 #include "AMultiClassObjectEvaluator.hpp"
00025 #include "DataSample.hpp"
00026 
00027 class IndependentBayesClassifier
00028 {
00029 private:
00030 
00031 char*                                                   name;
00032 
00033 int                                                             xDimension;
00034 
00035 int                                                             n, nmax;
00036 
00037 AMultiClassObjectEvaluator**    objectClassifier;               // p(X|Oi), p(X|notO)
00038 
00039 public:
00040 
00041 IndependentBayesClassifier(int nmax, int featureSize);
00042 virtual ~IndependentBayesClassifier();
00043 
00044 virtual void add(AMultiClassObjectEvaluator* oClass);
00045 
00046 virtual AMultiClassObjectEvaluator* get(int iObject){ return objectClassifier[iObject]; } 
00047 
00048 virtual int     numberOfObjects(){ return n; }
00049 virtual int     maxSize(){ return nmax; }       
00050 
00051 // computation of new parameters        
00052 virtual void initializeClasses(DataSample* objectSample);
00053 
00054 virtual void start(int iObj);
00055 
00056 virtual void learn(DataSample* objectSample);
00057 
00058 virtual void learn(int Oi, double value){ objectClassifier[Oi]->learn(value); }
00059 virtual void learn(int Oi, RealVector& value){ objectClassifier[Oi]->learn(value); }
00060 
00061 virtual void end(int iObj);
00062 
00063 
00064 // probability
00065 virtual double PX_O(double X, int Oi)                   // priori probabilty P(X|Oi)
00066                         { return objectClassifier[Oi]->Pxo(X); }
00067 
00068 virtual double PX_O(RealVector& X, int Oi)              // priori probabilty P(X|Oi)
00069                         { return objectClassifier[Oi]->Pxo(X); }
00070 
00071 virtual double PO(int Oi)                                               // P(Oi) using class repartition
00072                         { return objectClassifier[Oi]->Po(); }
00073 
00074 virtual double PX(double X);                                    // P(X)= sum( P(X|Oi)*P(Oi) )
00075 virtual double PX(RealVector& X);                               // P(X)= sum( P(X|Oi)*P(Oi) )
00076 
00077 virtual double PO_X(int Oi, double X);                  // posteriori probability= P(Oi|X)=P(X|Oi)*P(Oi)/P(X)
00078 virtual double PO_X(int Oi, RealVector& X);             // posteriori probability= P(Oi|X)=P(X|Oi)*P(Oi)/P(X)
00079 
00080 virtual int     objectName(double X);                           // P(Oj|X) -> Oi
00081 virtual int     objectName(RealVector& X);                      // P(Oj|X) -> Oi
00082 
00083 virtual double PO_X(double value)                               // best Oi of all posteriori probability P(Oj|X) 
00084                         { return PO_X(objectName(value), value); }
00085 virtual double PO_X(RealVector& value)                  // best Oi of all posteriori probability P(Oj|X) 
00086                         { return PO_X(objectName(value), value); }
00087 
00088 virtual double LX_O(double X, int Oi)                   
00089                         { return objectClassifier[Oi]->Lxo(X); }
00090 
00091 virtual double LX_O(RealVector& X, int Oi)                      
00092                         { return objectClassifier[Oi]->Lxo(X); }
00093 
00094 // ratios
00095 virtual double PO_Xratio(int Oi, int Oj, double X);
00096 virtual double LO_Xratio(int Oi, int Oj, double X);
00097 
00098 virtual double PO_Xratio(int Oi, int Oj, RealVector& X);
00099 virtual double LO_Xratio(int Oi, int Oj, RealVector& X);
00100 
00101 
00102 // likelihood
00103 virtual void output(FILE* file);
00104 
00105 virtual void output()
00106         {
00107         printf("IndependentBayesClassifier");
00108         }                               
00109 };
00110 
00111 #endif
SourceForge.net Logo
Restoreinpaint sourceforge project `C++/Java Image Processing, Restoration, Inpainting Project'.

Bernard De Cuyper: Open Project Leader: Concept, design and development.
Bernard De Cuyper & Eddy Fraiha 2002, 2003. Bernard De Cuyper 2004. Open and free, for friendly usage only.
Modifications on Belgium ground of this piece of artistic work, by governement institutions or companies, must be notified to Bernard De Cuyper.
bern_bdc@hotmail.com