Skip to main content

pairwise-ranking

Documentation status PyPI status

Models for ranking competitors and measuring the nature of hierarchies

Maximilian Jerdee, Mark Newman

Paired comparisons may arise from records of sports matches, social interactions, or from any set of preferences between pairs of objects. In these settings we can model the "strengths" of each participant, predict future contests, and infer the "depth-of-competition" and "luck" present in the hierarchies considered.

The models implemented in this package are based on this paper:

M. Jerdee, M. E. J. Newman, Luck, skill, and depth of competition in games and social hierarchies, Preprint arxiv:2312.04711 (2023).

Installation

pairwise-ranking may be installed through pip:

pip install pairwise-ranking

Typical usage

Once installed, the package can be imported as

import ranking

Note that this is not import pairwise-ranking.

Files can be in a .gml network format, or read from a .txt file of a list of matches or one of an adjacency matrix of head-to-head records. See the /data directory for examples of properly formatted data.

Once a match_list has been loaded from a data set, the package may be used to rank participants, make predictions, and compute the depth and luck:

# Load data set
match_list = ranking.read_match_list("data/gml_files/dogs.gml")

# Find scores (requires sampling, which can take a while)
scores = ranking.scores(match_list)
print(scores)

# Get ranks (uses cached samples when possible)
ranks = ranking.ranks(match_list)
print(ranks)

# Find probability (and error) of an outcome betwen a pair
player1 = 'MER'
player2 = 'STE'
probability, probability_error = ranking.probability(match_list,player1,player2)
print(f"Probability {probability:.4f}+/-{probability_error:.4f} that {player1} beats {player2}")

# Infer the depth and luck of the hierarchy
params = ranking.depth_and_luck(match_list)
print(f"Depth: {params['depth']:.3f}, Luck: {params['luck']:.3f}")

See the file example.py for examples of more advanced usage options and our readthedocs page for further documentation and data set sources.

Metadata

Release files for pairwise-ranking 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pairwise-ranking 1.0.2
File Size Uploaded
pairwise-ranking-1.0.2.tar.gz 14.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pairwise-ranking 1.0.2
File Interpreter ABI Platform
pairwise_ranking-1.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 30.0 kB

Release files / pairwise-ranking-1.0.2.tar.gz

Download URL pairwise-ranking-1.0.2.tar.gz
Size 14.5 kB
Tags Source
SHA-256 checksum
How to use checksums
adc42c94dab6bac499256b3936bd13bfb723ffd412ae3bee4dc88d4ce0ef81c1
BLAKE2b-256 checksum
How to use checksums
f30956ef6957668eca30cd4f87e8670b4de9f9127b3b4afc99e31bc450d8f147
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.12

Release files / pairwise_ranking-1.0.2-py3-none-any.whl

Download URL pairwise_ranking-1.0.2-py3-none-any.whl
Size 15.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b74e036354bd179ebe44699ea27a459c6666c5bdb8e6d3223f9b97125186b817
BLAKE2b-256 checksum
How to use checksums
c7c75c25e953955297a8ca989294da87c5bf4e9ce8641d91508ab2d2e829c5b0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.12

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page