Python implementations of rank aggregation methods for ranked lists.
This package implements some rank aggregation methods in Python. Currently, the following methods are supported:
- Instant Runoff Voting
- Borda count
- Dowdall system (variant of Borda count)
- “Average rank” – just take the average rank of each item across all lists. I don’t know if there is a real name for this method.
I plan on adding additional methods in the future (such as the Markov chain methods described in this paper.
All methods currently implemented are designed to work with partial lists (i.e., each base ranker does not necessarily rank every item).
Install from PyPI:
pip install rankaggregation
The key object in the package is the RankAggregator class. Each method takes rank_list as a parameter. Each list in rank_list is the ranking preference of a single base ranker.
>>> import rankaggregation as ra >>> agg = ra.RankAggregator() >>> rank_list = [['A', 'B', 'C'], ['B', 'A', 'C'], ['C', 'D', 'A']] >>> agg.instant_runoff(rank_list) ['A', 'B', 'C', 'D'] >>> agg.borda(rank_list) [('A', 9), ('B', 8.0), ('C', 8), ('D', 5.0)] >>> agg.dowdall(rank_list) [('A', 1.8333333333333333), ('C', 1.6666666666666665), ('B', 1.5), ('D', 0.5)] >>> agg.average_rank(rank_list) [('B', 1.5), ('A', 2.0), ('D', 2.0), ('C', 2.3333333333333335)]
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size rankaggregation-0.1.2.tar.gz (3.5 kB)||File type Source||Python version None||Upload date||Hashes View|