Predicting the Chance of Winning a Game of League of Legends based on Champion Select

Introduction

The traditional game of League of Legends takes place on a map known as Summoner’s Rift, where there are three major lanes as well as a jungle comprised of monsters. There are two teams, blue team and red team, who’s bases exist on opposite sides of the non-symmetrical map. Minions run through each lane from both sides and the eventual goal of the game is to take down most of the towers of the enemy team and destroy the nest of their base, the “nexus.” However, there is a much simpler gamemode in league that many casual players really enjoy, known as ARAM; it instead takes place on a map that consists of only one lane, basically the mid lane of summoner’s rift. Both teams consisting of five random players are given random champions, and this is why the gamemode is called ARAM (all random, and all mid). Within this project, I will try and predict which side has a greater chance of winning a game of ARAM based on team composition. I’ll be training a model that will take into account not only thousands of past ARAM games, but also the current ARAM win rates of champions in patch 11.

To get access to the Riot Games API and replicate or add on to this tutorial, you have to first navigate to https://developer.riotgames.com/ and sign in with a Riot Games account. You will then have to fill out an application and should automatically get access to a development API key shortly afterwards.

Initially, I signed up for the Riot Games API as a college developer, and got my own unique API key to utilize. Thus, I was able to use the adapted cassiopeia python library of riot's league API to extract data.

We then utilize a CountVectorizer to convert a list of champion names in champion select into a sparse vector where each element indicates whether the corresponding champion is present in the game. A positive value signifies that the champion is on blue team and a negative value that the champion is on red team.

Pull thousands of matches

We utilize get requests to retrieve the match history of a certain starter summoner by name, and for each ARAM match within this match history, we run another get request using the riot API to gather more specifics about this match through its match ID. We then repeat this process with extended summoners/players (as we have access to 9 other players within each match), until we eventually hit the number of matches we desire in our dataset for training (5000 in our case). Please take a look at https://github.com/meraki-analytics/cassiopeia/tree/master/examples and https://cassiopeia.readthedocs.io/en/latest/ to understand more about how the Riot Games API functions; it's quite neat!

Now that we have a list of all the match ID's we wanted, we start our training process. We iterate through all the matches, figure out what champions were on blue and red side during that match, and pass in the resultant target variable that shows which team won. We create a pandas dataframe with all this information and store it as a pickle file for later use.

After training the model on thousands of ARAM games in addition to the provided winrates of champions (the individual weights of each champion will be tuned from the initial winrate as we analyze games, as winrate is definitely not everything and can be very misleading), we will then test the accuracy of this model by running it back on the provided dataset of sample ARAM games. The beauty of league of legends is that each game feels pretty random; although team composition (champions chosen in the pre-game lobby) do make a big difference in the end result, there's so much that could potentially occur that even if one comp is much stronger than the other, most games are close to being coinflips. Thus, I don't expect this algorithm to be very accurate but any accuracy above 55% is honestly still impressive.

Furthermore, after the model was fully trained, I analyzed mirror matchups on both sides with the algorithm and found that blue side typically had a higher expected chance of winning compared to red side. This does make sense as the map is not symmetrical, meaning that vision and controls happen to be slightly more beneficial to blue side. Thus, I modified the algorithm by adding a slight fixed boost to blue side's chance of winning.

As for the algorithms I utilized to train this model, I chose logistic regression, ridge regression, a SVM, and a decision tree. Since the dependent variable is binary (either blue team won or not), I decided that it was best to use logistic regression for the further analysis, but I still checked the accuracy of the other models. If you wish to learn more about how logistic regression works, please take a look at this link: https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html

As we can see above, due to the really random nature of League games, our accuracy was pretty low for all models. Furthermore, we only predicted based on champion select, so there are so many features we didn't account for, such as player rank, runes, and builds. As for champion rankings, we see that the adjusted score seems to be generally pretty stable across the board, although there are definitely some champions with greater chances of winning than others.

As we can see, when the champions on both sides are mirrored, the blue team seems to have a slightly higher chance of winning, which leads us to believe that there is an inherent bias towards blue side.

As for future improvements to this project, I could potentially make a win predictor for Summoner’s Rift one day. It would be a lot more complicated and less accurate as there are not only many more factors (such as objectives, dragons, and ganking) but also a lot of skewed lane matchups, meaning we have to consider team synergy as well as counter champions. It would also be cool to analyze everyone’s ranks on both teams to make the prediction even more accurate. I’m currently a diamond adc main (draven one trick) and really enjoy playing ranked summoner’s rift, so I might look into doing so in the future.

Thank you so much for taking the time to read this and I hope you found it interesting!