Margin dependent Elo ratings and predictions.
Project description
Margin-dependent Elo ratings and predictions model
Documentation
Quick start
Requirements: Python 2.7 or 3.3+ with numpy and scipy.
Install the latest release with pip:
pip install melo
Example usage:
import pkgutil
import numpy as np
from melo import Melo
# the package comes pre-bundled with an example dataset
pkgdata = pkgutil.get_data('melo', 'nfl.dat').splitlines()
dates, teams_home, scores_home, teams_away, scores_away = zip(
*[l.split() for l in pkgdata[1:]])
# define a binary comparison statistic
spreads = [int(h) - int(a) for h, a
in zip(scores_home, scores_away)]
# hyperparameters and options
k = 0.245
lines = np.arange(-50.5, 51.5)
regress = lambda months: .413 if months > 3 else 0
regress_unit = 'month'
commutes = False
# initialize the estimator
nfl_spreads = Melo(k, lines=lines, commutes=commutes,
regress=regress, regress_unit=regress_unit)
# fit the estimator to the training data
nfl_spreads.fit(dates, teams_home, teams_away, spreads)
# specify a comparison time
time = nfl_spreads.last_update
# predict the mean outcome at that time
mean = nfl_spreads.mean(time, 'CLE', 'KC')
print('CLE VS KC: {}'.format(mean))
# rank nfl teams at end of 2018 regular season
rankings = nfl_spreads.rank(time, statistic='mean')
for team, rank in rankings:
print('{}: {}'.format(team, rank))
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
melo-1.1.0.tar.gz
(26.6 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
melo-1.1.0-py3-none-any.whl
(25.6 kB
view details)
File details
Details for the file melo-1.1.0.tar.gz.
File metadata
- Download URL: melo-1.1.0.tar.gz
- Upload date:
- Size: 26.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.4.2 requests/2.21.0 setuptools/41.2.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4dd95bcf4064a95cd9cae0af3ccc7518ac19bddbcbb3d4e0c070cda5a734f566
|
|
| MD5 |
497b3b87d7b45affc57511a87625fc6a
|
|
| BLAKE2b-256 |
e853285d3ee1ae21944b6f707bd7e74c0fed9e210de1d01285e022777f30006a
|
File details
Details for the file melo-1.1.0-py3-none-any.whl.
File metadata
- Download URL: melo-1.1.0-py3-none-any.whl
- Upload date:
- Size: 25.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.4.2 requests/2.21.0 setuptools/41.2.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
97b075ee1995a59e540f4eb67c1ac8a28cff86a85061c295d28745dd1b7d38d3
|
|
| MD5 |
bdfd784da15dbdc557cccf2180abf01d
|
|
| BLAKE2b-256 |
ffab20fb05f150413fd0fd02afa6f60e207ba617fd745c896695a44214f6a2a5
|