LTI-Lib latest version v1.9 - last update 10 Apr 2010

lti::MSTClustering< U > Class Template Reference

This class implements a minimum spanning tree clustering. More...

#include <ltiMSTClustering.h>

Inheritance diagram for lti::MSTClustering< U >:
Inheritance graph
[legend]
Collaboration diagram for lti::MSTClustering< U >:
Collaboration graph
[legend]

List of all members.

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
MSTClusteringcopy (const MSTClustering &other)
MSTClusteringoperator= (const MSTClustering &other)
virtual classifierclone () const
const parametersgetParameters () 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
distantor

Detailed Description

template<class U = l2SquareDistantor<dvector>>
class lti::MSTClustering< U >

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.


Constructor & Destructor Documentation

template<class U = l2SquareDistantor<dvector>>
lti::MSTClustering< U >::MSTClustering (  ) 

default constructor

template<class U = l2SquareDistantor<dvector>>
lti::MSTClustering< U >::MSTClustering ( const MSTClustering< U > &  other  ) 

copy constructor

Parameters:
other the object to be copied
template<class U = l2SquareDistantor<dvector>>
virtual lti::MSTClustering< U >::~MSTClustering (  )  [virtual]

destructor


Member Function Documentation

template<class U = l2SquareDistantor<dvector>>
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.

Parameters:
feature the vector to be classified
result the result of the classification
Returns:
false if an error occurred during classification else true

Implements lti::unsupervisedClassifier.

template<class U = l2SquareDistantor<dvector>>
virtual classifier* lti::MSTClustering< U >::clone (  )  const [virtual]

returns a pointer to a clone of this clustering.

Implements lti::classifier.

template<class U = l2SquareDistantor<dvector>>
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.

template<class U = l2SquareDistantor<dvector>>
MSTClustering& lti::MSTClustering< U >::copy ( const MSTClustering< U > &  other  ) 

copy data of "other" clustering.

Parameters:
other the clustering to be copied
Returns:
a reference to this clustering object

Reimplemented from lti::clustering.

template<class U = l2SquareDistantor<dvector>>
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.

template<class U = l2SquareDistantor<dvector>>
const parameters& lti::MSTClustering< U >::getParameters (  )  const

returns used parameters

Reimplemented from lti::clustering.

template<class U = l2SquareDistantor<dvector>>
virtual const char* lti::MSTClustering< U >::getTypeName (  )  const [virtual]

returns the name of this type ("MSTClustering")

Reimplemented from lti::clustering.

template<class U = l2SquareDistantor<dvector>>
MSTClustering& lti::MSTClustering< U >::operator= ( const MSTClustering< U > &  other  ) 

alias for copy member

Parameters:
other the clustering to be copied
Returns:
a reference to this clustering object

Reimplemented from lti::classifier.

template<class U = l2SquareDistantor<dvector>>
virtual bool lti::MSTClustering< U >::read ( ioHandler handler,
const bool  complete = true 
) [virtual]

read the parameters from the given ioHandler

Parameters:
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.
Returns:
true if write was successful

Reimplemented from lti::classifier.

template<class U = l2SquareDistantor<dvector>>
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.

Parameters:
input the matrix with the input vectors (each row is a training vector)
Returns:
true if successful, false otherwise. (if false you can check the error message with getStatusString())

Implements lti::clustering.

template<class U = l2SquareDistantor<dvector>>
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.

Parameters:
input the matrix with the input vectors (each row is a training vector)
ids vector of class ids for each input point
Returns:
true if successful, false otherwise. (if false you can check the error message with getStatusString())

Reimplemented from lti::clustering.

template<class U = l2SquareDistantor<dvector>>
virtual bool lti::MSTClustering< U >::write ( ioHandler handler,
const bool  complete = true 
) const [virtual]

read the parameters from the given ioHandler

Parameters:
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.
Returns:
true if write was successful

Reimplemented from lti::classifier.


Member Data Documentation

template<class U = l2SquareDistantor<dvector>>
std::vector<kdTree<dvector,int,U >* > lti::MSTClustering< U >::clusters [protected]

After the training process the vector contains under each id a kdTree with all points that are in the cluster with the id corresponding with the position in the vector.

template<class U = l2SquareDistantor<dvector>>
U lti::MSTClustering< U >::distantor [protected]

The distantor used computing distances.

template<class U = l2SquareDistantor<dvector>>
weightedGraph<vector<double>,int,double> lti::MSTClustering< U >::gr1 [protected]

The graph that contains the tree and the edges.

template<class U = l2SquareDistantor<dvector>>
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.


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

Generated on Sat Apr 10 15:26:55 2010 for LTI-Lib by Doxygen 1.6.1