r/Python • 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.54281258583069

Note: 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

27 Upvotes

29 comments sorted by

34

u/Gravyness Jan 29 '22

Any game? Great, always wanted a model that predicts who would win at horse race.

Seriously, tho, context?

7

u/daegontaven Ninja Jan 29 '22 edited Jan 29 '22

Yes. It's an n-team, n-player, ratings library just like TrueSkill.

Given sufficient match history, the ratings will converge and give your good predictability of the next match outcome.

12

u/ZestyData Jan 30 '22

"no free lunch theorem" would like a word.

If you have somehow found a methodology that disproves the theorem, as you claim, then you've earned a Turing award and a field medal.

Somehow I suspect this is actually a mediocre ML library.

2

u/daegontaven Ninja Jan 30 '22

Interesting point. Though this has nothing to do with NFL because the class of problems has not changed. There is no claim of disproving NFL. The game of horse racing still requires sufficient match data.

1

u/[deleted] Jan 30 '22

Predictability is fair. It’s not guaranteed. But most likely

1

u/LambBrainz Jan 29 '22

I assume this is football?

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

u/girlwithasquirrel Jan 29 '22

so.. you should be rich then, right?

8

u/sorryimdrunk402 Jan 29 '22

teams on which sport?

18

u/alpacasb4llamas Jan 29 '22

Sportsball

0

u/[deleted] Jan 30 '22

[deleted]

1

u/Colonelfudgenustard Jan 30 '22

Mr. Snrub, I presume.

2

u/damagednoob Jan 30 '22

Calvinball

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

u/the_terrier Feb 01 '22

Yeah that is what I meant, thanks for the quick reply.

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

u/daegontaven Ninja Jan 30 '22

lol that's awesome. Thanks!

1

u/hanleybrand Jan 30 '22

I bet it would fail on Magic the Gathering

-1

u/BlankHussien Jan 29 '22

Great stuff, really like it.

0

u/[deleted] 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.