latest version v1.9 - last update 10 Apr 2010 |
This class implements a minimum spanning tree clustering. More...
#include <ltiMSTClustering.h>
Classes | |
class | parameters |
the parameters for the class MSTClustering More... | |
Public Member Functions | |
MSTClustering () | |
MSTClustering (const MSTClustering &other) | |
virtual | ~MSTClustering () |
virtual const char * | getTypeName () const |
MSTClustering & | copy (const MSTClustering &other) |
MSTClustering & | operator= (const MSTClustering &other) |
virtual classifier * | clone () const |
const parameters & | getParameters () const |
virtual bool | train (const dmatrix &input, ivector &ids) |
virtual bool | train (const dmatrix &input) |
virtual bool | classify (const dvector &feature, outputVector &result) const |
virtual bool | write (ioHandler &handler, const bool complete=true) const |
virtual bool | read (ioHandler &handler, const bool complete=true) |
Protected Member Functions | |
void | collectDists (const int a, const int b, std::list< std::pair< int, int > > &dists, int depth) |
void | findClusters (const int from, int &curId, int &nextId, weightedGraph< vector< double >, int, double >::node *&startNode, vector< int > &ids, std::vector< int > &startNodes) |
Protected Attributes | |
weightedGraph< vector< double > , int, double > | gr1 |
std::vector< kdTree< dvector, int, U > * > | clusters |
std::map< int, double > | minDistances |
U | distantor |
This class implements a minimum spanning tree clustering.
First a minimum spanning tree of the input data is computed. Then all edges that are unusually large compared the neighboring edges are removed. The clusters are the connected components of the minimum spanning tree after the removal of the inconsistent edges.
As template parameter the distantor accoding to the distance measure you want to use has to be specified.
lti::MSTClustering< U >::MSTClustering | ( | ) |
default constructor
lti::MSTClustering< U >::MSTClustering | ( | const MSTClustering< U > & | other | ) |
copy constructor
other | the object to be copied |
virtual lti::MSTClustering< U >::~MSTClustering | ( | ) | [virtual] |
destructor
virtual bool lti::MSTClustering< U >::classify | ( | const dvector & | feature, | |
outputVector & | result | |||
) | const [virtual] |
Classification.
Classifies the feature and returns the outputVector with the classification result.
feature | the vector to be classified | |
result | the result of the classification |
Implements lti::unsupervisedClassifier.
virtual classifier* lti::MSTClustering< U >::clone | ( | ) | const [virtual] |
returns a pointer to a clone of this clustering.
Implements lti::classifier.
void lti::MSTClustering< U >::collectDists | ( | const int | a, | |
const int | b, | |||
std::list< std::pair< int, int > > & | dists, | |||
int | depth | |||
) | [protected] |
collects the weights of all edge starting from node with id b until it reaches the given depth.
a is used to make sure that the function does not run back the way same way he came from.
MSTClustering& lti::MSTClustering< U >::copy | ( | const MSTClustering< U > & | other | ) |
copy data of "other" clustering.
other | the clustering to be copied |
Reimplemented from lti::clustering.
void lti::MSTClustering< U >::findClusters | ( | const int | from, | |
int & | curId, | |||
int & | nextId, | |||
weightedGraph< vector< double >, int, double >::node *& | startNode, | |||
vector< int > & | ids, | |||
std::vector< int > & | startNodes | |||
) | [protected] |
searchs for clusters in the graph after the inconsistent edges are deleted.
const parameters& lti::MSTClustering< U >::getParameters | ( | ) | const |
returns used parameters
Reimplemented from lti::clustering.
virtual const char* lti::MSTClustering< U >::getTypeName | ( | ) | const [virtual] |
returns the name of this type ("MSTClustering")
Reimplemented from lti::clustering.
MSTClustering& lti::MSTClustering< U >::operator= | ( | const MSTClustering< U > & | other | ) |
alias for copy member
other | the clustering to be copied |
Reimplemented from lti::classifier.
virtual bool lti::MSTClustering< U >::read | ( | ioHandler & | handler, | |
const bool | complete = true | |||
) | [virtual] |
read the parameters from the given ioHandler
handler | the ioHandler to be used | |
complete | if true (the default) the enclosing begin/end will be also read, otherwise only the data block will be read. |
Reimplemented from lti::classifier.
virtual bool lti::MSTClustering< U >::train | ( | const dmatrix & | input | ) | [virtual] |
Unsupervised training.
The vectors in the input
matrix will be clustered using each specific method.
Implements lti::clustering.
virtual bool lti::MSTClustering< U >::train | ( | const dmatrix & | input, | |
ivector & | ids | |||
) | [virtual] |
Unsupervised training.
The vectors in the input
matrix will be put into groups according to the training algorithm. Additionally, an integer indicating the class each point belongs to is returned.
By default this method uses the other train method train(const dmatrix&) and then calls classify(const dvector&) to get the ids for each train vector. These ids are then returned.
input | the matrix with the input vectors (each row is a training vector) | |
ids | vector of class ids for each input point |
Reimplemented from lti::clustering.
virtual bool lti::MSTClustering< U >::write | ( | ioHandler & | handler, | |
const bool | complete = true | |||
) | const [virtual] |
read the parameters from the given ioHandler
handler | the ioHandler to be used | |
complete | if true (the default) the enclosing begin/end will be also read, otherwise only the data block will be read. |
Reimplemented from lti::classifier.
std::vector<kdTree<dvector,int,U >* > lti::MSTClustering< U >::clusters [protected] |
U lti::MSTClustering< U >::distantor [protected] |
The distantor used computing distances.
weightedGraph<vector<double>,int,double> lti::MSTClustering< U >::gr1 [protected] |
The graph that contains the tree and the edges.
std::map<int,double> lti::MSTClustering< U >::minDistances [protected] |
After the training process this map contains for each cluster with the given id the minimal distance to its nearest neighboring cluster.