1 | #ifndef _theplu_classifier_nbc_ |
---|

2 | #define _theplu_classifier_nbc_ |
---|

3 | |
---|

4 | // $Id: NBC.h 662 2006-09-27 10:16:17Z peter $ |
---|

5 | |
---|

6 | #include <c++_tools/classifier/SupervisedClassifier.h> |
---|

7 | #include <c++_tools/utility/matrix.h> |
---|

8 | |
---|

9 | namespace theplu { |
---|

10 | namespace classifier { |
---|

11 | |
---|

12 | class DataLookup1D; |
---|

13 | class DataLookup2D; |
---|

14 | class MatrixLookup; |
---|

15 | class MatrixLookupWeighted; |
---|

16 | class Target; |
---|

17 | |
---|

18 | /// |
---|

19 | /// @brief Naive Bayesian Classification. |
---|

20 | /// |
---|

21 | class NBC : public SupervisedClassifier |
---|

22 | { |
---|

23 | |
---|

24 | public: |
---|

25 | /// |
---|

26 | /// Constructor taking the training data, the target vector, and |
---|

27 | /// the distance measure as input. |
---|

28 | /// |
---|

29 | NBC(const MatrixLookup&, const Target&); |
---|

30 | |
---|

31 | /// |
---|

32 | /// Constructor taking the training data with weights, the target |
---|

33 | /// vector, the distance measure, and a weight matrix for the |
---|

34 | /// training data as input. |
---|

35 | /// |
---|

36 | NBC(const MatrixLookupWeighted&, const Target&); |
---|

37 | |
---|

38 | virtual ~NBC(); |
---|

39 | |
---|

40 | SupervisedClassifier* make_classifier(const DataLookup2D&, |
---|

41 | const Target&) const; |
---|

42 | |
---|

43 | /// |
---|

44 | /// Train the classifier using the training data. |
---|

45 | /// |
---|

46 | /// @return true if training succedeed. |
---|

47 | /// |
---|

48 | bool train(); |
---|

49 | |
---|

50 | |
---|

51 | /// |
---|

52 | /// For each sample, calculate the probabilies the sample belong |
---|

53 | /// to the corresponding class. |
---|

54 | /// |
---|

55 | void predict(const DataLookup2D&, utility::matrix&) const; |
---|

56 | |
---|

57 | |
---|

58 | private: |
---|

59 | utility::matrix centroids_; |
---|

60 | utility::matrix sigma_; |
---|

61 | const DataLookup2D& data_; |
---|

62 | |
---|

63 | }; |
---|

64 | |
---|

65 | }} // of namespace classifier and namespace theplu |
---|

66 | |
---|

67 | #endif |
---|