The tensorboard extension is already loaded. To reload it, use:
%reload_ext tensorboard
LoL Prediction S10 š¹
LOL s10 high elo ranked games prediction.
Introduction
Letās predict who won the match given team composition and how long game played out
Get dataset
The dataset is a collection of League of Legends High Elo(Challenger, GM, Master, High Diamonds) Ranked games in Season 10, Korea(WWW), North America(NA), Eastern Europe(EUNE), and Western Europe(EUW) servers. These datas were collected from op.gg by web scrapping with python spyder. The latest game was played on Oct.16th on the dataset. In total there are 4028 unique games. Note that Iāve used one-hot encoding hence [99,54,101,73,57,96,52,102,68,52] this list represents number of all unique champions used in each lanes [BlueTop, BlueJG, BlueMid, BlueAdc, BlueSup, RedTop, RedJg, RedMid, RedAdc, RedSup] respectivley. Note that there are in total 151 unique champions with āSamiraā as the latest addition.
Some Setups
game_length | mmr | result | server | team_1 | team_2 | timestamp | |
---|---|---|---|---|---|---|---|
0 | 25m 38s | NaN | Victory | na | Riven,Nidalee,Galio,Jhin,Pantheon | Camille,Olaf,Cassiopeia,Ezreal,Alistar | 2020-10-13 09:31:42 |
1 | 25m 38s | NaN | Defeat | na | Teemo,Nidalee,Lucian,Caitlyn,Senna | Irelia,Hecarim,Cassiopeia,Jinx,Lulu | 2020-10-13 06:00:17 |
2 | 25m 38s | NaN | Defeat | na | Malphite,Olaf,Taliyah,Ezreal,Alistar | Sylas,Lillia,Lucian,Senna,Pantheon | 2020-10-13 05:06:45 |
3 | 25m 38s | NaN | Defeat | na | Neeko,Shen,Orianna,Kai'Sa,Nautilus | Riven,Hecarim,Cassiopeia,Samira,Morgana | 2020-10-13 04:28:00 |
4 | 25m 38s | NaN | Defeat | na | Fiora,Nunu & Willump,Irelia,Jhin,Karma | Renekton,Elise,Kled,Jinx,Morgana | 2020-10-13 04:00:51 |
game_length | result | top1 | jg1 | mid1 | adc1 | sup1 | top2 | jg2 | mid2 | adc2 | sup2 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 25m 38s | Victory | Riven | Nidalee | Galio | Jhin | Pantheon | Camille | Olaf | Cassiopeia | Ezreal | Alistar |
1 | 25m 38s | Defeat | Teemo | Nidalee | Lucian | Caitlyn | Senna | Irelia | Hecarim | Cassiopeia | Jinx | Lulu |
2 | 25m 38s | Defeat | Malphite | Olaf | Taliyah | Ezreal | Alistar | Sylas | Lillia | Lucian | Senna | Pantheon |
3 | 25m 38s | Defeat | Neeko | Shen | Orianna | Kai'Sa | Nautilus | Riven | Hecarim | Cassiopeia | Samira | Morgana |
4 | 25m 38s | Defeat | Fiora | Nunu & Willump | Irelia | Jhin | Karma | Renekton | Elise | Kled | Jinx | Morgana |
5 | 25m 38s | Defeat | Irelia | Karthus | Sylas | Samira | Nautilus | Riven | Kayn | Akali | Miss Fortune | Galio |
6 | 25m 38s | Defeat | Galio | Kindred | Syndra | Ezreal | Blitzcrank | Camille | Fiddlesticks | Twisted Fate | Jhin | Morgana |
7 | 25m 38s | Defeat | Poppy | Ekko | Sylas | Samira | Blitzcrank | Lucian | Lillia | Lulu | Caitlyn | Alistar |
8 | 25m 38s | Defeat | Shen | Lillia | Samira | Lucian | Soraka | Taric | Master Yi | Riven | Ezreal | Lulu |
9 | 25m 38s | Defeat | Ornn | Graves | Sylas | Lucian | Alistar | Irelia | Hecarim | Akali | Senna | Leona |
{'categories': 'auto',
'drop': None,
'dtype': numpy.float64,
'handle_unknown': 'error',
'sparse': True}
(4028, 754)
(4028,)
Datas are one hot encoded and cleaned up. Letās train test split
(2577,)
(2577, 755)
Letās try Neural Network with dropouts
Model: "sequential"
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
flatten (Flatten) (None, 755) 0
_________________________________________________________________
layer_1 (Dense) (None, 30) 22680
_________________________________________________________________
dropout (Dropout) (None, 30) 0
_________________________________________________________________
layer_2 (Dense) (None, 16) 496
_________________________________________________________________
dropout_1 (Dropout) (None, 16) 0
_________________________________________________________________
layer_3 (Dense) (None, 16) 272
_________________________________________________________________
dropout_2 (Dropout) (None, 16) 0
_________________________________________________________________
layer_4 (Dense) (None, 1) 17
=================================================================
Total params: 23,465
Trainable params: 23,465
Non-trainable params: 0
_________________________________________________________________
26/26 [==============================] - 0s 806us/step - loss: 3.8032 - accuracy: 0.6613
accuracy 0.6612903475761414
We got about 0.661 accuracy with just raw neural network with dropouts.
Letās try random forests
RandomForestClassifier(max_leaf_nodes=32, n_estimators=2000, n_jobs=-1)
validation accuracy: 0.7710516103996896
test accuracy: 0.7704714640198511
Immediate improvement by almost 10% with random forest classifier!
Model Explanability
Letās look at what we were mostly interested. What are some best team compositions!
Letās try SHAP summary
- We see that feature 0 (game length) tells us that the game favors blue team winning more when game is shorter which is unexpected. Note that it it not significant at all since SHAP value is -0.02 ~ 0.4 at most.
- Generally, since all the values are 0 are 1, we can see clear 1-red and 0-blue (When itās 0 it has no impact on the prediction)
- We can see feature 156(blue Mid Akali) helped RED team win more
- Whereas Feature 462(red Top Tryndamere) helps the BLUE team win significantly more haha
- From this chart, we can clearly see that each champion has very consistent and predictable contribution to their teamās chance of winning
Note that - 119 Kindred blue jg - 638 Caitlyn red adc - 60 Renekton blue top - 162 Cassiopeia blue mid - 535 Akali red mid - 376 Thresh blue support - 471 Volibear red top - 31 Jax blue top - 654 Kalista red adc - 290 Miss Fortune blue adc - 259 Ashe blue adc - 360 Rakan blue support - 210 Orianna blue mid - 462 Tryndamere red top - 445 Riven red top - 425 Lucian red top - 715 Janna red support - 156 Akali blue mid - 72 Sylas blue top
Therefore our best teamp comp impacting positively on winning is ⦠- (Top)Renekton/Jax/Sylas (Jg)Kindred (Mid) Cassiopeia/Orianna (Adc)MF/Ashe (Sup)Thresh/Rakan
Meanwhile worst team comp impacting negatively on winning is ⦠- (Top)Volibear/Trynd/Riven/Lucian (Mid)Akali (Adc)Caitlyn/Kalista (Sup)Janna
We can also note that Jg role seem to not matter much.. : )
What if we didnāt have game length, just champion compositions only?
(2577,)
(2577, 754)
RandomForestClassifier(max_leaf_nodes=32, n_estimators=2000, n_jobs=-1)
validation accuracy: 0.7691113698098564
test accuracy: 0.7692307692307693
Surprisingly, accuracy only drops less than 0.01. We can conclude that planning out a team comp based on championās strength on early vs late game does not help win more. This can be explained by an example. Letās say I picked kayle which is the best late game champion. We may win games with longer duration more but will lose more short games due to her weakness early. So the overall win rate balances out.
Conclusion
- best: (Top)Renekton/Jax/Sylas (Jg)Kindred (Mid) Cassiopeia/Orianna (Adc)MF/Ashe (Sup)Thresh/Rakan
- worst: (Top)Volibear/Trynd/Riven/Lucian (Mid)Akali (Adc)Caitlyn/Kalista (Sup)Janna
We know that in the world of solo queue, picking the above champions will not gurantee a win. Sometimes people are autofilled, meaning they arenāt playing on their best role. People may disconnect, resulting in games favoring the opposite team. There are too many unknown factors like this, making it impossible to predict 100% of the game outcomes correctly.
As a former high elo NA player myself, I can say that generally, the ābest teamā above have champions that doesnāt get countered too often and is a good pick into anything. (This may not be the case for top because Iāve never really cared about top lanes as a support player :). But for āworst teamā champions, they are often easily countered. (Especially bottom lane)
The biggest surprise was blue team wins more early and red team wins more late (Very slightly but certainly) for some reason. Also jg mattering the least was a surprise as well.