HMLP: High-performance Machine Learning Primitives
hmlp::Cluster< T, Allocator > Class Template Reference

#include <cluster.hpp>

Public Member Functions

 Cluster (size_t d, size_t n, size_t ncluster, hmlp::Data< T > *X, std::vector< int, Allocator > *assignments)
 
void ProvideLabels (size_t nclass, std::vector< int, Allocator > *labels)
 
void InitializeAssignments ()
 
std::vector< size_t > Centroids (std::vector< int > &amap, std::vector< T, Allocator > &centroids, std::vector< T, Allocator > &centroid_sqnorms)
 
virtual void Kmeans (std::vector< int > &amap, size_t niter, T tol)
 
virtual void Kmeans (size_t niter, T tol)
 
template<typename VIRTUALMATRIX >
void Spectral (VIRTUALMATRIX &G)
 
void Spectral (kernel_s< T > &kernel)
 
void Spectral (kernel_s< T > &kernel, T stol, T budget)
 
std::vector< size_t > ClusterPermutation (std::vector< int > &amap, std::vector< std::vector< int >> &bmap)
 
virtual void KernelKmeans (kernel_s< T > &kernel, std::vector< int > &amap, size_t niter, T tol)
 
virtual void KernelKmeans (kernel_s< T > &kernel, size_t niter, T tol)
 
virtual void KernelKmeans (kernel_s< T > &kernel, std::vector< int > &amap, size_t niter, T tol, T budget)
 
virtual void KernelKmeans (kernel_s< T > &kernel, size_t niter, T tol, T budget)
 
virtual void KernelKmeansRefinement ()
 
void ComputeConfusion ()
 
NMI ()
 
virtual void NormalizedCut ()
 

Detailed Description

template<class T, class Allocator = std::allocator<T>>
class hmlp::Cluster< T, Allocator >

end class VirtualNormalizedGraph use default stl allocator

Constructor & Destructor Documentation

template<class T, class Allocator = std::allocator<T>>
hmlp::Cluster< T, Allocator >::Cluster ( size_t  d,
size_t  n,
size_t  ncluster,
hmlp::Data< T > *  X,
std::vector< int, Allocator > *  assignments 
)
inline

compute X2

Member Function Documentation

template<class T, class Allocator = std::allocator<T>>
std::vector<size_t> hmlp::Cluster< T, Allocator >::Centroids ( std::vector< int > &  amap,
std::vector< T, Allocator > &  centroids,
std::vector< T, Allocator > &  centroid_sqnorms 
)
inline

compute the centroids of X( :, amap ) based on the assignment

resize centroids and centroid_sqnorms

zero out

compute centroids accoding to the current assignment

normalize with the cluster size

randomly assign a point to be the centroid

square 2-norm

template<class T, class Allocator = std::allocator<T>>
std::vector<size_t> hmlp::Cluster< T, Allocator >::ClusterPermutation ( std::vector< int > &  amap,
std::vector< std::vector< int >> &  bmap 
)
inline
template<class T, class Allocator = std::allocator<T>>
void hmlp::Cluster< T, Allocator >::ComputeConfusion ( )
inline

labels must be provided and nclass must be non-zero

ncluster-by-nclass

compute cluster_sizes, class_sizes, Confusion

if nclass == ncluster then compute the accuracy

insert all classes to the candidate list

insert all clusteres to the candidate list

loop over all combination

template<class T, class Allocator = std::allocator<T>>
virtual void hmlp::Cluster< T, Allocator >::KernelKmeans ( kernel_s< T > &  kernel,
std::vector< int > &  amap,
size_t  niter,
tol 
)
inlinevirtual

create a kernel matrix

get D = [ K( 0, 0 ), ..., K( n-1, n-1 ) )

all one vector (indicators)

get the weights i.e. Degree = K * ones

cluster permutation

similarity

umap for similarity

main loop (sequential)

initialize

centroids

bmap permutes K into the current cluster order

compute the similarity matrix

clean up the similarity matrix

sum( Kij ) = K( amap, bmap ) *

Kcc = sum( Similarity( bmap, j ) )

Kcc = sum( K( bmap, bmap )

Kcc = sum( Degree( bmap[ j ] ) )

Kii - ( 2 / n ) * sum( Kic ) + ( 1 / n^2 ) * sum( Kcc )

template<class T, class Allocator = std::allocator<T>>
virtual void hmlp::Cluster< T, Allocator >::KernelKmeans ( kernel_s< T > &  kernel,
std::vector< int > &  amap,
size_t  niter,
tol,
budget 
)
inlinevirtual

end KernelKmeans()

create a kernel matrix

get D = [ K( 0, 0 ), ..., K( n-1, n-1 ) )

all one vector (indicators)

compute the approximate degree

examine accuracy with 3 setups, ASKIT, HODLR, and GOFMM

ASKIT treecode with NN pruning

ASKIT treecode without NN pruning

get results from GOFMM

only print 10 values.

cluster permutation

ncluster-by-n, similarity

assignments as indicators

main loop (sequential)

initialize

centroids

bmap permutes K into the current cluster order

update the indicator matrix

( K * indicators )^{T}

compute the similarity matrix

Kcc = sum( Similarity( j, bmap ) )

Dcc = sum( Degree( bmap[ j ] ) )

Kii - ( 2 / n ) * sum( Kic ) + ( 1 / n^2 ) * sum( Kcc )

template<class T, class Allocator = std::allocator<T>>
virtual void hmlp::Cluster< T, Allocator >::KernelKmeansRefinement ( )
inlinevirtual
template<class T, class Allocator = std::allocator<T>>
virtual void hmlp::Cluster< T, Allocator >::Kmeans ( std::vector< int > &  amap,
size_t  niter,
tol 
)
inlinevirtual

end Centroids() perform a Kmeans iteration

allocate centroids and centroid_sqnorms

initialize

main loop

update centroids

perform gsknn with one neighbor

template<class T, class Allocator = std::allocator<T>>
virtual void hmlp::Cluster< T, Allocator >::Kmeans ( size_t  niter,
tol 
)
inlinevirtual

end Kmeans()

template<class T, class Allocator = std::allocator<T>>
T hmlp::Cluster< T, Allocator >::NMI ( )
inline

end ComputeConfusion() normalized mutual information (true label required)

labels must be provided and nclass must be non-zero

Compute confusion matrix

antecedent part

consequent part (true class)

consequent part (cluster)

template<class T, class Allocator = std::allocator<T>>
virtual void hmlp::Cluster< T, Allocator >::NormalizedCut ( )
inlinevirtual

end NMI() normalized edge cut (no labels required)

template<class T, class Allocator = std::allocator<T>>
template<typename VIRTUALMATRIX >
void hmlp::Cluster< T, Allocator >::Spectral ( VIRTUALMATRIX &  G)
inline

end Kmeans() use a Lanczos method without restart

create a kernel matrix

create a matrix-free D^{-1/2}KD^{-1/2}

number of eigenpairs to compute

allocate space for eigenpairs

k-step Lanczos + LAPACK xstev

spherical initialization (point-wise normalization)

reinitialize with Round-Robin

spherical Kmeans

template<class T, class Allocator = std::allocator<T>>
void hmlp::Cluster< T, Allocator >::Spectral ( kernel_s< T > &  kernel)
inline

end Spectral()

create a kernel matrix

create a matrix-free D^{-1/2}KD^{-1/2}

calling matrix-independent spectral clustering

template<class T, class Allocator = std::allocator<T>>
void hmlp::Cluster< T, Allocator >::Spectral ( kernel_s< T > &  kernel,
stol,
budget 
)
inline

use a Lanczos method without restart

create a kernel matrix

create a simple GOFMM compression

create a matrix-free D^{-1/2}KD^{-1/2}

calling matrix-independent spectral clustering


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