Commit 9345258a authored by uudlo's avatar uudlo

Add confidence interval to the glicko2 graph

parent 4e68abb3
......@@ -68,6 +68,7 @@ ONCE_FOR_ALL_STATS = [
'elo_history',
'glicko2_history',
'glicko2_rd_history',
'glicko2_confidence_interval_history'
]
def elo_history():
......@@ -137,6 +138,13 @@ def glicko2_rd_history():
_, rd_history = get_cached(modules[__name__], '_glicko2_history')
return rd_history
def glicko2_confidence_interval_history():
rating_history, rd_history = get_cached(modules[__name__], '_glicko2_history')
ret = {}
for player in rating_history:
ret[player] = list(map(lambda r: (r[0]-2*r[1], r[0]+2*r[1]), zip(rating_history[player], rd_history[player])))
return ret
# hidden method with computation
def _glicko2_history():
glicko2 = Glicko2(800, 100, 0.1, 1.2)
......@@ -331,6 +339,10 @@ class Player(dbmodels.Model):
def glicko2_rd(self, it):
return glicko2_rd_history()[self][-1]
STAT_DESCRIPTION['glicko2_confidence_interval_history'] = "Glicko2 confidence interval history", "GL2CIH"
def glicko2_confidence_interval(self, it):
return glicko2_confidence_interval_history()[self][-1]
STAT_DESCRIPTION['streaks'] = "Streaks","Str"
def streaks(self, it):
played_games = self.played_games(it).values_list('won', flat=True)
......
......@@ -153,6 +153,24 @@ var dataSetsEloHistory = [
];
var dataSetsGlicko2History = [
{% for player in player_list|dictsort:"stats.points" %}{
fill: "tozerox",
fillcolor: "{{ player.color }}33",
line: {
color: "transparent"
},
name: "{{ player.name }}",
type: "scatter",
showlegend: false,
x: [
{% for point in player.stats.glicko2_confidence_interval_history %}{{ forloop.counter0 }},{% endfor %}
{% for point in player.stats.glicko2_confidence_interval_history reversed %}{{ forloop.revcounter0 }},{% endfor %}
],
y: [
{% for point in player.stats.glicko2_confidence_interval_history %}{{ point.1 }},{% endfor %}
{% for point in player.stats.glicko2_confidence_interval_history reversed %}{{ point.0 }},{% endfor %}
],
},{% endfor %}
{% for player in player_list|dictsort:"stats.points" %}{
marker: {
color: "{{ player.color }}",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment