FindNbrClusters {l1spectral} | R Documentation |
Find the optimal number of clusters
Description
This internal function of the l1-spectral algorithm finds the optimal number of clusters to build.
Usage
FindNbrClusters(A, structure, k = NULL, k_max = NULL)
Arguments
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. |
Value
A list with the following elements:
nbr_clusters
Optimal number of clusters by component,nbr_clusters_total
Optimal total number of clusters.
Author(s)
Camille Champion, Magali Champion
See Also
l1_spectralclustering
, l1spectral
.
Examples
#########################################
# 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
[Package l1spectral version 0.99.6 Index]