Ocean
Ocean::ClusteringSpectral Class Reference

This class implements spectral clustering. More...

Public Member Functions

 ClusteringSpectral (const Matrix &affinityMatrix, const unsigned int numberCluster)
 Determines the symmetric Laplacian matrix of input given and computes the eigen system of the Laplacian matrix. More...
 
std::vector< Indices32clusterRotation (const unsigned int iterations=100u, const Scalar convergenceThreshold=Scalar(0.0001))
 Performances the actual clustering. More...
 

Static Protected Member Functions

static Matrix determineLaplacianMatrix (const Matrix &affinityMatrix)
 Determines unnormalized graph Laplacian matrix. More...
 
template<bool tSimplify>
static Matrix determineRandomWalkLaplacianMatrix (const Matrix &affinityMatrix)
 Determines normalized graph Laplacian matrix closely connected to a random walk. More...
 
template<bool tSimplify>
static Matrix determineSymmetricLaplacianMatrix (const Matrix &affinityMatrix)
 Determines symmetric (normalized) graph Laplacian matrix. More...
 
template<typename T >
static bool pairSortDescending (const std::pair< T, MatrixT< T >> &firstElem, const std::pair< T, MatrixT< T >> &secondElem)
 Sorts a list of eigenvectors with corresponding eigenvalues in descending order. More...
 

Protected Attributes

Matrix reducedEigenvectors
 Column matrix of eigen vectors ordered by eigen values and reduced to [numberCluster] vectors. More...
 

Detailed Description

This class implements spectral clustering.

Constructor & Destructor Documentation

◆ ClusteringSpectral()

Ocean::ClusteringSpectral::ClusteringSpectral ( const Matrix affinityMatrix,
const unsigned int  numberCluster 
)

Determines the symmetric Laplacian matrix of input given and computes the eigen system of the Laplacian matrix.

Parameters
affinityMatrixa square weight matrix derived from similarity matrix (must be non-negative)
numberClusternumber of cluster to be returned (0, infinity)

Member Function Documentation

◆ clusterRotation()

std::vector<Indices32> Ocean::ClusteringSpectral::clusterRotation ( const unsigned int  iterations = 100u,
const Scalar  convergenceThreshold = Scalar(0.0001) 
)

Performances the actual clustering.

The algorithm is implemented according to "Huang et al. Spectral rotation versus K-means in spectral clustering. AAAI'13".

Parameters
iterationsUpper limit of iterations to be performed [1, infinity)
convergenceThresholdDifferential threshold used as convergence criteria (0, infinity)
Returns
Indices of cluster elements (number of cluster was given in constructor)

◆ determineLaplacianMatrix()

static Matrix Ocean::ClusteringSpectral::determineLaplacianMatrix ( const Matrix affinityMatrix)
staticprotected

Determines unnormalized graph Laplacian matrix.

L = D - W. W is the weight matrix and D is a diagonal matrix containing the row sum of W

Parameters
affinityMatrixa square weight matrix derived from similarity matrix (must be non-negative)
Returns
Laplacian matrix

◆ determineRandomWalkLaplacianMatrix()

template<bool tSimplify>
static Matrix Ocean::ClusteringSpectral::determineRandomWalkLaplacianMatrix ( const Matrix affinityMatrix)
staticprotected

Determines normalized graph Laplacian matrix closely connected to a random walk.

L = I - D^{-1} * W. W is the weight matrix, I is the identity matrix and D is a diagonal matrix containing the row sum of W

Template Parameters
tSimplifyindicating whether a simplified version is used, then substraction with identity matrix is obmitted. Mathematically wrong but commonly used
Parameters
affinityMatrixa square weight matrix derived from similarity matrix (must be non-negative)
Returns
Laplacian matrix

◆ determineSymmetricLaplacianMatrix()

template<bool tSimplify>
static Matrix Ocean::ClusteringSpectral::determineSymmetricLaplacianMatrix ( const Matrix affinityMatrix)
staticprotected

Determines symmetric (normalized) graph Laplacian matrix.

L = I - D^{-1/2} * W * D^{-1/2}. W is the weight matrix, I is the identity matrix and D is a diagonal matrix containing the row sum of W

Template Parameters
tSimplifyindicating whether a simplified version is used, then substraction with identity matrix is obmitted. Mathematically wrong but commonly used
Parameters
affinityMatrixa square weight matrix derived from similarity matrix (must be non-negative)
Returns
Laplacian matrix

◆ pairSortDescending()

template<typename T >
bool Ocean::ClusteringSpectral::pairSortDescending ( const std::pair< T, MatrixT< T >> &  firstElem,
const std::pair< T, MatrixT< T >> &  secondElem 
)
inlinestaticprotected

Sorts a list of eigenvectors with corresponding eigenvalues in descending order.

Parameters
firstElemFirst pair of eigenvalue and eigenvector
secondElemSecond pair of eigenvalue and eigenvector
Returns
first eigenvalue is greater than eigenvalue of second element

Field Documentation

◆ reducedEigenvectors

Matrix Ocean::ClusteringSpectral::reducedEigenvectors
protected

Column matrix of eigen vectors ordered by eigen values and reduced to [numberCluster] vectors.


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