Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weightings not respected when supplied as dictionary #9

Closed
bernd-wechner opened this issue Sep 4, 2014 · 4 comments
Closed

Weightings not respected when supplied as dictionary #9

bernd-wechner opened this issue Sep 4, 2014 · 4 comments

Comments

@bernd-wechner
Copy link
Contributor

In this sample:

    # Multi Player example
    print("\nMultiplayer example")

    class Player(object):
        def __init__(self, name, rating, team):
            self.name = name
            self.rating = rating
            self.team = team

    p1 = Player('Player A', Rating(), 0)
    p2 = Player('Player B', Rating(), 0)
    p3 = Player('Player C', Rating(), 1)

    print(p1.rating, p2.rating, p3.rating)

    teams = [{p1: p1.rating, p2: p2.rating}, {p3: p3.rating}]
    ranks = [1, 2]
    weights = {(0, p1): 1, (0, p2): 1, (1, p3): 1}

    rated = trueskill.rate(teams, ranks, weights=weights)

    p1.rating = rated[p1.team][p1]
    p2.rating = rated[p2.team][p2]
    p3.rating = rated[p3.team][p3]

    print(p1.rating, p2.rating, p3.rating)

The result is:

    Multiplayer example
    trueskill.Rating(mu=25.000, sigma=8.333) trueskill.Rating(mu=25.000, sigma=8.333) trueskill.Rating(mu=25.000, sigma=8.333)
    trueskill.Rating(mu=25.604, sigma=8.075) trueskill.Rating(mu=25.604, sigma=8.075) trueskill.Rating(mu=24.396, sigma=8.075)

All the weights were 1. Now give p2 a weight of 0.5:

    weights = {(0, p1): 1, (0, p2): 0.5, (1, p3): 1}

The result is identical:

If the weights are supplied as a list of tuples instead:

    weights = weights = [(1, 0.5), (1,)]    # for p1, p2, p3 respectively

Then the results reflect the weights:

    Multiplayer example
    trueskill.Rating(mu=25.000, sigma=8.333) trueskill.Rating(mu=25.000, sigma=8.333) trueskill.Rating(mu=25.000, sigma=8.333)
    trueskill.Rating(mu=26.764, sigma=7.685) trueskill.Rating(mu=25.882, sigma=8.176) trueskill.Rating(mu=23.236, sigma=7.685)
sublee added a commit that referenced this issue Sep 4, 2014
@sublee
Copy link
Owner

sublee commented Sep 4, 2014

Thanks to report. I fixed this error. Upgrade the package by:

$ pip install -U trueskill

If your problem has been gone, please close this issue.

@bernd-wechner
Copy link
Contributor Author

Thanks enormously!

Heungsub Lee wrote:

|pip install -U trueskill|

@sublee
Copy link
Owner

sublee commented Sep 11, 2014

@bernd-wechner Is this issue fixed? Then I'll or you'll close it.

@bernd-wechner
Copy link
Contributor Author

Heungsub,

Yep, it's fixed. Thanks heaps!. You can close it. Have not looked at
code most week, but will get back into it some time in coming month.

Regards,

Bernd.

Heungsub Lee wrote:

@bernd-wechner https://github.com/bernd-wechner Is this issue fixed?
Then I'll or you'll close it.


Reply to this email directly or view it on GitHub
#9 (comment).

@sublee sublee closed this as completed Sep 12, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants