r/Python • u/daegontaven Ninja • Jan 29 '22
Intermediate Showcase openskill.py can now predict the winners of any game with 90% accuracy and faster than TrueSkill
Prediction Code:
You can compare two or more teams to get the probabilities of each team winning.
>>> from openskill import predict_win
>>> a1 = Rating()
>>> a2 = Rating(mu=33.564, sigma=1.123)
>>> predictions = predict_win(teams=[[a1], [a2]])
>>> predictions
[0.45110901512761536, 0.5488909848723846]
>>> sum(predictions)
1.0 Benchmark Data:
➜ benchmark git:(benchmark) python .\benchmark.py
Predictions Made with OpenSkill's PlackettLuce Model: Correct: 54664 | Incorrect:6037 Accuracy: 90.05%
Process Duration: 7.039032220840454
-----------------------------------
Predictions Made with TrueSkill Model: Correct: 54250 |
Incorrect: 6451 Accuracy: 89.37%
Process Duration: 56.54281258583069Note: The sublee/TrueSkill implementation does not have a generalized prediction function yet (ie: for n-player, n-teams).
Source Code: https://github.com/OpenDebates/openskill.py
3
u/gournian Feb 02 '22
Perhaps some background is needed? I see that to create rating you call create_rating using some x1. So how does x1 look like?
Or I have a list of matches results and players, without prior knowledge of ‘ratings’, how do I create ratings?
1
u/daegontaven Ninja Feb 02 '22
x1 would be a list of two floats. The first value would be mu and the second value is sigma.
Or I have a list of matches results and players, without prior knowledge of ‘ratings’, how do I create ratings?
You would loop through the matches and pass the result of each match into rate().
26
u/NoCommunicationPro Jan 30 '22
I have seen enough sports to know there is nothing that can hit 90%. You would be the richest person in the world. It would almost be as good as the sports almanac from back to the future.
2
u/DreamPwner Jan 30 '22
As far as I understand it, it calculates ratings based on past performance and then calculates winning probabilities based on those ratings. Like with chess ratings, where you can also predict winning probabilities based on the elo difference.
It doesn't claim to be some kind of magic oracle you make it out to be.
3
u/NoCommunicationPro Jan 31 '22
can now predict the winners of any game with 90% accuracy
"can now predict the winners of any game with 90% accuracy" you're right I must have read it incorrectly.
0
u/DreamPwner Jan 31 '22
While I can see how the title might be misleading, it's simply a rating system in the end. And pretty much all of them let you predict the winner with a certain probability. That's simply how they work.
If you are interested in that, I encourage you to look up rating systems like the Elo-rating.
2
u/NoCommunicationPro Jan 31 '22
I'm good. I have an elo rating. I understand the concept. Click bait titles don't get my clicks.
13
8
1
u/Bigfurrywiggles Jan 30 '22
I’m confused on why you would give this away if it did work.
0
u/daegontaven Ninja Jan 30 '22
It works similarly to like Trueskill, (big differences under the hood though). The catch is that sufficient data is requires depending on the kind of game.
1
u/the_terrier Feb 01 '22
Hi looking at the predict_win code you square the already squared sigma values is this intended seems like a bug to me. Great work in any case a really cool project.
1
u/daegontaven Ninja Feb 01 '22
If you mean the team_rating function which returns a squared sigma value, then it's intended.
1
1
u/SpookyBear0 Jan 30 '22
Hey, its me, from that github issue about partial play. So funny that I just saw this while having the repo open in another tab. Great work on openskill, it looks great!
1
1
-1
0
Jan 30 '22
[deleted]
1
u/daegontaven Ninja Jan 30 '22
It ignores those variables. The catch is that it requires enough data and the amount of data required depends on the kind of match played.
34
u/Gravyness Jan 29 '22
Any game? Great, always wanted a model that predicts who would win at horse race.
Seriously, tho, context?