How do you keep all labels tied for the most votes?
multimode returns every value with maximum frequency in first-encounter order.
Python example and interpretation
Blue and red tie at two votes each and can both be sent for review. The first element reflects arrival order alone.
from statistics import multimode
multimode(['blue','red','red','blue','green'])Result ['blue', 'red']
中文
多个标注词并列出现最多时,如何保留全部候选?
multimode 返回所有达到最高频次的值,并按首次遇见的次序排列。
Python 算例与适用条件
蓝、红各两票时两者都应提交复核。返回列表第一项只反映输入次序,不代表它更可信。
from statistics import multimode
multimode(['blue','red','red','blue','green'])结果 ['blue', 'red']