# NOT RUN {
#########################################################
# Performing the l1-spectral clustering on one component
#########################################################
# 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]]]
k <- Clusters$nbr_clusters$Component1 # number of clusters to create
Elements_tmp <- list(score = Elements$score$Component1,
indices = Elements$indices$Component1)
# the elements of the first component
# 3rd: perform the l1-spectral clustering algorithm
# (with stabilization, which is the most recommended setting)
comm <- l1_spectral(A = A_tmp, k = k, elements = Elements_tmp, pen = "lasso", stab=TRUE)
# }
Run the code above in your browser using DataLab