KMeansHeuristic.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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/vector/Distance.h>
  10. #include "ClusterAlgorithm.h"
  11. namespace OBJREC
  12. {
  13. /** K-Means */
  14. class KMeansHeuristic: public ClusterAlgorithm
  15. {
  16. protected:
  17. int noClasses;
  18. std::string distanceType;
  19. NICE::VectorDistance<double> *distancefunction;
  20. double compute_assignments(const NICE::VVector & features,
  21. const NICE::VVector & prototypes, std::vector<int> & assignment);
  22. double compute_weights(const NICE::VVector & features,
  23. std::vector<double> & weights, std::vector<int> & assignment);
  24. double compute_delta(const NICE::VVector & oldprototypes,
  25. const NICE::VVector & prototypes);
  26. void initial_guess(const NICE::VVector & features, NICE::VVector & prototypes);
  27. void print_iteration(int iterations, NICE::VVector & prototypes, double delta);
  28. int robust_prototypes(const NICE::VVector &features, NICE::VVector &prototypes, std::vector<
  29. double> & weights, const std::vector<int> & assignment);
  30. public:
  31. /** simple constructor */
  32. KMeansHeuristic(int noClasses, std::string distanceMode = "euclidean");
  33. /** simple destructor */
  34. virtual ~KMeansHeuristic();
  35. void cluster(const NICE::VVector & features, NICE::VVector & prototypes, std::vector<double> & weights, std::vector<int> & assignment);
  36. };
  37. } // namespace
  38. #endif