Description Usage Arguments Value Author(s) See Also Examples
This internal function of the l1-spectral clustering algorithm solves the l1-minimization problem and recover the community indicators of the clusters.
1 | PenOpt(U, n, elements, iteration, pen, k)
|
U |
The eigenvector matrix. |
n |
The number of nodes of the connected component to cluster. |
elements |
The representative elements of the connected component to cluster. |
iteration |
The cluster we aim at recovering. |
pen |
The penalty (to be chosen among "lasso" and "thresholdedLS"). |
k |
The number of clusters. |
v
The community indicator of cluster iteration
.
Camille Champion, Magali Champion
l1_spectralclustering
, l1_spectral
, l1spectral
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | ###################################
# Solving the minimization problem
###################################
# 1st: create data
Data <- CreateDataSet(k=3, n=20, p=list(p_inside=0.1,p_outside=0.1))
# 2nd: find the structure, the opt number of clusters and the representative elements
Structure <- FindStructure(Data$A_hat)
Clusters <- FindNbrClusters(A = Data$A_hat, structure = Structure)
Elements <- FindElement(A = Data$A_hat, structure = Structure, clusters = Clusters)
Structure_tmp <- Structure$groups[[1]] # the first component
A_tmp <- Data$A_hat[Structure$groups[[1]],Structure$groups[[1]]]
n <- ncol(A_tmp)
k <- Clusters$nbr_clusters$Component1 # number of clusters to create
Elements_tmp <- Elements$indices$Component1 # the elements of the first component
# 3rd: perform svd
svd <- eigen(A_tmp)
eigenvalues <- sort(svd$values,index.return=TRUE)
eigenvectors <- svd$vectors[,eigenvalues$ix]
# 4th: solve the minimization problem
i <- 1 # the cluster we aim at recovering
U <- t(eigenvectors[,1:(n-k+i-1)])
v <- PenOpt(U, n, elements = Elements_tmp, iteration = i, pen = "lasso", k) # for lasso
# the same with the least-squared threshold
v <- PenOpt(U, n, elements = Elements_tmp, iteration = i, pen = "thresholdedLS", k)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.