spectral_clustering
SpectralClustering
Bases: Clustering
assign_labels = 'discretize'
instance-attribute
n_init = 100
instance-attribute
number_of_clusters = None
instance-attribute
__init__(cycles)
cluster()
Cluster cycles using spectral clustering.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
ndarray
|
dictionary with cluster labels as keys, and all cycles with said label as values. |
get_adjacency_matrix()
Build an adjacency matrix from a weighted graph created by the set of cycles that is being clustered. This graph contains all unique nodes and edges from all cycles combined. The weights of the edges are the number of times that each edge occurs in the set of cycles.
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: adjacency matrix |
get_eigengap(laplacian_matrix)
Calcualte the eigengap of the clusters. The eigengap is defined as the place where the gap between eigenvalues of the laplacian matrix is largest. The number of eigenvalues beneeth this gap define the number of clusters used for spectral clustering.
get_norm_laplacian(adjacency_matrix)
Calculates the normalized laplacian of the adjacency matrix.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adjacency_matrix |
ndarray
|
adjacency matrix of the graph |
required |
set_assign_labels(assign_labels)
Default = 'discretize'
set_n_init(n_init)
Number of times the Number of time the k-means algorithm will be run with different centroid seeds. The final results will be the best output of n_init consecutive runs in terms of inertia.
Default = 100
set_number_of_clusters(number_of_clusters)
By default, the number of clusters is automatically calculated by analysing where the gap between eigenvalues lies.