HMLP: High-performance Machine Learning Primitives
|
#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 > ¢roids, std::vector< T, Allocator > ¢roid_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 () |
T | NMI () |
virtual void | NormalizedCut () |
end class VirtualNormalizedGraph use default stl allocator
|
inline |
compute X2
|
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
|
inline |
end Spectral()
|
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
|
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 )
|
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 )
|
inlinevirtual |
end KernelKmeans()
|
inlinevirtual |
end Centroids() perform a Kmeans iteration
allocate centroids and centroid_sqnorms
initialize
main loop
update centroids
perform gsknn with one neighbor
|
inlinevirtual |
end Kmeans()
|
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)
|
inlinevirtual |
end NMI() normalized edge cut (no labels required)
|
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
|
inline |
end Spectral()
create a kernel matrix
create a matrix-free D^{-1/2}KD^{-1/2}
calling matrix-independent spectral clustering
|
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