MCPcopy Index your code
hub / github.com/wepe/MachineLearning / _majorityCnt

Method _majorityCnt

DecisionTree/id3_c45.py:134–143  ·  view source on GitHub ↗

函数功能:返回labelList中出现次数最多的label

(self,labelList)

Source from the content-addressed store, hash-verified

132
133
134 def _majorityCnt(self,labelList):
135 """
136 函数功能:返回labelList中出现次数最多的label
137 """
138 labelCount={}
139 for vote in labelList:
140 if vote not in labelCount.keys(): labelCount[vote] = 0
141 labelCount[vote] += 1
142 sortedClassCount = sorted(labelCount.iteritems(),key=lambda x:x[1], reverse=True)
143 return sortedClassCount[0][0]
144
145
146

Callers 1

_createTreeMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected