import operator
def majorityCnt(classList):
classCount={}
for vote in classList:
if vote not in classCount:
classCount[vote]=1
else:
classCount[vote]+=1
sortedClassCount=sorted(classCount.items(),key=operator.itemgetter(1),reverse=True)
return classList[0][0]
多数投票(pyrhon)
猜你喜欢
转载自blog.csdn.net/qq_39394809/article/details/85094800
今日推荐
周排行