sublee / trueskill

An implementation of the TrueSkill rating system for Python
https://trueskill.org/
Other
742 stars 112 forks source link

Win probability for N:M case #17

Closed romovpa closed 6 years ago

romovpa commented 6 years ago

I've implemented win probability function for the special case when one team plays versus another and exactly one team wins. This case occurs frequently in my practice, I want to use those function out of the box.

The formula is proposed to me by @AVSirotkin (co-author of trueskill modifications), but it also mentioned in #1 here. Unfortunately, I cant give detailed explanation of the math behind this formula.

Usage

import trueskill

r1 = trueskill.Rating()
r2 = trueskill.Rating()

trueskill.probability_1vs1(r1, r2)  # 0.5000000150000002

r1, r2 = trueskill.rate_1vs1(r1, r2)

trueskill.probability_1vs1(r1, r2)  # 0.7732314666870078
trueskill.probability_1vs1(r2, r1) + trueskill.probability_1vs1(r1, r2)  # 1.0

trueskill.probability_NvsM((r1, r1, r1), (r2, r2, r2))  # 0.9028951782988498
trueskill.probability_NvsM((r1, r1, r1), (r1, r2, r2))  # 0.8066134315889564
trueskill.probability_NvsM((r2,), (r1, r2))  # 0.020365869935275418
coveralls commented 6 years ago

Coverage Status

Coverage decreased (-1.2%) to 91.049% when pulling 1d6a2043282824d4acecd73dfee7d2c52c72e680 on romovpa:master into ba421226883530f5764d81c0d6ae7f5d1481ac8a on sublee:master.

coveralls commented 6 years ago

Coverage Status

Coverage increased (+0.1%) to 92.327% when pulling 797bdb276f97c56fe273e95934442e1b25f8ede2 on romovpa:master into ba421226883530f5764d81c0d6ae7f5d1481ac8a on sublee:master.

sublee commented 6 years ago

Thank you for the patch. But I don't think that the win probability can be a part of the TrueSkill library.

Here're the reasons:

But that's true, #1 is the most common issue on this project. So I suggest you write some note in the documentation instead of providing a code.

Tjorriemorrie commented 6 years ago

I would like to remark on some of those points:

3 that's not necessarily true, it took me a long time to find this, especially since I'm not familiar with stats at all, which means I'm not even sure what I'm looking for.

1 I would suggest that this is moved to an extras module. I agree it should be out of the main module, but excluding it is a bit too strict. This is also not the official TrueSkill repo. And making extra features available is what I like of python being batteries included.

2 Yes, I'm specifically looking for FFA. Currently I'm looping through every player and making two teams with the one player filling up the first team and the rest in the second team. I don't even know if that works :p

sublee commented 6 years ago

Algorithms in this library are all proved by the TrueSkill™ paper. But in case of a win probability function, there's no reliable reference.

I designed this library's responsibility to be limited in only TrueSkill™. If this library provides more than that by extras module, the responsibility will be expanded unexpectedly. So I reject providing batteries for TrueSkill™.

I agree with you it's not enough easy to find that the win probability function. At this point, I think a documentation about that can be enough to help people although it's not a battery.

romovpa commented 6 years ago

sublee commented 6 years ago

Don't be discouraged. Your suggestion was reasonable. Keep your passion for the Open Source culture. 👍

lukebyrne commented 4 years ago

@romovpa Do you have a function to calculate win probability as per this question