View source: R/SpectralClustering.R
pod | R Documentation |
Finding optimal discrete solutions for spectral clustering
pod(Y, verbose = FALSE)
Y |
a matrix with N rows and K columns, with N being the number of objects (e.g., patients), K being the number of clusters. The K columns of 'Y' should correspond to the first k eigenvectors of graph Laplacian matrix (of affinity matrix) corresponding to the k smallest eigenvalues |
verbose |
logical(1); if true, print some information |
class assignment matrix with the same shape as Y (i.e., N x K). Each row contains all zeros except one 1. For instance, if X_ij = 1, then object (eg, patient) i belongs to cluster j.
Stella, X. Yu, and Jianbo Shi. "Multiclass spectral clustering." ICCV. IEEE, 2003.
D = matrix(runif(400),20)
A = affinity_matrix(D, 5)
d = rowSums(A)
L = diag(d) - A
# `NL` is graph Laplacian of affinity matrix `A`
NL = diag(1/d) %*% L
e = eigen(NL)
# Here we select eigenvectors corresponding to three smallest eigenvalues
Y = Re(e$vectors[,-1:-17])
X = pod(Y)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.