Thrill  0.1
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()

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

◆ centroids()

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

Returns centroids_.

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

◆ Classify() [1/2]

size_t Classify ( const Point p) const
inline

Calculate closest cluster to point.

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

References Vector< D, Type >::DistanceSquare().

◆ Classify() [2/2]

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 CentroidAccumulated< Point >::p.

◆ ClassifyPairs()

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 CentroidAccumulated< Point >::p.

◆ ComputeCost() [1/2]

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 Vector< D, Type >::DistanceSquare().

◆ ComputeCost() [2/2]

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 CentroidAccumulated< Point >::p.

◆ dimensions()

size_t dimensions ( ) const
inline

Returns dimensions_.

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

◆ iterations()

size_t iterations ( ) const
inline

Returns iterations_.

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

◆ num_clusters()

size_t num_clusters ( ) const
inline

Returns number of clusters.

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

Member Data Documentation

◆ centroids_

std::vector<Point> centroids_
private

computed centroids in cluster id order

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

◆ dimensions_

size_t dimensions_
private

dimensions of space

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

◆ iterations_

size_t iterations_
private

number of iterations

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

◆ num_clusters_

size_t num_clusters_
private

number of clusters

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


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