CEDRIC  Revision_backup-2009-02
Public Types | Public Member Functions | Protected Member Functions | List of all members
PAMClustering Class Reference

#include <PAMClustering.h>

Public Types

typedef
ublas::symmetric_matrix
< double, ublas::lower > 
matrix_type
 
typedef std::vector< unsigned int > ivec
 
typedef std::vector< double > dvec
 

Public Member Functions

 PAMClustering (const matrix_type &d, unsigned int k)
 
 ~PAMClustering ()
 
 PAMClustering (PAMClustering &other)
 Copy constructor (copy assignment not allowed because of const referenced distance matrix) More...
 
int cluster (unsigned int maxIterations=10000)
 
double calcSilhouette ()
 
double silCluster (unsigned int c)
 
const dvec & sils () const
 
const ivec & labels () const
 
const ivec & medoids () const
 
unsigned int numClusters () const
 

Protected Member Functions

void label ()
 Label each point with its nearest medoid. More...
 
bool swap ()
 
bool isSelected (unsigned int i)
 
double avgDist (unsigned int i, unsigned int c)
 
double label (ivec &labels)
 

Detailed Description

Implementation of Partitioning Around Medoids algorithm. After "Finding Groups in Data: an Introduction to Cluster Analysis" by Kaufman,Rosseeuw 1990.

Todo:
Switch from brute force swap-cost calculation to more efficient cost-update.

Member Typedef Documentation

typedef std::vector<double> PAMClustering::dvec
typedef std::vector<unsigned int> PAMClustering::ivec
typedef ublas::symmetric_matrix<double,ublas::lower> PAMClustering::matrix_type

Constructor & Destructor Documentation

PAMClustering::PAMClustering ( const matrix_type &  d,
unsigned int  k 
)

Constructor (does not perform clustering, call cluster() to do this).

Parameters
dsymmetric distance matrix
knumber of clusters
Remarks
Input matrix d is stored as const reference, so make sure it is valid throughout the existence of your PAMClustering instance.

References label().

PAMClustering::~PAMClustering ( )
PAMClustering::PAMClustering ( PAMClustering &  other)

Copy constructor (copy assignment not allowed because of const referenced distance matrix)

Member Function Documentation

double PAMClustering::avgDist ( unsigned int  i,
unsigned int  c 
)
protected
Returns
average distance from point i to points in cluster c

Referenced by calcSilhouette().

double PAMClustering::calcSilhouette ( )

Calculate per point, per cluster and overall silhouette width.

Returns
overall silhouette width

References avgDist().

Referenced by AutomaticPAM::cluster(), and EventNavigator::computeClustering().

int PAMClustering::cluster ( unsigned int  maxIterations = 10000)
Parameters
maxIterationsis the number of iterations after which to abort
Returns
number of iterations needed until convergence

References swap().

Referenced by AutomaticPAM::cluster(), and EventNavigator::computeClustering().

bool PAMClustering::isSelected ( unsigned int  i)
protected
Returns
true if point i already was used as medoid

Referenced by swap().

void PAMClustering::label ( )
protected

Label each point with its nearest medoid.

Referenced by PAMClustering(), and swap().

double PAMClustering::label ( ivec &  labels)
protected
const ivec& PAMClustering::labels ( ) const
inline
Returns
const reference to vector of labels

Referenced by EventNavigator::computeClustering().

const ivec& PAMClustering::medoids ( ) const
inline
Returns
const reference to vector of medoids

Referenced by EventNavigator::computeClustering().

unsigned int PAMClustering::numClusters ( ) const
inline

Referenced by AutomaticPAM::cluster().

double PAMClustering::silCluster ( unsigned int  c)
Returns
silhouette width of cluster c as determined by last calcSilhouette() call
const dvec& PAMClustering::sils ( ) const
inline
Returns
array of silhouette width per point as determined by last calcSilhouette() call
bool PAMClustering::swap ( )
protected

Perform PAM swap step.

Returns
true if final medoids found, false otherwise

References isSelected(), and label().

Referenced by cluster().