Description Usage Arguments Value Author(s) See Also Examples
View source: R/FindNbrClusters.R
This internal function of the l1-spectral algorithm finds the optimal number of clusters to build.
1 | FindNbrClusters(A, structure, k = NULL, k_max = NULL)
|
A |
The adjacency matrix |
structure |
Output of the function |
k |
True number of clusters (not necessarily needed). If not provided, k is chosen by spectral eigengap. |
k_max |
Maximal number of clusters to form (not necessarily needed). If not provided, k_max is set to the number of nodes. |
A list with the following elements:
nbr_clusters
Optimal number of clusters by component,
nbr_clusters_total
Optimal total number of clusters.
Camille Champion, Magali Champion
l1_spectralclustering
, l1spectral
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | #########################################
# Finding the optimal number of clusters
#########################################
# 1st example: non-perturbed graph
Data <- CreateDataSet(k=3, n=20, p=list(p_inside=0,p_outside=0))
Structure <- FindStructure(Data$A_hat)
Clusters <- FindNbrClusters(A = Data$A_hat, structure = Structure, k=3)
# The number of clusters is provided (3): each of the 3 components will be divided into 1 cluster
Clusters <- FindNbrClusters(A = Data$A_hat, structure = Structure, k=5)
# The number of clusters is provided (5) and larger than the number of components (3),
# the spectral eigengap method is used to find the optimal number of clusters of each component.
# 2nd example: perturbed graph
Data <- CreateDataSet(k=3, n=20, p=list(p_inside=0.1,p_outside=0.1))
Structure <- FindStructure(Data$A_hat) # there are less than 3 components
Clusters <- FindNbrClusters(A = Data$A_hat, structure = Structure)
# The number of clusters is optimized using the spectral eigengap method
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.