TrueSkill Model Setup

I wish to formulate the model specified in the TrueSkill paper by Tom Minka. Essentially, I want to figure out the posterior on skills and I have presented a simple case of the paper as below:

Suppose I have 5 players with true skill levels denoted by s_i. During a game the player performance at level p_i\sim\mathcal{N}(s_i,\sigma^2). For simplicity sake, let’s assume that \sigma=1. The performance level is unobserved (latent variable), but we do see the rankings of each game that is played eg. y_{i1} = 1, y_{i2} = 4, ..., y_{i5}=2 for game i. Suppose we observe the ranks for a 1000 games, and that the prior on skill is \mathcal{N}(0,1). For instance see below:

import numpy as np

np.random.seed(1)

K = 5 # number of players
s = np.random.randn(1,K) * 5 # skill level
N = 1000 # number of games
p = np.random.randn(N, K) + s # play during each game (latent var)

# get ranking
order = p.argsort()
ranks = order.argsort()
# print some of the ranks
ranks[:10]
>>>
array([[4, 2, 1, 0, 3],
       [4, 1, 2, 0, 3],
       [4, 2, 1, 0, 3],
       [4, 1, 2, 0, 3],
       [4, 2, 1, 0, 3],
       [4, 1, 2, 0, 3],
       [4, 0, 2, 1, 3],
       [4, 0, 2, 1, 3],
       [4, 1, 2, 0, 3],
       [4, 2, 1, 0, 3]])

Question is, how would I go about setting up the model in PyMC3 to do this? The part I can’t figure out is the ranking part.

I think the model in Order statistics in PyMC3 is what you are looking for.

1 Like