cvi.cSIL¶
- class cvi.cSIL¶
Bases:
CVICentroid-based Silhouette (cSIL) Cluster Validity Index.
References
Brito da Silva, N. M. Melton, and D. C. Wunsch II, “Incremental Cluster Validity Indices for Hard Partitions: Extensions and Comparative Study,” ArXiv e-prints, Feb 2019, arXiv:1902.06711v1 [cs.LG].
Rousseeuw, “Silhouettes: A graphical aid to the interpretation and validation of cluster analysis,” Journal of Computational and Applied Mathematics, vol. 20, pp. 53-65, 1987.
Rawashdeh and A. Ralescu, “Center-wise intra-inter silhouettes,” in Scalable Uncertainty Management, E. Hüllermeier, S. Link, T. Fober et al., Eds. Berlin, Heidelberg: Springer, 2012, pp. 406-419.
- __init__()¶
Centroid-based Silhouette (cSIL) initialization routine.
Methods
__init__()Centroid-based Silhouette (cSIL) initialization routine.
get_cvi(data, label)Update the CVI and return its criterion value.
merge(target_label, source_label)Merge a source cluster into a target cluster.
remove(sample, label)Remove a sample from an initialized CVI.
Attributes
info- get_cvi(data: ndarray, label: int | ndarray) float¶
Update the CVI and return its criterion value.
Pass a one-dimensional sample and scalar integer label for an incremental update, or a two-dimensional batch and label vector for batch initialization. The object is mutated in both modes. A batch may be followed by incremental updates, but a second batch is not supported.
- Parameters:
data (np.ndarray) – The sample(s) of features used for clustering.
label (Union[int, np.ndarray]) – The label(s) prescribed to the sample(s) by the clustering algorithm.
- Returns:
The CVI’s criterion value.
- Return type:
- Raises:
ValueError – If the input dimensionality is invalid, feature dimensionality changes after initialization, batch labels contain fewer than two distinct values, or a second batch update is requested.
- merge(target_label: int, source_label: int) float¶
Merge a source cluster into a target cluster.
The target external label is retained and the source label is removed.
- Parameters:
- Returns:
The updated CVI criterion value.
- Return type:
- Raises:
NotImplementedError – If this index does not implement cluster merging.
ValueError – If the index is uninitialized, either label is unknown, or the two labels are equal.
- remove(sample: ndarray, label: int) float¶
Remove a sample from an initialized CVI.
The caller is responsible for ensuring that the sample belongs to the supplied cluster label. If the sample is the cluster’s final member, the empty cluster and its label are removed.
- Parameters:
sample (numpy.ndarray) – One sample vector of features.
label (int) – External label of the cluster containing the sample.
- Returns:
The updated CVI criterion value.
- Return type:
- Raises:
NotImplementedError – If this index does not implement removal.
ValueError – If the index is uninitialized, the label is unknown, the sample has the wrong shape, or the sample is inconsistent with the stored sufficient statistics.