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.2.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.2-py2.py3-none-any.whl (25.8 kB view details)

Uploaded Python 2Python 3

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

Hashes for melo-1.1.2.tar.gz
Algorithm Hash digest
SHA256 6d4ad267a219c64d72eec298e37e6fd22716c037140ea1e8cd43a44856008268
MD5 b030921352145885660878e85c50aede
BLAKE2b-256 e07be4cf6a139542291efdeaecfa019eff5b2dfa81dcaeaa4d287d2ab5cd47d8

See more details on using hashes here.

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

Hashes for melo-1.1.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 a5264c8df2090ad18d16687e643320d0066d6ad08735c5c60294fceab5cb9031
MD5 e7759a4bd0260cd64834e5dd706e1934
BLAKE2b-256 c8ac8dcfdb000c8e3ea3ba0b58c756f591101f40adc7bb8472903f57e792f635

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