Skip to content

Commit 40b2989

Browse files
authored
Modify default tau value to 25/300 (#61)
* Modify default tau value to 25/300 * Remove note about default tau value * Add changelog fragment
1 parent e6b194b commit 40b2989

File tree

13 files changed

+45
-32
lines changed

13 files changed

+45
-32
lines changed

benchmark/benchmark.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,19 @@
55

66
import jsonlines
77
import trueskill
8-
from prompt_toolkit import print_formatted_text as print, HTML, prompt
8+
from prompt_toolkit import HTML
9+
from prompt_toolkit import print_formatted_text as print
10+
from prompt_toolkit import prompt
911
from prompt_toolkit.completion import WordCompleter
1012
from prompt_toolkit.shortcuts import ProgressBar
1113

1214
import openskill
1315
from openskill.models import (
14-
ThurstoneMostellerPart,
15-
ThurstoneMostellerFull,
1616
BradleyTerryFull,
1717
BradleyTerryPart,
1818
PlackettLuce,
19+
ThurstoneMostellerFull,
20+
ThurstoneMostellerPart,
1921
)
2022

2123
# Stores

benchmark/draw_benchmark.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,20 @@
66
import numpy as np
77
import pandas
88
import trueskill
9-
from prompt_toolkit import print_formatted_text as print, HTML, prompt
9+
from prompt_toolkit import HTML
10+
from prompt_toolkit import print_formatted_text as print
11+
from prompt_toolkit import prompt
1012
from prompt_toolkit.completion import WordCompleter
1113
from prompt_toolkit.shortcuts import ProgressBar
1214
from sklearn.model_selection import train_test_split
1315

1416
import openskill
1517
from openskill.models import (
16-
ThurstoneMostellerPart,
17-
ThurstoneMostellerFull,
1818
BradleyTerryFull,
1919
BradleyTerryPart,
2020
PlackettLuce,
21+
ThurstoneMostellerFull,
22+
ThurstoneMostellerPart,
2123
)
2224

2325
# Stores

benchmark/split_benchmark.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,20 @@
66
import jsonlines
77
import numpy as np
88
import trueskill
9-
from prompt_toolkit import print_formatted_text as print, HTML, prompt
9+
from prompt_toolkit import HTML
10+
from prompt_toolkit import print_formatted_text as print
11+
from prompt_toolkit import prompt
1012
from prompt_toolkit.completion import WordCompleter
1113
from prompt_toolkit.shortcuts import ProgressBar
1214
from sklearn.model_selection import train_test_split
1315

1416
import openskill
1517
from openskill.models import (
16-
ThurstoneMostellerPart,
17-
ThurstoneMostellerFull,
1818
BradleyTerryFull,
1919
BradleyTerryPart,
2020
PlackettLuce,
21+
ThurstoneMostellerFull,
22+
ThurstoneMostellerPart,
2123
)
2224

2325
# Stores

changes/61.breaking.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Modify default ``tau`` value to ``25/300`` #61

docs/conf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,10 @@
4848
pass
4949

5050
try:
51-
import sphinx
5251
from distutils.version import LooseVersion
5352

53+
import sphinx
54+
5455
cmd_line_template = (
5556
"sphinx-apidoc --implicit-namespaces -f -o {outputdir} {moduledir}"
5657
)

docs/time_decay.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from openskill import Rating, rate, predict_win
1+
from openskill import Rating, predict_win, rate
22

33
x, y = Rating(), Rating()
44

openskill/__init__.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
from openskill.rate import ordinal
21
from openskill.rate import (
3-
rate,
42
Rating,
53
create_rating,
6-
team_rating,
7-
predict_win,
4+
ordinal,
85
predict_draw,
6+
predict_win,
7+
rate,
8+
team_rating,
99
)
1010

11-
1211
__version__ = "2.5.1"

openskill/constants.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,17 @@ def beta_squared(**options) -> float:
4040
return beta(**options) ** 2
4141

4242

43+
def tau(**options) -> float:
44+
if "tau" in options:
45+
return options["tau"]
46+
else:
47+
return mu(**options) / 300
48+
49+
4350
class Constants:
4451
def __init__(self, **options):
4552
self.EPSILON: float = epsilon(**options)
4653
self.TWO_BETA_SQUARED: float = 2 * beta_squared(**options)
4754
self.BETA_SQUARED: float = beta_squared(**options)
4855
self.Z: float = z(**options)
56+
self.TAU: float = tau(**options)

openskill/rate.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22
import itertools
33
import math
44
from functools import reduce
5-
from typing import Optional, Union, List
5+
from typing import List, Optional, Union
66

7-
from openskill.constants import mu as default_mu, beta, Constants
7+
from openskill.constants import Constants, beta
8+
from openskill.constants import mu as default_mu
89
from openskill.constants import sigma as default_sigma
910
from openskill.models.plackett_luce import PlackettLuce
1011
from openskill.statistics import phi_major, phi_major_inverse
11-
from openskill.util import unwind, rankings
12+
from openskill.util import rankings, unwind
1213

1314

1415
class Rating:
@@ -262,13 +263,12 @@ def rate(teams: List[List[Rating]], **options) -> List[List[Rating]]:
262263
:param prevent_sigma_increase: A :class:`~bool` that prevents sigma from ever increasing.
263264
:param options: Pass in a set of custom values for constants defined in the Weng-Lin paper.
264265
:return: Returns a list of :class:`~openskill.rate.Rating` objects.
265-
266-
.. note::
267-
``tau`` will default to ``25/300`` in the next major version update.
268266
"""
267+
constants = Constants(**options)
268+
tau = constants.TAU
269269
original_teams = copy.deepcopy(teams)
270270
if "tau" in options:
271-
tau_squared = options["tau"] * options["tau"]
271+
tau_squared = tau * tau
272272
for team_index, team in enumerate(teams):
273273
for player_index, player in enumerate(team):
274274
teams[team_index][player_index].sigma = math.sqrt(

tests/__init__.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
import math
22
from abc import ABC, abstractmethod
33
from collections import UserString
4-
from collections.abc import (
5-
Mapping,
6-
Set,
7-
Sequence,
8-
)
4+
from collections.abc import Mapping, Sequence, Set
95
from decimal import Decimal
106
from numbers import Real
117
from typing import List

0 commit comments

Comments
 (0)