python机器学习API介绍21:层次聚类算法介绍( 六 )

def plot_AgglomerativeClustering_linkage(*data):

x labels_true = data

markers=\"+o*\"

nums = range(1 80)

fig = plt.figure()

ax = fig.add_subplot(111)

linkages = ['ward' 'complete' 'average'

for i linkage in enumerate(linkages):

APIs = [

for num in nums:

clst = AgglomerativeClustering(n_clusters=num linkage=linkage)

predicted_labels = clst.fit_predict(x)

APIs.append(adjusted_rand_score(labels_true predicted_labels))

ax.plot(nums APIs marker=markers[i
label=\"linkage:%s\"%linkage)

推荐阅读