Thrill  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
KMeansModel< Point > Class Template Reference

Detailed Description

template<typename Point>
class examples::k_means::KMeansModel< Point >

Model returned by KMeans algorithm containing results.

Definition at line 73 of file k-means.hpp.

#include <k-means.hpp>

Public Member Functions

 KMeansModel (size_t dimensions, size_t num_clusters, size_t iterations, const std::vector< Point > &centroids)
 
Accessors
size_t dimensions () const
 Returns dimensions_. More...
 
size_t num_clusters () const
 Returns number of clusters. More...
 
size_t iterations () const
 Returns iterations_. More...
 
const std::vector< Point > & centroids () const
 Returns centroids_. More...
 
Classification
size_t Classify (const Point &p) const
 Calculate closest cluster to point. More...
 
template<typename PointDIA >
auto Classify (const PointDIA &points) const
 
template<typename PointDIA >
auto ClassifyPairs (const PointDIA &points) const
 
double ComputeCost (const Point &p) const
 Calculate the k-means cost: the squared distance to the nearest center. More...
 
template<typename PointDIA >
double ComputeCost (const PointDIA &points) const
 

Private Attributes

std::vector< Pointcentroids_
 computed centroids in cluster id order More...
 
size_t dimensions_
 dimensions of space More...
 
size_t iterations_
 number of iterations More...
 
size_t num_clusters_
 number of clusters More...
 

Constructor & Destructor Documentation

KMeansModel ( size_t  dimensions,
size_t  num_clusters,
size_t  iterations,
const std::vector< Point > &  centroids 
)
inline

Definition at line 76 of file k-means.hpp.

Member Function Documentation

const std::vector<Point>& centroids ( ) const
inline

Returns centroids_.

Definition at line 95 of file k-means.hpp.

References KMeansModel< Point >::centroids_.

size_t Classify ( const Point p) const
inline

Calculate closest cluster to point.

Definition at line 103 of file k-means.hpp.

References KMeansModel< Point >::centroids_, and Vector< D, Type >::DistanceSquare().

Referenced by KMeansModel< Point >::Classify(), and KMeansModel< Point >::ClassifyPairs().

auto Classify ( const PointDIA &  points) const
inline

Calculate closest cluster to all points, returns DIA containing only the cluster ids.

Definition at line 119 of file k-means.hpp.

References KMeansModel< Point >::Classify().

auto ClassifyPairs ( const PointDIA &  points) const
inline

Calculate closest cluster to all points, returns DIA contains pairs of points and their cluster id.

Definition at line 127 of file k-means.hpp.

References KMeansModel< Point >::Classify().

double ComputeCost ( const Point p) const
inline

Calculate the k-means cost: the squared distance to the nearest center.

Definition at line 135 of file k-means.hpp.

References KMeansModel< Point >::centroids_, and Vector< D, Type >::DistanceSquare().

Referenced by KMeansModel< Point >::ComputeCost().

double ComputeCost ( const PointDIA &  points) const
inline

Calculate the overall k-means cost: the sum of squared distances to their nearest center.

Definition at line 149 of file k-means.hpp.

References KMeansModel< Point >::ComputeCost().

size_t dimensions ( ) const
inline

Returns dimensions_.

Definition at line 86 of file k-means.hpp.

References KMeansModel< Point >::dimensions_.

size_t iterations ( ) const
inline

Returns iterations_.

Definition at line 92 of file k-means.hpp.

References KMeansModel< Point >::iterations_.

size_t num_clusters ( ) const
inline

Returns number of clusters.

Definition at line 89 of file k-means.hpp.

References KMeansModel< Point >::num_clusters_.

Member Data Documentation

std::vector<Point> centroids_
private

computed centroids in cluster id order

Definition at line 168 of file k-means.hpp.

Referenced by KMeansModel< Point >::centroids(), KMeansModel< Point >::Classify(), and KMeansModel< Point >::ComputeCost().

size_t dimensions_
private

dimensions of space

Definition at line 159 of file k-means.hpp.

Referenced by KMeansModel< Point >::dimensions().

size_t iterations_
private

number of iterations

Definition at line 165 of file k-means.hpp.

Referenced by KMeansModel< Point >::iterations().

size_t num_clusters_
private

number of clusters

Definition at line 162 of file k-means.hpp.

Referenced by KMeansModel< Point >::num_clusters().


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