KMeansHeuristic.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /**
  2. * @file KMeansHeuristic.h
  3. * @brief K-Means
  4. * @author Erik Rodner, Michael Koch, Michael Trummer
  5. * @date 02/04/2011
  6. */
  7. #ifndef KMeansHeuristicINCLUDE
  8. #define KMeansHeuristicINCLUDE
  9. #include <core/basics/Config.h>
  10. #include <core/vector/Distance.h>
  11. #include "core/vector/VectorT.h"
  12. #include "core/vector/MatrixT.h"
  13. #include "ClusterAlgorithm.h"
  14. namespace OBJREC
  15. {
  16. /** K-Means (but what does Heuristic actually mean? )*/
  17. class KMeansHeuristic: public ClusterAlgorithm
  18. {
  19. protected:
  20. int noClusters;
  21. std::string distanceType;
  22. NICE::VectorDistance<double> *distancefunction;
  23. double compute_assignments(const NICE::VVector & features,
  24. const NICE::VVector & prototypes, std::vector<int> & assignment);
  25. double compute_weights(const NICE::VVector & features,
  26. std::vector<double> & weights, std::vector<int> & assignment);
  27. double compute_delta(const NICE::VVector & oldprototypes,
  28. const NICE::VVector & prototypes);
  29. void initial_guess(const NICE::VVector & features, NICE::VVector & prototypes);
  30. void print_iteration(int iterations, NICE::VVector & prototypes, double delta);
  31. int robust_prototypes(const NICE::VVector &features, NICE::VVector &prototypes, std::vector<
  32. double> & weights, const std::vector<int> & assignment);
  33. public:
  34. /** simple constructor */
  35. KMeansHeuristic(int noClusters, std::string distanceMode = "euclidean");
  36. /**
  37. * @brief standard constructor
  38. * @param conf config file specifying all relevant variable settings
  39. * @param _section name of the section within the configfile where the settings can be found (default: KMeansHeuristic)
  40. * @date 14-06-2013 (dd-mm-yyyy)
  41. * @author Alexander Freytag
  42. */
  43. KMeansHeuristic( const NICE::Config *conf, const std::string & _section = "KMeansHeuristic");
  44. /** simple destructor */
  45. virtual ~KMeansHeuristic();
  46. void cluster(const NICE::VVector & features, NICE::VVector & prototypes, std::vector<double> & weights, std::vector<int> & assignment);
  47. };
  48. } // namespace
  49. #endif