Library for ranking tennis players
Project description
tennis-rank
Computes tennis player ranks using pagerank algorithm on match graph
Install
Using pip:
pip install tennisrank
Run tests:
make lint
make test
Example
from tennisrank.utils import load_atp
from tennisrank.model import Player, PlayerRank
from tennisrank.algorithm import TennisRank
matches = load_atp(2021)
ranker = TennisRank(matches)
# Get top 3 on all surfaces
top = 3
for surface in [Surface.ANY, Surface.HARD, Surface.CLAY, Surface.GRASS]:
print(f'Top {top} on {surface.name} surface (unit weight):')
ranks = ranker.get_ranks(surface=surface)
for player_rank in ranks[:top]:
print('-', player_rank)
print(f'{len(ranks)-top} more...')
print()
# Get rank of particular player
ranker.get_rank('Novak Hukohic', surface=Surface.GRASS) # fuzzy matching
Creates the following output:
Top 3 on ANY surface (unit weight):
- PlayerRank(player=Player(id=100644, name='Alexander Zverev'), rank=1, surface=<Surface.ANY: 3>)
- PlayerRank(player=Player(id=104925, name='Novak Djokovic'), rank=2, surface=<Surface.ANY: 3>)
- PlayerRank(player=Player(id=106421, name='Daniil Medvedev'), rank=3, surface=<Surface.ANY: 3>)
389 more...
Top 3 on HARD surface (unit weight):
- PlayerRank(player=Player(id=106421, name='Daniil Medvedev'), rank=1, surface=<Surface.HARD: 0>)
- PlayerRank(player=Player(id=100644, name='Alexander Zverev'), rank=2, surface=<Surface.HARD: 0>)
- PlayerRank(player=Player(id=104925, name='Novak Djokovic'), rank=3, surface=<Surface.HARD: 0>)
316 more...
Top 3 on CLAY surface (unit weight):
- PlayerRank(player=Player(id=104745, name='Rafael Nadal'), rank=1, surface=<Surface.CLAY: 2>)
- PlayerRank(player=Player(id=104925, name='Novak Djokovic'), rank=2, surface=<Surface.CLAY: 2>)
- PlayerRank(player=Player(id=126774, name='Stefanos Tsitsipas'), rank=3, surface=<Surface.CLAY: 2>)
221 more...
Top 3 on GRASS surface (unit weight):
- PlayerRank(player=Player(id=104925, name='Novak Djokovic'), rank=1, surface=<Surface.GRASS: 1>)
- PlayerRank(player=Player(id=200000, name='Felix Auger Aliassime'), rank=2, surface=<Surface.GRASS: 1>)
- PlayerRank(player=Player(id=126610, name='Matteo Berrettini'), rank=3, surface=<Surface.GRASS: 1>)
164 more...
(PlayerRank(player=Player(id=104925, name='Novak Djokovic'), rank=1, surface=<Surface.GRASS: 1>),
0.7407407407407407)
Publish new version
For developers
Via Github Actions
- Update version number in pyproject.toml
- Merge to main (via PR, direct push to main or other way)
- Create new release on Github
Direct to PyPI
Build and upload:
python -m build
twine upload dist/*
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
tennisrank-0.1.8.tar.gz
(9.6 kB
view details)
Built Distribution
File details
Details for the file tennisrank-0.1.8.tar.gz
.
File metadata
- Download URL: tennisrank-0.1.8.tar.gz
- Upload date:
- Size: 9.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 118a089ab303383959c1f0aaf6e7277c2a922c7e2986aef5140de3046941e217 |
|
MD5 | 489553acdcb0788ea412e85c07b9ebee |
|
BLAKE2b-256 | a91e1b18f4ac2c1f4a682822021e7f8117ce5f1d6fb7b3b8c97313505df9750e |
File details
Details for the file tennisrank-0.1.8-py3-none-any.whl
.
File metadata
- Download URL: tennisrank-0.1.8-py3-none-any.whl
- Upload date:
- Size: 9.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c78e18322a4f8837ee9979eb4e88a2cf09cb45b7cd28b0e00525ae48d16846fd |
|
MD5 | 4bbdc09caddf29eb1f88a1f41efa3330 |
|
BLAKE2b-256 | 74bd8392df3103edf7574dcfb622bd9ee6576bf20a704f3588bcc4040858b212 |