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.2.tar.gz
(29.2 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.2-py2.py3-none-any.whl
(25.8 kB
view details)
File details
Details for the file melo-1.1.2.tar.gz.
File metadata
- Download URL: melo-1.1.2.tar.gz
- Upload date:
- Size: 29.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6d4ad267a219c64d72eec298e37e6fd22716c037140ea1e8cd43a44856008268
|
|
| MD5 |
b030921352145885660878e85c50aede
|
|
| BLAKE2b-256 |
e07be4cf6a139542291efdeaecfa019eff5b2dfa81dcaeaa4d287d2ab5cd47d8
|
File details
Details for the file melo-1.1.2-py2.py3-none-any.whl.
File metadata
- Download URL: melo-1.1.2-py2.py3-none-any.whl
- Upload date:
- Size: 25.8 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a5264c8df2090ad18d16687e643320d0066d6ad08735c5c60294fceab5cb9031
|
|
| MD5 |
e7759a4bd0260cd64834e5dd706e1934
|
|
| BLAKE2b-256 |
c8ac8dcfdb000c8e3ea3ba0b58c756f591101f40adc7bb8472903f57e792f635
|