Skip to main content

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))

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)

Source distribution for melo 1.1.2
File Size Uploaded
melo-1.1.2.tar.gz 29.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for melo 1.1.2
File Interpreter ABI Platform
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

Release history Release notifications | RSS feed

This release

1.1.2 This release

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page