Skip to main content

Role ML

PyPi Build Status codecov Language grade: Python Downloads Code style: black


League of Legends Role Classifier

This project aims to provide to Riot Games API users, especially those using match data, a better classifier for role. It is known that the internal role classifier give a lot of misclassifications, making the whole thing not enough reliable for any production application.

Based on that observation, we used machine learning to create a classifier closer to what user would expect as roles, and with an improved accuracy. In order to get solid bases and verify the ability of our classifier, we build a set of manually labeled roles as a verification set. From this verification set, the Riot Games classifier gives a 12.5% error rate and our classifier downed this error rate to less than 0.1%, on really edge cases.

For more details about the development of the classifier, check https://github.com/Canisback/roleML/blob/master/exploration/Role%20ML.ipynb

To get the verification set raw data, get it here : https://github.com/Canisback/roleML/blob/master/data/verification_results.csv (column name is participantId) (all games are from EUW server).

This classifier only works for normal and ranked games on Summoner's Rift.

Note that the range of possible role as been reduced to the 5 most used roles : MIDDLE_SOLO, TOP_SOLO, JUNGLE_NONE, BOTTOM_DUO_CARRY, BOTTOM_DUO_SUPPORT.


How to use it

The classifier is available as a python module.

pip install roleml

As the classifier relies on a set of carefully picked features from the match data, you will need to give it raw data from the API :

import roleml
roleml.predict(match, timeline)

Output :

{
 1: 'mid',
 2: 'bot',
 3: 'supp',
 4: 'top',
 5: 'jungle',
 6: 'top',
 7: 'jungle',
 8: 'bot',
 9: 'supp',
 10: 'mid'
}

The output is a dictionary linking participantId to their role.

The match needs to be at least 12 minutes long, an exception will be raised else.

Options

Add the predicted role to the participant and fix the timeline data :

fixed_match, fixed_timeline = 
	roleml.fix_game(game, timeline)

You can turn off the timeline fix :

fixed_match, fixed_timeline = 
	roleml.fix_game(game, timeline, False)

You can also change the role format output :

roleml.change_role_formatting("full")
  • clean (default)
{
 1: 'mid',
 2: 'bot',
 3: 'supp',
 4: 'top',
 5: 'jungle',
 6: 'top',
 7: 'jungle',
 8: 'bot',
 9: 'supp',
 10: 'mid'
}
  • full
{
 1: 'MIDDLE_SOLO',
 2: 'BOTTOM_DUO_CARRY',
 3: 'BOTTOM_DUO_SUPPORT',
 4: 'TOP_SOLO',
 5: 'JUNGLE_NONE',
 6: 'TOP_SOLO',
 7: 'JUNGLE_NONE',
 8: 'BOTTOM_DUO_CARRY',
 9: 'BOTTOM_DUO_SUPPORT',
 10: 'MIDDLE_SOLO'
}
  • rgapi
{
 1: {"lane":"MIDDLE","role":"SOLO"},
 2: {"lane":"BOTTOM","role":"DUO_CARRY"},
 3: {"lane":"BOTTOM","role":"DUO_SUPPORT"},
 4: {"lane":"TOP","role":"SOLO"},
 5: {"lane":"JUNGLE","role":"NONE"},
 6: {"lane":"TOP","role":"SOLO"},
 7: {"lane":"JUNGLE","role":"NONE"},
 8: {"lane":"BOTTOM","role":"DUO_CARRY"},
 9: {"lane":"BOTTOM","role":"DUO_SUPPORT"},
 10: {"lane":"MIDDLE","role":"SOLO"}
}

Cassiopeia support

RoleML partially supports Cassiopeia Match data structure. The predict function has a cassiopeia_dicts flag to be used with the Cassiopeia match .to_dict() function :

roleml.predict(match.to_dict(), match.timeline.to_dict(), True)

A special function allows to add the predicited role in Participants object from Cassiopeia matches :

roleml.add_cass_predicted_roles(match)

Working example :

import roleml
import cassiopeia as cass

cass.set_riot_api_key("RGAPI-")
cass.set_default_region("EUW")

summoner = cass.get_summoner(name="Canisback")
match = cass.MatchHistory(summoner=summoner, queues={cass.Queue.blind_fives})[0].load()
match.timeline.load()

roleml.add_cass_predicted_roles(match)
for p in match.participants:
    print(p.predicted_role)

Output :

bot
jungle
mid
top
supp
bot
mid
supp
jungle
top

Metadata

Release files for roleml 0.2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for roleml 0.2.3
File Size Uploaded Provenance
roleml-0.2.3.tar.gz 4.2 MB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for roleml 0.2.3
File Interpreter ABI Platform
roleml-0.2.3-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 8.7 MB

Release files / roleml-0.2.3.tar.gz

Download URL roleml-0.2.3.tar.gz
Size 4.2 MB
Tags Source
SHA-256 checksum
How to use checksums
1b5281acf4a98d3bc7afb349acf777f5753e59d4fc69f1622e4ce366b4c63af1
BLAKE2b-256 checksum
How to use checksums
9debf70b5f6c388daba7080c8fc0498f888e9dc1655fa784ee6a367c5c419248
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.7

Release files / roleml-0.2.3-py2.py3-none-any.whl

Download URL roleml-0.2.3-py2.py3-none-any.whl
Size 4.5 MB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
4c8306c50f6563ff0a3ccdc831548b3231d3ba41758251ecd0df82ae51eaff83
BLAKE2b-256 checksum
How to use checksums
151143b44383a891bc6cce11e5d668e14c0c714e25a5d6ae1ef5a9569da1098e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.7

Security for roleml 0.2.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page