我正在使用 clusteval python 库来获取集群的数量,但这是一个过程,所以我无法存储数据。如何将簇值保存到变量中?
[clusteval] >Fit using agglomerative with metric: euclidean, and linkage: ward
[clusteval] >Evaluate using silhouette.
100%|██████████| 23/23 [00:00<00:00, 77.07it/s]
[clusteval] >Compute dendrogram threshold.
[clusteval] >Optimal number clusters detected: [3].
[clusteval] >Fin.
[clusteval] >Plotting the dendrogram with optimized settings: metric=euclidean, linkage=ward, max_d=197.613. Be patient now..
[clusteval] >Compute cluster labels.
[clusteval] >Estimated number of n_clusters: 3, average silhouette_score=0.897
这个问题是大约3年前提出的。这是我最终使用的,希望对其他人有帮助。将 results['labx'] 簇标签列表转换为集合并获取长度
results = ce.fit(X)
len(set(results['labx']))