Competitors
Elo Competitor
- class elote.competitors.elo.EloCompetitor(initial_rating: float = 400, k_factor: float = 32)[source]
Overview
Elo rating is a rating system based on pairwise comparisons. Ratings are given to competitors based on their comparisons (bouts) with peers, in which they can win, lose or tie. The change in a players rating is scaled by the rating difference between them and their competitor.
[1] Elo, Arpad (1978). The Rating of Chessplayers, Past and Present. Arco. ISBN 0-668-04721-6.
Basic Usage
from elote import EloCompetitor good = EloCompetitor(initial_rating=400) better = EloCompetitor(initial_rating=500) better.beat(good) print('probability of better beating good: %5.2f%%' % (better.expected_score(good) * 100, ))
Class Variables
Class variables are configured for all competitors in a population, not on a per-competitor basis. See the documentation on
Arenas
to see how to set these safely._base_rating: defaults to 400.
_k_factor: tunes the speed of response to new information, higher is faster response. Default=32
Configuration Options
- Parameters:
initial_rating (int) – the initial rating to use for a new competitor who has no history. Default 400
- beat(competitor: BaseCompetitor)[source]
Takes in a competitor object that lost a match to this competitor, updates the ratings for both.
- Parameters:
competitor (EloCompetitor) – the competitor that lost their bout
- expected_score(competitor: BaseCompetitor)[source]
In Elo rating, a player’s expected score is their probability of winning plus half their probability of drawing. This is because in Elo rating a draw is not explicitly accounted for, but rather counted as half of a win and half of a loss. It can make the expected score a bit difficult to reason about, so be careful.
- Parameters:
competitor – another EloCompetitor to compare this competitor to.
- Returns:
likelihood to beat the passed competitor, as a float 0-1.
- export_state()[source]
Exports all information needed to re-create this competitor from scratch later on.
- Returns:
dictionary of kwargs and class-args to re-instantiate this object
- tied(competitor: BaseCompetitor)[source]
Takes in a competitor object that tied in a match to this competitor, updates the ratings for both.
- Parameters:
competitor (EloCompetitor) – the competitor that tied with this one
Glicko Competitor
- class elote.competitors.glicko.GlickoCompetitor(initial_rating: float = 1500, initial_rd: float = 350)[source]
from http://www.glicko.net/glicko/glicko.pdf
class vars:
_c: default 1
_q: default 0.0057565
- Parameters:
initial_rating – the initial rating to use for a new competitor who has no history. Default 1500
initial_rd – initial value of rd to use for new competitors with no history. Default 350
- beat(competitor: GlickoCompetitor)[source]
Takes in a competitor object that lost a match to this competitor, updates the ratings for both.
- Parameters:
competitor (GlickoCompetitor) – the competitor that lost thr bout
- expected_score(competitor: BaseCompetitor)[source]
The expected outcome of a match between this competitor and one passed in. Scaled between 0-1, where 1 is a strong likelihood of this competitor winning and 0 is a strong likelihood of this competitor losing.
- Parameters:
competitor – another EloCompetitor to compare this competitor to.
- Returns:
likelihood to beat the passed competitor, as a float 0-1.
- export_state()[source]
Exports all information needed to re-create this competitor from scratch later on.
- Returns:
dictionary of kwargs and class-args to re-instantiate this object
- tied(competitor: GlickoCompetitor)[source]
Takes in a competitor object that tied in a match to this competitor, updates the ratings for both.
- Parameters:
competitor (GlickoCompetitor) – the competitor that tied with this one
DWZ Competitor
- class elote.competitors.dwz.DWZCompetitor(initial_rating: float = 400)[source]
class vars:
_J: default 10
- Parameters:
initial_rating – the initial rating to use for a new competitor who has no history. Default 400
- beat(competitor: BaseCompetitor)[source]
Takes in a competitor object that lost a match to this competitor, updates the ratings for both.
- Parameters:
competitor (DWZCompetitor) – the competitor that lost thr bout
- expected_score(competitor: BaseCompetitor)[source]
The expected outcome of a match between this competitor and one passed in. Scaled between 0-1, where 1 is a strong likelihood of this competitor winning and 0 is a strong likelihood of this competitor losing.
- Parameters:
competitor – another EloCompetitor to compare this competitor to.
- Returns:
likelihood to beat the passed competitor, as a float 0-1.
- export_state()[source]
Exports all information needed to re-create this competitor from scratch later on.
- Returns:
dictionary of kwargs and class-args to re-instantiate this object
- tied(competitor: BaseCompetitor)[source]
Takes in a competitor object that tied in a match to this competitor, updates the ratings for both.
- Parameters:
competitor (DWZCompetitor) – the competitor that tied with this one
ECF Competitor
- class elote.competitors.ecf.ECFCompetitor(initial_rating: float = 40)[source]
class vars:
_delta: default 50
_n_periods: default 30
- Parameters:
initial_rating – the initial rating to use for a new competitor who has no history. Default 40
- beat(competitor: BaseCompetitor)[source]
Takes in a competitor object that lost a match to this competitor, updates the ratings for both.
- Parameters:
competitor (ECFCompetitor) – the competitor that lost their bout
- expected_score(competitor: BaseCompetitor)[source]
The expected outcome of a match between this competitor and one passed in. Scaled between 0-1, where 1 is a strong likelihood of this competitor winning and 0 is a strong likelihood of this competitor losing.
- Parameters:
competitor – another EloCompetitor to compare this competitor to.
- Returns:
likelihood to beat the passed competitor, as a float 0-1.
- export_state()[source]
Exports all information needed to re-create this competitor from scratch later on.
- Returns:
dictionary of kwargs and class-args to re-instantiate this object
- property rating
- Returns:
- tied(competitor: BaseCompetitor)[source]
Takes in a competitor object that tied in a match to this competitor, updates the ratings for both.
- Parameters:
competitor (ECFCompetitor) – the competitor that tied with this one
BlendedCompetitor
- class elote.competitors.ensemble.BlendedCompetitor(competitors: list, blend_mode: str = 'mean')[source]
- Parameters:
competitors –
blend_mode –
- beat(competitor: BaseCompetitor)[source]
Takes in a competitor object that lost a match to this competitor, updates the ratings for both.
- Parameters:
competitor (BlendedCompetitor) – the competitor that lost their bout
- expected_score(competitor: BaseCompetitor)[source]
The expected outcome of a match between this competitor and one passed in. Scaled between 0-1, where 1 is a strong likelihood of this competitor winning and 0 is a strong likelihood of this competitor losing.
- Parameters:
competitor – another EloCompetitor to compare this competitor to.
- Returns:
likelihood to beat the passed competitor, as a float 0-1.
- export_state()[source]
Exports all information needed to re-create this competitor from scratch later on.
- Returns:
dictionary of kwargs and class-args to re-instantiate this object
- tied(competitor: BaseCompetitor)[source]
Takes in a competitor object that tied in a match to this competitor, updates the ratings for both.
- Parameters:
competitor (BlendedCompetitor) – the competitor that tied with this one