Skip to main content

Python implementations of rank aggregation methods for ranked lists.

Project description

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).

Installation

Install from PyPI:

pip install rankaggregation

Example usage

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)]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for rankaggregation, version 0.1.2
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 hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page