函数功能:返回labelList中出现次数最多的label
(self,labelList)
| 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 |