SCGiniIndex.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /**
  2. * @file SCGiniIndex.h
  3. * @brief the Gini index splitting criterion
  4. * @author Sven Sickert
  5. * @date 01/16/2017
  6. */
  7. #ifndef SCGiniIndexINCLUDE
  8. #define SCGiniIndexINCLUDE
  9. #include "SplittingCriterion.h"
  10. namespace OBJREC {
  11. class SCGiniIndex : public SplittingCriterion
  12. {
  13. protected:
  14. double gini_left,
  15. gini_right,
  16. count_left,
  17. count_right;
  18. /**
  19. * @brief computation of Gini index
  20. * @param distribution given distribution
  21. * @param count amount of samples
  22. * @param maxClassNo maximum class number
  23. * @return computed Gini index
  24. */
  25. double computeGiniIndex(
  26. const double* distribution,
  27. const double count ,
  28. const int maxClassNo );
  29. public:
  30. /* default constructor */
  31. SCGiniIndex();
  32. /* simple constructor */
  33. SCGiniIndex( int _min_examples );
  34. /** config constructor */
  35. SCGiniIndex( const NICE::Config *conf );
  36. /** copy constructor */
  37. SCGiniIndex( const SCGiniIndex &obj );
  38. /* simple destructor */
  39. virtual ~SCGiniIndex();
  40. /* cloning function */
  41. virtual SplittingCriterion* clone();
  42. /**
  43. * @brief evaluate the split and return if split is possible
  44. * @param values unsorted list of feature values of a certain dimension
  45. * @param threshold threshold for current feature dimension
  46. * @param distribution_left class distribution for left child node after splitting
  47. * @param distribution_right class distribution for right child node after splitting
  48. * @param maxClassNo maximum class number
  49. * @return possible split or not
  50. */
  51. virtual bool evaluateSplit(
  52. const FeatureValuesUnsorted & values,
  53. double threshold,
  54. double* distribution_left,
  55. double* distribution_right,
  56. int maxClassNo );
  57. /**
  58. * @brief compute purity based on given split
  59. * @return purity value
  60. */
  61. double computePurity() const;
  62. };
  63. } // namespace
  64. #endif