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))
Release files for melo 1.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| melo-1.1.2.tar.gz | 29.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| melo-1.1.2-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 54.9 kB
Release files / melo-1.1.2.tar.gz
| Download URL | melo-1.1.2.tar.gz |
|---|---|
| Size | 29.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6d4ad267a219c64d72eec298e37e6fd22716c037140ea1e8cd43a44856008268
|
|
BLAKE2b-256 checksum How to use checksums |
e07be4cf6a139542291efdeaecfa019eff5b2dfa81dcaeaa4d287d2ab5cd47d8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.2
|
Release files / melo-1.1.2-py2.py3-none-any.whl
| Download URL | melo-1.1.2-py2.py3-none-any.whl |
|---|---|
| Size | 25.8 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
a5264c8df2090ad18d16687e643320d0066d6ad08735c5c60294fceab5cb9031
|
|
BLAKE2b-256 checksum How to use checksums |
c8ac8dcfdb000c8e3ea3ba0b58c756f591101f40adc7bb8472903f57e792f635
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.2
|