Skip to content

george-cochrane/ELO-python-test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

ELO Rating System

A Python implementation of the ELO rating system for ranking and comparing items (like cars, players, etc.).

Features

  • ELO Rating Calculations: Implements the standard ELO formula for rating updates
  • Expected Score Calculation: Calculate win probabilities between any two ratings
  • Configurable K-Factor: Adjust rating volatility (32 for beginners, 16 for experienced, 8 for masters)
  • Interactive Demo: Car comparison example with step-by-step mathematical breakdown

Usage

from main import EloRatingSystem

# Initialize with default K-factor of 32
elo = EloRatingSystem(k_factor=32)

# Calculate expected score
expected = elo.expected_score(rating_a=1600, rating_b=1400)

# Update ratings after a match
new_rating_a, new_rating_b = elo.update_ratings(
    rating_a=1600, 
    rating_b=1400, 
    score_a=1  # 1=win, 0=loss, 0.5=draw
)

Running the Demo

python main.py

The demo simulates car comparisons and shows:

  • Starting ratings (all equal at 1500)
  • Step-by-step rating updates
  • Final rankings
  • Win probability analysis
  • Mathematical breakdown of calculations

ELO Formula

The ELO system uses these key formulas:

Expected Score:

E_A = 1 / (1 + 10^((R_B - R_A) / 400))

Rating Update:

R_new = R_old + K × (S - E)

Where:

  • E = Expected score (0 to 1)
  • S = Actual score (1=win, 0=loss, 0.5=draw)
  • K = K-factor (rating change multiplier)

Example Output

🏎️  ELO RATING SYSTEM DEMO - Car Rankings
==================================================
Starting ratings (all equal):
  Audi R8: 1500
  Porsche 911: 1500
  VW Golf: 1500
  Old Volvo (1990): 1500

FINAL RANKINGS:
==================================================
1. Audi R8: 1632
2. Porsche 911: 1568
3. VW Golf: 1400
4. Old Volvo (1990): 1400

License

MIT License

About

Testing ELO algo

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages