/** * @file KMeans.h * @brief K-Means * @author Erik Rodner * @date 10/29/2007 */ #ifndef KMEANSINCLUDE #define KMEANSINCLUDE #include "core/vector/VectorT.h" #include "core/vector/MatrixT.h" #include "ClusterAlgorithm.h" #include namespace OBJREC { /** K-Means */ class KMeans : public ClusterAlgorithm { protected: int noClasses; std::string distanceType; NICE::VectorDistance *distancefunction; double vectorDistance(const NICE::Vector &vector1, const NICE::Vector &vector2, uint distancetype); double compute_assignments ( const NICE::VVector & features, const NICE::VVector & prototypes, std::vector & assignment ); double compute_weights ( const NICE::VVector & features, std::vector & weights, std::vector & assignment ); double compute_delta ( const NICE::VVector & oldprototypes, const NICE::VVector & prototypes ); int compute_prototypes ( const NICE::VVector & features, NICE::VVector & prototypes, std::vector & weights, const std::vector & assignment ); void initial_guess ( const NICE::VVector & features, NICE::VVector & prototypes ); void print_iteration ( int iterations, NICE::VVector & prototypes, double delta ); public: /** simple constructor */ KMeans( int noClasses , std::string distanceMode="euclidean"); /** simple destructor */ virtual ~KMeans(); void cluster ( const NICE::VVector & features, NICE::VVector & prototypes, std::vector & weights, std::vector & assignment ); }; } // namespace #endif