DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’» is a community of 967,611 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
Taven
Taven

Posted on

I ported openskill.js to python. No need to rely on the TrueSkill package and worry about licensing issues anymore.

For a while we've had no good free alternative to trueskill. Anyone that used trueskill was always plagued with doubt about whether there would be any repercussions for using it in commercial projects. Luckily there was already a package for javascript that solved this issue by implementing the Weng-Lin Bayesian ranking system. So I decided to port it to python. Hope this is useful to the general Python community and those creating systems that need ranking.

Installation

pip install openskill
Enter fullscreen mode Exit fullscreen mode

Usage

>>> from openskill import Rating, rate
>>> a1 = Rating()
>>> a1
Rating(mu=25, sigma=8.333333333333334)
>>> a2 = Rating(mu=32.444, sigma=5.123)
>>> a2
Rating(mu=32.444, sigma=5.123)
>>> b1 = Rating(43.381, 2.421)
>>> b1
Rating(mu=43.381, sigma=2.421)
>>> b2 = Rating(mu=25.188, sigma=6.211)
>>> b2
Rating(mu=25.188, sigma=6.211)
Enter fullscreen mode Exit fullscreen mode

If a1 and a2 are on a team, and wins against a team of b1 and b2, send this into rate:

>>> [[x1, x2], [y1, y2]] = rate([[a1, a2], [b1, b2]])
>>> x1, x2, y1, y2
([28.669648436582808, 8.071520788025197], [33.83086971107981, 5.062772998705765], [43.071274808241974, 2.4166900452721256], [23.149503312339064, 6.1378606973362135])
Enter fullscreen mode Exit fullscreen mode

You can also create Rating objects by importing create_rating:

>>> from openskill import create_rating
>>> x1 = create_rating(x1)
>>> x1
Rating(mu=28.669648436582808, sigma=8.071520788025197)
Enter fullscreen mode Exit fullscreen mode

Ranks

When displaying a rating, or sorting a list of ratings, you can use ordinal:

>>> from openskill import ordinal
>>> ordinal(mu=43.07, sigma=2.42)
35.81
Enter fullscreen mode Exit fullscreen mode

Source: https://github.com/OpenDebates/openskill.py

Top comments (0)

DEV has this feature:

Settings

Go to your customization settings to nudge your home feed to show content more relevant to your developer experience level. πŸ›