IMP  2.2.0
The Integrative Modeling Platform
IMP::kmeans::KMeans Class Reference

#include <IMP/kmeans/KMeans.h>

+ Inheritance diagram for IMP::kmeans::KMeans:

Public Member Functions

 KMeans (const std::string &fname_data, int dim, unsigned int max_nPts)
 
 KMeans ()
 
void add_data_pt (const IMP::Floats &p)
 
void clear_data ()
 
void execute (unsigned int k, KM_ALG_TYPE alg_type=KM_LLOYDS, int stages=100)
 
IMP::Ints get_assignments () const
 
IMP::Floats get_center (unsigned int i) const
 
const IMP::Floatsget_data_point (unsigned int i) const
 
unsigned int get_number_of_centers () const
 
unsigned int get_number_of_data_points () const
 
IMP::Floats get_squared_distance_to_centers () const
 
virtual std::string get_type_name () const
 
virtual ::IMP::base::VersionInfo get_version_info () const
 Get information about the module and version of the object.
 
void print_centers (base::LogLevel ll=base::PROGRESS) const
 
- Public Member Functions inherited from IMP::base::Object
virtual void clear_caches ()
 
virtual void do_destroy ()
 
CheckLevel get_check_level () const
 
LogLevel get_log_level () const
 
void set_check_level (CheckLevel l)
 
void set_log_level (LogLevel l)
 Set the logging level used in this object. More...
 
void set_was_used (bool tf) const
 
void show (std::ostream &out=std::cout) const
 
const std::string & get_name () const
 
void set_name (std::string name)
 

Additional Inherited Members

- Protected Member Functions inherited from IMP::base::Object
 Object (std::string name)
 Construct an object with the given name. More...
 

Detailed Description

Class that wraps and provides an interface to the K-means library by David Mount (GPL license), downloaded and adapted to IMP from http://www.cs.umd.edu/~mount/Projects/KMeans/

For a simple usage example, see modules/kmeans/examples/kmeans_example.py

Warning: KMeans has not been well tested yet
Use with caution and please report any bugs found.
Warning: KMeans has not been stabilized and is likely to change without notice.

Definition at line 72 of file kmeans/KMeans.h.

Constructor & Destructor Documentation

IMP::kmeans::KMeans::KMeans ( const std::string &  fname_data,
int  dim,
unsigned int  max_nPts 
)

Initialize the KMeans object with data from fname_data, assuming input data of dimension dim

Parameters
[in]fname_dataInput filename. Input is assumed to be in textual (ascii) whitespace separated format, with a fixed number of columns dim. Each row represents a single data point of fixed dimension dim. For example, a file with three examples of dimension 4 would look as follows:
10.3 0.7 1.3 11.1
2.1 1.5 20.1 0.2
10.1 0.9 2.1 10.9
[in]dimDimension of each data point
[in]max_nPtsMaximal number of points to be read from file
IMP::kmeans::KMeans::KMeans ( )

Empty constructor for all default initializations - object data is not considered initialized after this call

Member Function Documentation

void IMP::kmeans::KMeans::add_data_pt ( const IMP::Floats p)

Add a data point for clustering.

Parameters
[in]ppoint to be added
void IMP::kmeans::KMeans::clear_data ( )

Clears all data in object.

void IMP::kmeans::KMeans::execute ( unsigned int  k,
KM_ALG_TYPE  alg_type = KM_LLOYDS,
int  stages = 100 
)

Execute a kmeans algorithm variant on the data points stored.

Parameters
[in]knumber of clusters
[in]alg_typeThe k-means algorithm variant to use
See Also
KM_ALG_TYPE
Parameters
[in]stagesNumber of k-means iterations
IMP::Ints IMP::kmeans::KMeans::get_assignments ( ) const

Returns the cluster assignment of each data point

Definition at line 152 of file kmeans/KMeans.h.

IMP::Floats IMP::kmeans::KMeans::get_center ( unsigned int  i) const

Returns the i'th center Must be called only following a succesful execute() invokation

Parameters
[in]iCenter number in range (0,...,k-1)
const IMP::Floats& IMP::kmeans::KMeans::get_data_point ( unsigned int  i) const

Returns the i'th point in the dataset

Parameters
[in]iCenter number in range (0,...,nPts-1)
unsigned int IMP::kmeans::KMeans::get_number_of_centers ( ) const
Returns
The number of centers after a succeful execution

Definition at line 167 of file kmeans/KMeans.h.

unsigned int IMP::kmeans::KMeans::get_number_of_data_points ( ) const
Returns
The number of data points

Definition at line 135 of file kmeans/KMeans.h.

IMP::Floats IMP::kmeans::KMeans::get_squared_distance_to_centers ( ) const

Returns the squared distance of each data point to its respective cluster center

Definition at line 160 of file kmeans/KMeans.h.

void IMP::kmeans::KMeans::print_centers ( base::LogLevel  ll = base::PROGRESS) const

Print the centers (assuming exectute() was applied) to log

Parameters
llthe log level for printout

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