Class for performing K-means clustering, optimized for a particular feature type and metric. More...
#include <simple_kmeans.h>
Public Types | |
typedef boost::function< void(const std::vector< Feature * > &, size_t, std::vector < Feature, FeatureAllocator > &, Distance) | Initializer ) |
typedef Distance::result_type | squared_distance_type |
Public Member Functions | |
squared_distance_type | cluster (const std::vector< Feature, FeatureAllocator > &features, size_t k, std::vector< Feature, FeatureAllocator > ¢ers, std::vector< unsigned int > &membership) const |
Partition a set of features into k clusters. | |
squared_distance_type | clusterPointers (const std::vector< Feature * > &features, size_t k, std::vector< Feature, FeatureAllocator > ¢ers, std::vector< unsigned int > &membership) const |
Partition a set of features into k clusters. | |
size_t | getMaxIterations () const |
size_t | getRestarts () const |
void | setInitMethod (const Initializer &init) |
Set function object used to choose initial cluster centers. | |
void | setMaxIterations (size_t iters) |
void | setRestarts (size_t restarts) |
SimpleKmeans (const Feature &zero=Feature(), Distance d=Distance()) | |
Constructor. | |
Private Member Functions | |
squared_distance_type | clusterOnce (const std::vector< Feature * > &features, size_t k, std::vector< Feature, FeatureAllocator > ¢ers, std::vector< unsigned int > &membership) const |
Private Attributes | |
Initializer | choose_centers_ |
Distance | distance_ |
size_t | max_iterations_ |
size_t | restarts_ |
Feature | zero_ |
Class for performing K-means clustering, optimized for a particular feature type and metric.
The standard Lloyd's algorithm is used. By default, cluster centers are initialized randomly.
Definition at line 26 of file simple_kmeans.h.
typedef boost::function<void(const std::vector<Feature*>&, size_t, std::vector<Feature, FeatureAllocator>&, Distance) vt::SimpleKmeans< Feature, Distance, FeatureAllocator >::Initializer) |
Definition at line 30 of file simple_kmeans.h.
typedef Distance::result_type vt::SimpleKmeans< Feature, Distance, FeatureAllocator >::squared_distance_type |
Definition at line 29 of file simple_kmeans.h.
vt::SimpleKmeans< Feature, Distance, FeatureAllocator >::SimpleKmeans | ( | const Feature & | zero = Feature() , |
|
Distance | d = Distance() | |||
) | [inline] |
Constructor.
zero | Object representing zero in the feature space | |
d | Functor for calculating squared distance |
Definition at line 93 of file simple_kmeans.h.
SimpleKmeans< Feature, Distance, FeatureAllocator >::squared_distance_type vt::SimpleKmeans< Feature, Distance, FeatureAllocator >::cluster | ( | const std::vector< Feature, FeatureAllocator > & | features, | |
size_t | k, | |||
std::vector< Feature, FeatureAllocator > & | centers, | |||
std::vector< unsigned int > & | membership | |||
) | const [inline] |
Partition a set of features into k clusters.
features | The features to be clustered. | |
k | The number of clusters. | |
[out] | centers | A set of k cluster centers. |
[out] | membership | Cluster assignment for each feature |
Definition at line 104 of file simple_kmeans.h.
SimpleKmeans< Feature, Distance, FeatureAllocator >::squared_distance_type vt::SimpleKmeans< Feature, Distance, FeatureAllocator >::clusterOnce | ( | const std::vector< Feature * > & | features, | |
size_t | k, | |||
std::vector< Feature, FeatureAllocator > & | centers, | |||
std::vector< unsigned int > & | membership | |||
) | const [inline, private] |
Definition at line 142 of file simple_kmeans.h.
SimpleKmeans< Feature, Distance, FeatureAllocator >::squared_distance_type vt::SimpleKmeans< Feature, Distance, FeatureAllocator >::clusterPointers | ( | const std::vector< Feature * > & | features, | |
size_t | k, | |||
std::vector< Feature, FeatureAllocator > & | centers, | |||
std::vector< unsigned int > & | membership | |||
) | const [inline] |
Partition a set of features into k clusters.
This version is more convenient for hierarchical clustering, as you do not have to copy feature objects.
features | The features to be clustered. | |
k | The number of clusters. | |
[out] | centers | A set of k cluster centers. |
[out] | membership | Cluster assignment for each feature |
Definition at line 117 of file simple_kmeans.h.
size_t vt::SimpleKmeans< Feature, Distance, FeatureAllocator >::getMaxIterations | ( | ) | const [inline] |
Definition at line 45 of file simple_kmeans.h.
size_t vt::SimpleKmeans< Feature, Distance, FeatureAllocator >::getRestarts | ( | ) | const [inline] |
Definition at line 48 of file simple_kmeans.h.
void vt::SimpleKmeans< Feature, Distance, FeatureAllocator >::setInitMethod | ( | const Initializer & | init | ) | [inline] |
Set function object used to choose initial cluster centers.
Definition at line 43 of file simple_kmeans.h.
void vt::SimpleKmeans< Feature, Distance, FeatureAllocator >::setMaxIterations | ( | size_t | iters | ) | [inline] |
Definition at line 46 of file simple_kmeans.h.
void vt::SimpleKmeans< Feature, Distance, FeatureAllocator >::setRestarts | ( | size_t | restarts | ) | [inline] |
Definition at line 49 of file simple_kmeans.h.
Initializer vt::SimpleKmeans< Feature, Distance, FeatureAllocator >::choose_centers_ [private] |
Definition at line 86 of file simple_kmeans.h.
Distance vt::SimpleKmeans< Feature, Distance, FeatureAllocator >::distance_ [private] |
Definition at line 85 of file simple_kmeans.h.
size_t vt::SimpleKmeans< Feature, Distance, FeatureAllocator >::max_iterations_ [private] |
Definition at line 87 of file simple_kmeans.h.
size_t vt::SimpleKmeans< Feature, Distance, FeatureAllocator >::restarts_ [private] |
Definition at line 88 of file simple_kmeans.h.
Feature vt::SimpleKmeans< Feature, Distance, FeatureAllocator >::zero_ [private] |
Definition at line 84 of file simple_kmeans.h.