KMeansOnline.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /**
  2. * @file KMeansOnline.h
  3. * @brief online kmeans clustering
  4. * @author Erik Rodner
  5. * @date 02/13/2008
  6. */
  7. #ifndef KMEANSONLINEINCLUDE
  8. #define KMEANSONLINEINCLUDE
  9. #ifdef NOVISUAL
  10. #include <vislearning/nice_nonvis.h>
  11. #else
  12. #include <vislearning/nice.h>
  13. #endif
  14. #include "core/basics/Config.h"
  15. #include "ClusterOnline.h"
  16. #include "vislearning/cbaselib/Example.h"
  17. namespace OBJREC {
  18. /** online kmeans clustering */
  19. class KMeansOnline : public ClusterOnline
  20. {
  21. protected:
  22. size_t numClusters;
  23. double gamma;
  24. public:
  25. /** simple constructor */
  26. KMeansOnline( size_t numClusters, double gamma = 1.0 );
  27. /** simple destructor */
  28. virtual ~KMeansOnline();
  29. // refactor-nice.pl: check this substitution
  30. // old: int updateClusters ( const Vector & x );
  31. int updateClusters ( const NICE::Vector & x );
  32. void init ();
  33. /**
  34. * Cluster algorithm using examples
  35. * @param ex input examples
  36. */
  37. void cluster( const Examples &ex);
  38. /**
  39. * returns the distance to the centre of each cluster
  40. * @param vin input vector
  41. * @param dist distance
  42. * @param size how much centres should considered
  43. * @param hard use a hard assignment (all values = 1 or 0) or not
  44. */
  45. void getDist(const NICE::Vector &vin, SparseVector &dist, int size = 1, bool hard = false);
  46. };
  47. } // namespace
  48. #endif