Public Types | Public Member Functions | Private Member Functions | Private Attributes
vt::SimpleKmeans< Feature, Distance, FeatureAllocator > Class Template Reference

Class for performing K-means clustering, optimized for a particular feature type and metric. More...

#include <simple_kmeans.h>

List of all members.

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 > &centers, 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 > &centers, 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 > &centers, std::vector< unsigned int > &membership) const

Private Attributes

Initializer choose_centers_
Distance distance_
size_t max_iterations_
size_t restarts_
Feature zero_

Detailed Description

template<class Feature, class Distance = distance::L2<Feature>, class FeatureAllocator = typename DefaultAllocator<Feature>::type>
class vt::SimpleKmeans< Feature, Distance, FeatureAllocator >

Class for performing K-means clustering, optimized for a particular feature type and metric.

Todo:
InitKmeanspp

The standard Lloyd's algorithm is used. By default, cluster centers are initialized randomly.

Definition at line 26 of file simple_kmeans.h.


Member Typedef Documentation

template<class Feature, class Distance = distance::L2<Feature>, class FeatureAllocator = typename DefaultAllocator<Feature>::type>
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.

template<class Feature, class Distance = distance::L2<Feature>, class FeatureAllocator = typename DefaultAllocator<Feature>::type>
typedef Distance::result_type vt::SimpleKmeans< Feature, Distance, FeatureAllocator >::squared_distance_type

Definition at line 29 of file simple_kmeans.h.


Constructor & Destructor Documentation

template<class Feature , class Distance , class FeatureAllocator >
vt::SimpleKmeans< Feature, Distance, FeatureAllocator >::SimpleKmeans ( const Feature zero = Feature(),
Distance  d = Distance() 
)

Constructor.

Parameters:
zeroObject representing zero in the feature space
dFunctor for calculating squared distance
Todo:
FeatureAllocator parameter

Definition at line 93 of file simple_kmeans.h.


Member Function Documentation

template<class Feature , class Distance , class FeatureAllocator >
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

Partition a set of features into k clusters.

Parameters:
featuresThe features to be clustered.
kThe number of clusters.
[out]centersA set of k cluster centers.
[out]membershipCluster assignment for each feature

Definition at line 104 of file simple_kmeans.h.

template<class Feature , class Distance , class FeatureAllocator >
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 [private]
Todo:
Kahan summation?

Definition at line 142 of file simple_kmeans.h.

template<class Feature , class Distance , class FeatureAllocator >
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

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.

Parameters:
featuresThe features to be clustered.
kThe number of clusters.
[out]centersA set of k cluster centers.
[out]membershipCluster assignment for each feature

Definition at line 117 of file simple_kmeans.h.

template<class Feature, class Distance = distance::L2<Feature>, class FeatureAllocator = typename DefaultAllocator<Feature>::type>
size_t vt::SimpleKmeans< Feature, Distance, FeatureAllocator >::getMaxIterations ( ) const [inline]

Definition at line 45 of file simple_kmeans.h.

template<class Feature, class Distance = distance::L2<Feature>, class FeatureAllocator = typename DefaultAllocator<Feature>::type>
size_t vt::SimpleKmeans< Feature, Distance, FeatureAllocator >::getRestarts ( ) const [inline]

Definition at line 48 of file simple_kmeans.h.

template<class Feature, class Distance = distance::L2<Feature>, class FeatureAllocator = typename DefaultAllocator<Feature>::type>
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.

template<class Feature, class Distance = distance::L2<Feature>, class FeatureAllocator = typename DefaultAllocator<Feature>::type>
void vt::SimpleKmeans< Feature, Distance, FeatureAllocator >::setMaxIterations ( size_t  iters) [inline]

Definition at line 46 of file simple_kmeans.h.

template<class Feature, class Distance = distance::L2<Feature>, class FeatureAllocator = typename DefaultAllocator<Feature>::type>
void vt::SimpleKmeans< Feature, Distance, FeatureAllocator >::setRestarts ( size_t  restarts) [inline]

Definition at line 49 of file simple_kmeans.h.


Member Data Documentation

template<class Feature, class Distance = distance::L2<Feature>, class FeatureAllocator = typename DefaultAllocator<Feature>::type>
Initializer vt::SimpleKmeans< Feature, Distance, FeatureAllocator >::choose_centers_ [private]

Definition at line 86 of file simple_kmeans.h.

template<class Feature, class Distance = distance::L2<Feature>, class FeatureAllocator = typename DefaultAllocator<Feature>::type>
Distance vt::SimpleKmeans< Feature, Distance, FeatureAllocator >::distance_ [private]

Definition at line 85 of file simple_kmeans.h.

template<class Feature, class Distance = distance::L2<Feature>, class FeatureAllocator = typename DefaultAllocator<Feature>::type>
size_t vt::SimpleKmeans< Feature, Distance, FeatureAllocator >::max_iterations_ [private]

Definition at line 87 of file simple_kmeans.h.

template<class Feature, class Distance = distance::L2<Feature>, class FeatureAllocator = typename DefaultAllocator<Feature>::type>
size_t vt::SimpleKmeans< Feature, Distance, FeatureAllocator >::restarts_ [private]

Definition at line 88 of file simple_kmeans.h.

template<class Feature, class Distance = distance::L2<Feature>, class FeatureAllocator = typename DefaultAllocator<Feature>::type>
Feature vt::SimpleKmeans< Feature, Distance, FeatureAllocator >::zero_ [private]

Definition at line 84 of file simple_kmeans.h.


The documentation for this class was generated from the following file:


vocabulary_tree
Author(s): Patrick Mihelich
autogenerated on Thu Jan 2 2014 12:12:26