-
Notifications
You must be signed in to change notification settings - Fork 0
/
rank_aggregation.py
executable file
·32 lines (26 loc) · 1.07 KB
/
rank_aggregation.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import os
import sys
import os.path
if __name__ == "__main__":
sys.path.insert(1,
os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir)))
from pyrankagg.rankagg import FullListRankAggregator
def perform_rank_aggregation(
rank_aggregation_input: list,
):
"""Use pyrankagg to aggregate the items in the given list of experts
Parameters
----------
rank_aggregation_input : list
List of expert scores. Each element corresponds to one expert and is a dictionary containing scores for each item from that expert.
Returns
-------
dict
The aggregated ranks of the items
"""
aggregator = FullListRankAggregator() #the package is for rank aggregation
rank_aggregation_output = aggregator.aggregate_ranks(rank_aggregation_input)
if isinstance(rank_aggregation_output, tuple):
rank_aggregation_output = rank_aggregation_output[-1] # TODO:?
assert isinstance(rank_aggregation_output, dict), f"rank_aggregation_output is NOT A DICT! {rank_aggregation_output}"
return rank_aggregation_output