This is a data collector script based on RiotWatcher to build a dataset containing specific data about each participant of a match. Those data are meant to feed an ML implementation to try to predict the outcome of a match starting from those data.
The data is retrieved directly from Riot APIs using RiotWatcher, a really useful wrapper written in Python that implements a naive rate limiter, which is needed since the free API Key that Riot provides is limited to 20 requests per 1 minute and 100 requests per 2 minutes (source). All data is therefore of public domain and so it can be accessed by anyone.
The features of each player of a match are retrieved by the method of the class Player called “get_useful_infos_from_match_history”. These are data collected from a number of matches that are set on settings.py that happened before the analyzed match in the same queue:
- number of games won by the player
- number of games lost by the player
- average maximum bounty level
- average gold per second
- average kill participation
- average ratio of time spent living throughout the match
The choice of the features was dictated by the need for them to be as less influenced as possible by the specific position. Features like the damage score and the ally healing are certainly indicative of the performance of a player but depend too much on factors like the champion and the role of the player in the team.
Python Dotenv Library is needed to load the environment variables (in this case the API key).
RiotWatcher is needed to do the API calls.
pip install -r requirements.txt
To being able to use this script you must get an API key from Riot Games. To use it you need to put it in a file called ".env" on the script folder this way:
API_KEY="RGAPI-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"
To build the .json dataset you need to run the function "build_dataset()". If you want to build a players list beforehand, run the function "build_players_list()" and set the argument "use_players_list" to True.
To export the data inside the .json database use the function "export_dataset()".
The .csv file won't have an header. Each row contains all the data about one or both teams, the last element being the result.
If each row contains data about both teams, the data about the blue team is on the first half. The result is 1 if the blue team won, 0 if not.
If each row contains data about a single team, the odd rows will contain the data about the blue team, the even rows will contain the data about the red team of each match (i.e.: same match, row 1 blue team data, row 2 red team data).
This project isn't endorsed by Riot Games and doesn't reflect the views or 38 opinions of Riot Games or anyone officially involved in producing or 39 managing League of Legends. League of Legends and Riot Games are 40 trademarks or registered trademarks of Riot Games, Inc. League of Legends 41 © Riot Games, Inc.