IMP
2.1.1
The Integrative Modeling Platform
|
#include <IMP/kmeans/KMeans.h>
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::Floats & | get_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... | |
Object () | |
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
Definition at line 73 of file kmeans/KMeans.h.
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
[in] | fname_data | Input 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] | dim | Dimension of each data point |
[in] | max_nPts | Maximal 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
void IMP::kmeans::KMeans::add_data_pt | ( | const IMP::Floats & | p | ) |
Add a data point for clustering.
[in] | p | point 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.
[in] | k | number of clusters |
[in] | alg_type | The k-means algorithm variant to use |
[in] | stages | Number of k-means iterations |
IMP::Ints IMP::kmeans::KMeans::get_assignments | ( | ) | const |
Returns the cluster assignment of each data point
Definition at line 164 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
[in] | i | Center 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
[in] | i | Center number in range (0,...,nPts-1) |
unsigned int IMP::kmeans::KMeans::get_number_of_centers | ( | ) | const |
Definition at line 181 of file kmeans/KMeans.h.
unsigned int IMP::kmeans::KMeans::get_number_of_data_points | ( | ) | const |
Definition at line 144 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 173 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
ll | the log level for printout |