latest version v1.9 - last update 10 Apr 2010 |
This class implements two versions of k-means-clustering: batch and sequential. More...
#include <ltiKMeansClustering.h>
Classes | |
class | parameters |
Parameters for kMeansClustering. More... | |
Public Member Functions | |
kMeansClustering () | |
kMeansClustering (const kMeansClustering &other) | |
virtual | ~kMeansClustering () |
virtual const char * | getTypeName () const |
kMeansClustering & | copy (const kMeansClustering &other) |
virtual classifier * | clone () const |
const parameters & | getParameters () const |
virtual bool | train (const dmatrix &data) |
virtual bool | train (const dmatrix &input, ivector &ids) |
Protected Member Functions | |
bool | trainBatch (const dmatrix &data) |
bool | trainSequential (const dmatrix &data) |
This class implements two versions of k-means-clustering: batch and sequential.
Both methods are initailized by drawing numberOfClusters training points and assigning them as centroids. The batch version continues by labeling each training point with the centroid it belongs to and then calculating new centroids as mean average of the data belonging to each cluster. This is continued until a convergence criterion is met.
The sequential algorithm performs one step of batch training. After that training points are analyzed in random order. Whenever one data point switches clusters the centroids of the old and new cluster of that data point are recalculated. Calculation is also stoped by a convergence criterion.
For both methods the convergence criterion is that for one run through the training set none of the training points switched clusters.
lti::kMeansClustering::kMeansClustering | ( | ) |
default constructor
lti::kMeansClustering::kMeansClustering | ( | const kMeansClustering & | other | ) |
copy constructor
other | the object to be copied |
virtual lti::kMeansClustering::~kMeansClustering | ( | ) | [virtual] |
destructor
virtual classifier* lti::kMeansClustering::clone | ( | ) | const [virtual] |
returns a pointer to a clone of this classifier.
Implements lti::classifier.
kMeansClustering& lti::kMeansClustering::copy | ( | const kMeansClustering & | other | ) |
copy data of "other" functor.
other | the functor to be copied |
Reimplemented from lti::centroidClustering.
const parameters& lti::kMeansClustering::getParameters | ( | ) | const |
returns used parameters
Reimplemented from lti::centroidClustering.
virtual const char* lti::kMeansClustering::getTypeName | ( | ) | const [virtual] |
returns the name of this type ("kMeansClustering")
Reimplemented from lti::centroidClustering.
calls centroidClustering::train(const dmatrix&, ivector&)
Reimplemented from lti::centroidClustering.
virtual bool lti::kMeansClustering::train | ( | const dmatrix & | data | ) | [virtual] |
Performs batch or sequential training according to the value of parameters::clusterMode.
data | the training points |
Implements lti::centroidClustering.
bool lti::kMeansClustering::trainBatch | ( | const dmatrix & | data | ) | [protected] |
returns current parameters.
(non const! -> protected) Performs batch k-means clustering, see class description.
bool lti::kMeansClustering::trainSequential | ( | const dmatrix & | data | ) | [protected] |
Performs sequential k-means clustering, see class description.