def get_centers_label(cluster_lables,textList):
from collections import Counter
cluster_lables = list(cluster_lables)
combin = []
for i in range(len(cluster_lables)):
combin.append(str(cluster_lables[i])+','+str(textList[i].realLabel))
dic_center = {}
for i in Counter(combin).most_common():
x = i[0].split(',')
if dic_center.__contains__(x[0]) == False and x[1] not in list(dic_center.values()):
dic_center[x[0]] = x[1]
return dic_center
输出出现次数最多的组合,将其作为字典,多数投票
最新推荐文章于 2021-12-26 22:18:10 发布