rstt.ranking.standard package

Submodules

rstt.ranking.standard.consensus module

class rstt.ranking.standard.consensus.BTRanking(name: str = '', players: list[SPlayer] | None = None)[source]

Bases: Ranking

Consensus Ranking For the Bradley-Terry Model

Ranking based on the player’s level() method. This also work for Time varying player, inherited class from rstt.player.playerTVS.PlayerTVS, But it needs to be updated manually everytime player’s level is updated.

Attributes

datamodel: rstt.ranking.datamodel.KeyModel (float as rating type) backend: rstt.ranking.inferer.PlayerLevel handler: rstt.ranking.observer.PlayerChecker

Parameters

namestr, optional

A name to identify the ranking, by default ‘’

players_type_, optional

SPlayer to add to the ranking, by default None

Warning

BTRanking validity is limited to Bradley-Terry like models and is not suited for simulation using ‘None-transitive’ level.

class rstt.ranking.standard.consensus.WinRate(name: str, default: float = -1.0, scope: int = 2147483647, players: list[SPlayer] | None = None)[source]

Bases: Ranking

Ranking based on Win rate

Ranking that tracks the winrate of rstt.player.player.Player. The update function does not take any parameters, win rate is computed directly with the player’s game history.

Attributes

datamodel rstt.ranking.datamodel.KeyModel (float as rating) backend rstt.ranking.inferer.PlayerWinPRC handler rstt.ranking.observer.PlayerChecker

Parameters

namestr, optional

A name to identify the ranking, by default ‘’

defaultfloat, optional

A default rating value for when player have no game in their history, by default -1.0

playersOptional[List[SPlayer]], optional

Players to register in the ranking, by default None

forward(*args, **kwargs)[source]

Internal ‘update’ function

This method calls the handler rstt.stypes.handle_observations() with the parameters of the update function.

Note

FOR RANKING DESIGNER ONLY method designed for devellopers who wants to modify the ranking.update function’s behavivous. In most cases, it is sufficient to write an apropriate observer as the ranking.handler.

However, sometimes it is relevant to do some ranking preprocessing before any rating updates. This would not always be possible to do inside the handle_observations method as the observer do not have access to all ranking attributes.

rstt.ranking.standard.basicElo module

class rstt.ranking.standard.basicElo.BasicElo(name: str, default: float = 1500, k: float = 20.0, lc: float = 400.0, base: float = 10.0, players: list[SPlayer] | None = None)[source]

Bases: Ranking

Simple Elo System

Attributes

datamodel: rstt.ranking.datamodel.KeyModel (float as rating type) backend: rstt.ranking.inferer.elo.Elo handler: rstt.ranking.observer.GameByGame

Parameters

namestr, optional

A name to identify the ranking, by default ‘’

defaultfloat, optional

Datamodel parameter, a default elo rating, by default 1500.0

kfloat, optional

Backend parameter, the K value, by default 20.0

lcfloat, optional

Backend parameter, constant dividing the ratings difference in the expected score formula , by default 400.0

playersOptional[List[SPlayer]], optional

Players to register in the ranking, by default None

rstt.ranking.standard.basicGlicko module

class rstt.ranking.standard.basicGlicko.BasicGlicko(name: str, mu: float = 1500.0, sigma: float = 350.0, minRD: float = 30.0, maxRD: float = 350.0, c: float = 63.2, q: float = 0.005756462732485115, lc: int = 400, players: list[SPlayer] | None = None)[source]

Bases: Ranking

Simple Glicko system

Implement A glicko rating system as originaly proposed.

Note

As recommanded in the source paper, the update() method starts by adjusting each players rating before processing any game data (sort of a rating decay)

Attributes

datamodel: rstt.ranking.datamodel.GaussianModel (rstt.ranking.rating.GlickoRating as rating) backend: :class:`rstt.ranking.inferer.Glicko as backend handler rstt.ranking.observer.BatchGame as handler

Parameters

namestr, optional

A name to identify the ranking, by default ‘’

handler_type_, optional

Backend as parameter, by default BatchGame() The original recommendation is to update the ranking by grouping matches within rating period. Which is what the BatchGame Observer do, (each update call represent one period). To match other glicko, use A GameByGame observer

mufloat, optional

Datamodel parameter, the default mu of the rating, by default 1500.0

sigmafloat, optional

Datamodel parameter, the default sigma of the rating, by default 350.0

playersOptional[List[SPlayer]], optional

Players to register in the ranking, by default None

forward(*args, **kwargs)[source]

Internal ‘update’ function

This method calls the handler rstt.stypes.handle_observations() with the parameters of the update function.

Note

FOR RANKING DESIGNER ONLY method designed for devellopers who wants to modify the ranking.update function’s behavivous. In most cases, it is sufficient to write an apropriate observer as the ranking.handler.

However, sometimes it is relevant to do some ranking preprocessing before any rating updates. This would not always be possible to do inside the handle_observations method as the observer do not have access to all ranking attributes.

class rstt.ranking.standard.basicGlicko.BasicGlicko2(name: str, mu: float = 1500, sigma: float = 350, volatility: float = 0.06, tau: float = 0.3, epsilon: float = 5e-09, players: list[SPlayer] | None = None)[source]

Bases: Ranking

Glicko-2 system

Implement the glicko-2 rating system as descried by Prof. Mark E. Glickman.

Attributes

rating: rstt.ranking.rating.Glicko2Rating datamodel: rstt.ranking.datamodel.GaussianModel backend: rstt.ranking.inferer.Glicko2 as Inference handler rstt.ranking.observer.BatchGame as Observer

Parameters

namestr, optional

A name to identify the ranking, by default ‘’

handler_type_, optional

Backend as parameter, by default BatchGame() The original recommendation is to update the ranking by grouping matches within rating period. Which is what the BatchGame Observer do, (each update call represent one period). To match other glicko, use A GameByGame observer

mufloat, optional

Glicko2Rating parameter, the default mu of the rating, by default 1500.0

sigmafloat, optional

Glicko2Rating parameter, the default sigma of the rating, by default 350.0

volatility: float, optional

Glicko2Rating parameter, the default volatility of rating, by default 0.06

tau: float, optional

Glicko2 Inference parameter. Tau constrains the change in volatility over time. Reasonable choices are between 0.3 and 1.2, by default 0.3

epsilon: float, optional

Glicko2 Inference parameter. Convergence tolerance of the Illinois algorithm used in step 5 of rating update, by default 0.000000005

playersOptional[List[SPlayer]], optional

Players to register in the ranking, by default None

forward(*args, **kwargs)[source]

Glicko2 algorithm

  1. adjust rating of unactive player

  2. adapt system parameter tau

  3. update rating

rstt.ranking.standard.basicGlicko.get_ratings_for_glicko(prior: RatingSystem, data: dict[str, Any]) None[source]

rstt.ranking.standard.basicOS module

class rstt.ranking.standard.basicOS.BasicOS(name: str, model=None, players: list[SPlayer] | None = None)[source]

Bases: Ranking

Simple OpenSkill Integretion

Ranking to integrate an openskill model into the rstt package.

Attributes

datamodel: rstt.ranking.datamodel.GaussianModel (openskill.models.rating as rating type) backend: an openskill model instance handler: rstt.ranking.standard.BasicOs.OSGBG, which behaves as a GameByGame observer

Parameters

namestr, optional

A name to identify the ranking, by default ‘’

modelopenskills.models

One of openskills.models implementation, by default None

playersOptional[List[SPlayer]], optional

Players to register in the ranking, by default None

Example:

1from rstt import Player, BasicOS
2from openskill.models import PlackettLuce
3
4competitors = Player.create(nb=10)
5pl = BasicOS(name='Plackett-Luce', model= PlackettLuce(), players=competitors)
6pl.plot()
quality(game: SMatch) float[source]
class rstt.ranking.standard.basicOS.OSGBG[source]

Bases: ObsTemplate

Observer for the BasicOS ranking class

Similar to rstt.ranking.observer.GameByGame, but dealing with ‘kwargs’ ambiguity

extractor(matches: list[SMatch])[source]
output_formater(data: dict[str, Any], output: list[list[Any]])[source]
query(prior: RatingSystem, data: dict[str, Any])[source]

rstt.ranking.standard.successRanking module

class rstt.ranking.standard.successRanking.SuccessRanking(name: str, window_range: int = 1, tops: int = 1, buffer: int | None = None, nb: int | None = None, players: list[SPlayer] | None = None, default: dict[int, float] | None = None)[source]

Bases: Ranking

Merit Based Ranking

Usefull to implement Ranking system like the one in tennis for example.

Attributes

datamodel: rstt.ranking.datamodel.KeyModel (int as rating) backend: rstt.ranking.inferer.EventScoring handler: rstt.ranking.observer.PlayerChecker

Parameters

namestr, optional

A name to identify the ranking, by default ‘’

bufferint

Backend parameter. The number of event to consider for the rating, starting from the last.

nbint

Backend parameter. The actual number of event in the buffer to use for the ratings computation.

defaultOptional[Dict[int, float]], optional

Backend Parameter. Mapping placement in event to points for the rating, by default None

playersOptional[List[SPlayer]], optional

Players to register in the ranking, by default None

forward(event: Event | None = None, events: list[Event] | None = None)[source]

Internal ‘update’ function

This method calls the handler rstt.stypes.handle_observations() with the parameters of the update function.

Note

FOR RANKING DESIGNER ONLY method designed for devellopers who wants to modify the ranking.update function’s behavivous. In most cases, it is sufficient to write an apropriate observer as the ranking.handler.

However, sometimes it is relevant to do some ranking preprocessing before any rating updates. This would not always be possible to do inside the handle_observations method as the observer do not have access to all ranking attributes.

Module contents

Implement classic and usefull Ranking System

class rstt.ranking.standard.BTRanking(name: str = '', players: list[SPlayer] | None = None)[source]

Bases: Ranking

Consensus Ranking For the Bradley-Terry Model

Ranking based on the player’s level() method. This also work for Time varying player, inherited class from rstt.player.playerTVS.PlayerTVS, But it needs to be updated manually everytime player’s level is updated.

Attributes

datamodel: rstt.ranking.datamodel.KeyModel (float as rating type) backend: rstt.ranking.inferer.PlayerLevel handler: rstt.ranking.observer.PlayerChecker

Parameters

namestr, optional

A name to identify the ranking, by default ‘’

players_type_, optional

SPlayer to add to the ranking, by default None

Warning

BTRanking validity is limited to Bradley-Terry like models and is not suited for simulation using ‘None-transitive’ level.

class rstt.ranking.standard.BasicElo(name: str, default: float = 1500, k: float = 20.0, lc: float = 400.0, base: float = 10.0, players: list[SPlayer] | None = None)[source]

Bases: Ranking

Simple Elo System

Attributes

datamodel: rstt.ranking.datamodel.KeyModel (float as rating type) backend: rstt.ranking.inferer.elo.Elo handler: rstt.ranking.observer.GameByGame

Parameters

namestr, optional

A name to identify the ranking, by default ‘’

defaultfloat, optional

Datamodel parameter, a default elo rating, by default 1500.0

kfloat, optional

Backend parameter, the K value, by default 20.0

lcfloat, optional

Backend parameter, constant dividing the ratings difference in the expected score formula , by default 400.0

playersOptional[List[SPlayer]], optional

Players to register in the ranking, by default None

class rstt.ranking.standard.BasicGlicko(name: str, mu: float = 1500.0, sigma: float = 350.0, minRD: float = 30.0, maxRD: float = 350.0, c: float = 63.2, q: float = 0.005756462732485115, lc: int = 400, players: list[SPlayer] | None = None)[source]

Bases: Ranking

Simple Glicko system

Implement A glicko rating system as originaly proposed.

Note

As recommanded in the source paper, the update() method starts by adjusting each players rating before processing any game data (sort of a rating decay)

Attributes

datamodel: rstt.ranking.datamodel.GaussianModel (rstt.ranking.rating.GlickoRating as rating) backend: :class:`rstt.ranking.inferer.Glicko as backend handler rstt.ranking.observer.BatchGame as handler

Parameters

namestr, optional

A name to identify the ranking, by default ‘’

handler_type_, optional

Backend as parameter, by default BatchGame() The original recommendation is to update the ranking by grouping matches within rating period. Which is what the BatchGame Observer do, (each update call represent one period). To match other glicko, use A GameByGame observer

mufloat, optional

Datamodel parameter, the default mu of the rating, by default 1500.0

sigmafloat, optional

Datamodel parameter, the default sigma of the rating, by default 350.0

playersOptional[List[SPlayer]], optional

Players to register in the ranking, by default None

forward(*args, **kwargs)[source]

Internal ‘update’ function

This method calls the handler rstt.stypes.handle_observations() with the parameters of the update function.

Note

FOR RANKING DESIGNER ONLY method designed for devellopers who wants to modify the ranking.update function’s behavivous. In most cases, it is sufficient to write an apropriate observer as the ranking.handler.

However, sometimes it is relevant to do some ranking preprocessing before any rating updates. This would not always be possible to do inside the handle_observations method as the observer do not have access to all ranking attributes.

class rstt.ranking.standard.BasicGlicko2(name: str, mu: float = 1500, sigma: float = 350, volatility: float = 0.06, tau: float = 0.3, epsilon: float = 5e-09, players: list[SPlayer] | None = None)[source]

Bases: Ranking

Glicko-2 system

Implement the glicko-2 rating system as descried by Prof. Mark E. Glickman.

Attributes

rating: rstt.ranking.rating.Glicko2Rating datamodel: rstt.ranking.datamodel.GaussianModel backend: rstt.ranking.inferer.Glicko2 as Inference handler rstt.ranking.observer.BatchGame as Observer

Parameters

namestr, optional

A name to identify the ranking, by default ‘’

handler_type_, optional

Backend as parameter, by default BatchGame() The original recommendation is to update the ranking by grouping matches within rating period. Which is what the BatchGame Observer do, (each update call represent one period). To match other glicko, use A GameByGame observer

mufloat, optional

Glicko2Rating parameter, the default mu of the rating, by default 1500.0

sigmafloat, optional

Glicko2Rating parameter, the default sigma of the rating, by default 350.0

volatility: float, optional

Glicko2Rating parameter, the default volatility of rating, by default 0.06

tau: float, optional

Glicko2 Inference parameter. Tau constrains the change in volatility over time. Reasonable choices are between 0.3 and 1.2, by default 0.3

epsilon: float, optional

Glicko2 Inference parameter. Convergence tolerance of the Illinois algorithm used in step 5 of rating update, by default 0.000000005

playersOptional[List[SPlayer]], optional

Players to register in the ranking, by default None

forward(*args, **kwargs)[source]

Glicko2 algorithm

  1. adjust rating of unactive player

  2. adapt system parameter tau

  3. update rating

class rstt.ranking.standard.BasicOS(name: str, model=None, players: list[SPlayer] | None = None)[source]

Bases: Ranking

Simple OpenSkill Integretion

Ranking to integrate an openskill model into the rstt package.

Attributes

datamodel: rstt.ranking.datamodel.GaussianModel (openskill.models.rating as rating type) backend: an openskill model instance handler: rstt.ranking.standard.BasicOs.OSGBG, which behaves as a GameByGame observer

Parameters

namestr, optional

A name to identify the ranking, by default ‘’

modelopenskills.models

One of openskills.models implementation, by default None

playersOptional[List[SPlayer]], optional

Players to register in the ranking, by default None

Example:

1from rstt import Player, BasicOS
2from openskill.models import PlackettLuce
3
4competitors = Player.create(nb=10)
5pl = BasicOS(name='Plackett-Luce', model= PlackettLuce(), players=competitors)
6pl.plot()
quality(game: SMatch) float[source]
class rstt.ranking.standard.SuccessRanking(name: str, window_range: int = 1, tops: int = 1, buffer: int | None = None, nb: int | None = None, players: list[SPlayer] | None = None, default: dict[int, float] | None = None)[source]

Bases: Ranking

Merit Based Ranking

Usefull to implement Ranking system like the one in tennis for example.

Attributes

datamodel: rstt.ranking.datamodel.KeyModel (int as rating) backend: rstt.ranking.inferer.EventScoring handler: rstt.ranking.observer.PlayerChecker

Parameters

namestr, optional

A name to identify the ranking, by default ‘’

bufferint

Backend parameter. The number of event to consider for the rating, starting from the last.

nbint

Backend parameter. The actual number of event in the buffer to use for the ratings computation.

defaultOptional[Dict[int, float]], optional

Backend Parameter. Mapping placement in event to points for the rating, by default None

playersOptional[List[SPlayer]], optional

Players to register in the ranking, by default None

forward(event: Event | None = None, events: list[Event] | None = None)[source]

Internal ‘update’ function

This method calls the handler rstt.stypes.handle_observations() with the parameters of the update function.

Note

FOR RANKING DESIGNER ONLY method designed for devellopers who wants to modify the ranking.update function’s behavivous. In most cases, it is sufficient to write an apropriate observer as the ranking.handler.

However, sometimes it is relevant to do some ranking preprocessing before any rating updates. This would not always be possible to do inside the handle_observations method as the observer do not have access to all ranking attributes.

class rstt.ranking.standard.WinRate(name: str, default: float = -1.0, scope: int = 2147483647, players: list[SPlayer] | None = None)[source]

Bases: Ranking

Ranking based on Win rate

Ranking that tracks the winrate of rstt.player.player.Player. The update function does not take any parameters, win rate is computed directly with the player’s game history.

Attributes

datamodel rstt.ranking.datamodel.KeyModel (float as rating) backend rstt.ranking.inferer.PlayerWinPRC handler rstt.ranking.observer.PlayerChecker

Parameters

namestr, optional

A name to identify the ranking, by default ‘’

defaultfloat, optional

A default rating value for when player have no game in their history, by default -1.0

playersOptional[List[SPlayer]], optional

Players to register in the ranking, by default None

forward(*args, **kwargs)[source]

Internal ‘update’ function

This method calls the handler rstt.stypes.handle_observations() with the parameters of the update function.

Note

FOR RANKING DESIGNER ONLY method designed for devellopers who wants to modify the ranking.update function’s behavivous. In most cases, it is sufficient to write an apropriate observer as the ranking.handler.

However, sometimes it is relevant to do some ranking preprocessing before any rating updates. This would not always be possible to do inside the handle_observations method as the observer do not have access to all ranking attributes.