def test_binary_linkage2clusters():
from freediscovery.cluster.utils import _binary_linkage2clusters
from sklearn.metrics import v_measure_score
n_samples = 10
linkage = np.array([[1, 2],
[2, 3],
[5, 7],
[6, 9]])
cluster_id = _binary_linkage2clusters(linkage, n_samples)
cluster_id_ref = np.array([0, 1, 1, 1, 2, 3, 4, 3, 5, 4])
assert cluster_id.shape == cluster_id_ref.shape
# i.e. same clusters
assert v_measure_score(cluster_id, cluster_id_ref) == 1.0
评论列表
文章目录