首页 > 解决方案 > 使用 metrics.adjusted_rand_score 获取链接的性能

问题描述

大家好,我有下面的代码,我想知道如何通过使用 metrics.adjusted_rand_score 方法来获得链接的性能。

import numpy as np
import matplotlib
import matplotlib.pyplot as plt
from scipy.cluster.hierarchy import dendrogram, linkage
from sklearn.cluster import AgglomerativeClustering

Y = np.array([[1],[7],[15],[12], [2], [4], [7], [8], [10], [15],[17], [21]])

cluster = AgglomerativeClustering(n_clusters=4)
cluster.fit(Y)
cluster.labels_

linked = linkage(Y, 'ward')
labelList = [[1],[7],[15],[12], [2], [4], [7], [8], [10], [15],[17], [21]]
plt.figure(figsize=(10, 7))
dendrogram(linked,orientation='top',labels=labelList,distance_sort='descending',show_leaf_counts=True)
plt.show()

顺便说一句,我还想知道我应该如何将它与 Means 一起使用。

先感谢您。

标签: pythoncluster-analysishierarchical-clustering

解决方案


推荐阅读