KMeansHeuristic.h 1.5 KB

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