cratepy.clustering.clusteringalgs.AgglomerativeAlgorithm¶
- class AgglomerativeAlgorithm[source]¶
Bases:
ClusteringAlgorithm
Hierarchical agglomerative interface.
- get_linkage_matrix(self):
abstract: Get hierarchical agglomerative clustering linkage matrix.
Constructor.
List of Public Methods
Get hierarchical agglomerative clustering linkage matrix.
Perform cluster analysis and get cluster label of each dataset item.
Methods
- abstract __init__()¶
Constructor.
- abstract get_linkage_matrix()[source]¶
Get hierarchical agglomerative clustering linkage matrix.
- Returns:
linkage_matrix – Linkage matrix associated with the hierarchical agglomerative clustering (numpy.ndarray of shape (n-1, 4)). At the i-th iteration the clusterings with indices Z[i, 0] and Z[i, 1], with distance Z[i, 2], are merged, forming a new cluster that contains Z[i, 3] original dataset items. All cluster indices j >= n refer to the cluster formed in Z[j-n, :].
- Return type:
numpy.ndarray (2d)
Notes
The hierarchical agglomerative clustering linkage matrix follows the definition of SciPy agglomerative clustering algorithm (see here).
- abstract perform_clustering(data_matrix)¶
Perform cluster analysis and get cluster label of each dataset item.
- Parameters:
data_matrix (numpy.ndarray (2d)) – Data matrix containing the required data to perform the cluster analysis (numpy.ndarray of shape (n_items, n_features)).
- Returns:
cluster_labels – Cluster label (int) assigned to each dataset item.
- Return type:
numpy.ndarray (1d)