有没有一个好的算法可以从几个部分排名列表重建全局排名列表?

问题描述 投票:0回答:1

我有一份物品清单,正在由一组评委进行审查。每个评委只能看到对象的一个子集,并且每个评委将对象从最好到最差进行排名。每个对象至少由两名评委进行排名,并且评委有可能出现不同意见(即,这是一个嘈杂的评判过程)。没有法官能看到所有物体。

有没有一个好的算法来根据所有评委的部分排名列表来编制“最佳”全球排名列表?

Python 中的示例(将其视为伪代码):

# Let's say there are six things and we want to rank them.

# There are ... four judges, each of whom judges three things, 
# so each thing gets judged twice.

items = ['a', 'b', 'c', 'd', 'e', 'f']
j1_rank = ['a', 'c', 'e']
j2_rank = ['b', 'd', 'f']
j3_rank = ['a', 'b', 'c']
j4_rank = ['d', 'e', 'f']
# these are ranked low to high

# the goal is - can we combine together ranks j1-j4 to reproduce a master ranked list
expected_ranked_list = ['a', 'b', 'c', 'd', 'e', 'f']

我研究过排名聚合算法,但我发现的大多数在线材料都非常技术性和/或数学性或科学文献中的大量术语;其中许多更多的是关于排名选择投票(例如政治候选人),这与我面临的问题不同。

编辑:正如@JoshGordon和@SurajShourie所指出的,我相信另一个可接受的预期解决方案是

['a', 'b', 'd', 'c', 'e', 'f']

python ranking
1个回答
0
投票

优秀的 Python 内置函数可以提供帮助 -

collections.Count
。您可以将所有结果附加到一个列表中,对其进行计数(放入字典中),然后将其转换回列表。 这是一个例子:

items = ['a', 'b', 'c', 'd', 'e', 'f']
j1_rank = ['a', 'c', 'e']
j2_rank = ['b', 'd', 'f']
j3_rank = ['a', 'b', 'c']
j4_rank = ['d', 'e', 'f', 'c']  // added 'c' so it will have a higher ranking

items.extend(j1_rank)  // appending to the original items, as there can be a
items.extend(j2_rank)  // situation where some element is not included 
items.extend(j3_rank)  // into rankings
items.extend(j4_rank)

a = dict(collections.Counter(items))  
// this will give something like {'a': 3, 'b': 3, 'c': 4, 'd': 3, 'e': 3, 'f': 3}
a = dict(sorted(a.items(), key=lambda item: item[1], reverse=True))
// sort it by value in reverse order {'c': 4, 'a': 3, 'b': 3, 'd': 3, 'e': 3, 'f': 3}

print(list(a.keys()))  // get keys and transform it to the list.

© www.soinside.com 2019 - 2024. All rights reserved.