我一直在尝试在列表中找到最大结果 - 使用置信度值。查找列表中的最大匹配
列表的例子:
[[{u'categories': [u'health-beauty'], u'confidence': 0.3333333333333333},
{u'categories': [u'activities-events'], u'confidence': 0.6666666666666666}]]
将返回活动事件字典
[[{u'categories': [u'home-garden'], u'confidence': 0.3333333333333333},
{u'categories': [u'None of These'], u'confidence': 0.3333333333333333},
{u'categories': [u'toys-kids-baby'], u'confidence': 0.3333333333333333}]]
将返回所有三个,因为他们是平等的
[[{u'categories': [u'entertainment'], u'confidence': 1.0}]]
将返回娱乐
我试图使用python的最大功能:
seq = [x['confidence'] for x in d[0]]
max(seq)
但只是返回值
“最大的结果”使用的是什么规则? – 2012-11-12 08:30:41
更新了问题。谢谢@Tichodroma将继续并做到这一点。 – AlexZ
问题和你想要的应该清楚。 – raton