Skip to main content

Margin dependent Elo ratings and predictions.

Project description

Margin-dependent Elo ratings and predictions model

https://github.com/morelandjs/melo/actions/workflows/tests.yml/badge.svg

Documentation

moreland.dev/projects/melo

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.1.tar.gz (29.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

melo-1.1.1-py2.py3-none-any.whl (25.7 kB view details)

Uploaded Python 2Python 3

File details

Details for the file melo-1.1.1.tar.gz.

File metadata

  • Download URL: melo-1.1.1.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

Hashes for melo-1.1.1.tar.gz
Algorithm Hash digest
SHA256 ac68dd906da292fc76256880ef80f61724034397878809586adce8efddc39506
MD5 0853f19f8c41c40e6dd98d8ac7f134ec
BLAKE2b-256 913798670d00f2041c93894a301bd49fdc88ca8d5cff7fa1e2888336584047d3

See more details on using hashes here.

File details

Details for the file melo-1.1.1-py2.py3-none-any.whl.

File metadata

  • Download URL: melo-1.1.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 25.7 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.2

File hashes

Hashes for melo-1.1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 794349e2cac84121438cf55ff6f3269d589e4c35b4d1c3de17f06b42aa07bf6f
MD5 0c7d798870bd51b7b4d24d8b1d50f02a
BLAKE2b-256 6d2f04201813380d4e57b6ae01defd532b6f69863695c78277482622c7d79c23

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page