Skip to content

codexponent/dota2-draft-analysis

Repository files navigation

Draft Analysis of Dota 2


# # Importing Packages
import os
import copy
import config
import dota2api
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import LabelEncoder
from sklearn.naive_bayes import MultinomialNB

%matplotlib inline
# # STEAM Client API Key to access the dota2 api
API_KEY = config.STEAM_API_KEY
api = dota2api.Initialise(API_KEY)
data = pd.read_csv('../data/draft/capmodedata.csv')
data.head(5)
<style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; }
.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}
</style>
match_id radiant_win duration 1is_pick 1team_id 1hero_id 2is_pick 2team_id 2hero_id 3is_pick ... 17hero_id 18is_pick 18team_id 18hero_id 19is_pick 19team_id 19hero_id 20is_pick 20team_id 20hero_id
0 1928898739 True 2885 False 0 73 False 1 69 False ... 41.0 False 0.0 81.0 True 1.0 105.0 True 0.0 94.0
1 1928932285 True 1894 False 0 69 False 1 102 False ... 40.0 False 0.0 28.0 True 1.0 97.0 True 0.0 62.0
2 1928903165 True 2424 False 1 85 False 0 68 False ... 30.0 False 1.0 47.0 True 0.0 58.0 True 1.0 33.0
3 1928907204 True 2588 False 1 71 False 0 73 False ... 30.0 False 1.0 68.0 True 0.0 50.0 True 1.0 21.0
4 1928865084 True 3658 False 1 12 False 0 42 False ... 93.0 False 1.0 67.0 True 0.0 72.0 True 1.0 40.0

5 rows ร— 63 columns

data.columns
Index(['match_id', 'radiant_win', 'duration', '1is_pick', '1team_id',
       '1hero_id', '2is_pick', '2team_id', '2hero_id', '3is_pick', '3team_id',
       '3hero_id', '4is_pick', '4team_id', '4hero_id', '5is_pick', '5team_id',
       '5hero_id', '6is_pick', '6team_id', '6hero_id', '7is_pick', '7team_id',
       '7hero_id', '8is_pick', '8team_id', '8hero_id', '9is_pick', '9team_id',
       '9hero_id', '10is_pick', '10team_id', '10hero_id', '11is_pick',
       '11team_id', '11hero_id', '12is_pick', '12team_id', '12hero_id',
       '13is_pick', '13team_id', '13hero_id', '14is_pick', '14team_id',
       '14hero_id', '15is_pick', '15team_id', '15hero_id', '16is_pick',
       '16team_id', '16hero_id', '17is_pick', '17team_id', '17hero_id',
       '18is_pick', '18team_id', '18hero_id', '19is_pick', '19team_id',
       '19hero_id', '20is_pick', '20team_id', '20hero_id'],
      dtype='object')
# # # Getting Heroes ID according to the name
heroes = api.get_heroes()
heroes_dict = {}
for i in range (len(heroes['heroes'])):
    hero_id = heroes['heroes'][i]['id']
    hero_name = heroes['heroes'][i]['localized_name']
    heroes_dict[hero_id]= hero_name
def change_hero_name(row):
    if row in heroes_dict:
        return heroes_dict[row]
    
columns = [
    '1hero_id', 
    '2hero_id', 
    '3hero_id', 
    '4hero_id', 
    '5hero_id', 
    '6hero_id', 
    '7hero_id', 
    '8hero_id', 
    '9hero_id',
    '10hero_id',
    '11hero_id', 
    '12hero_id', 
    '13hero_id', 
    '14hero_id', 
    '15hero_id', 
    '16hero_id', 
    '17hero_id', 
    '18hero_id', 
    '19hero_id',
    '20hero_id'
    ]
    
for i in range(len(columns)):
    data[columns[i]] = data[columns[i]].apply(change_hero_name)
data.head(5)
<style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; }
.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}
</style>
match_id radiant_win duration 1is_pick 1team_id 1hero_id 2is_pick 2team_id 2hero_id 3is_pick ... 17hero_id 18is_pick 18team_id 18hero_id 19is_pick 19team_id 19hero_id 20is_pick 20team_id 20hero_id
0 1928898739 True 2885 False 0 Alchemist False 1 Doom False ... Faceless Void False 0.0 Chaos Knight True 1.0 Techies True 0.0 Medusa
1 1928932285 True 1894 False 0 Doom False 1 Abaddon False ... Venomancer False 0.0 Slardar True 1.0 Magnus True 0.0 Bounty Hunter
2 1928903165 True 2424 False 1 Undying False 0 Ancient Apparition False ... Witch Doctor False 1.0 Viper True 0.0 Enchantress True 1.0 Enigma
3 1928907204 True 2588 False 1 Spirit Breaker False 0 Alchemist False ... Witch Doctor False 1.0 Ancient Apparition True 0.0 Dazzle True 1.0 Windranger
4 1928865084 True 3658 False 1 Phantom Lancer False 0 Wraith King False ... Slark False 1.0 Spectre True 0.0 Gyrocopter True 1.0 Venomancer

5 rows ร— 63 columns

Getting the longest match from the dataset (in minutes)

max_minutes = (np.max(data['duration'])) / 60
max_minutes
161.26666666666668
# # Plotting the graph of match played in minutes
data['minutes'] = data['duration'].apply(lambda x: x / 60)
groupby_minute = data.groupby(['minutes']).count()
groupby_minute.index
Float64Index([0.03333333333333333, 0.26666666666666666, 0.36666666666666664,
               0.5166666666666667,                0.55,  0.5833333333333334,
               0.6333333333333333,                0.65,                 0.8,
               0.8166666666666667,
              ...
               127.83333333333333,              129.05,              136.35,
                           138.05,              138.35,  140.86666666666667,
               142.46666666666667,               143.2,               153.3,
               161.26666666666668],
             dtype='float64', name='minutes', length=5184)
plt.hist(groupby_minute.index, histtype='bar', color='green')
(array([819., 967., 968., 967., 949., 444.,  50.,  11.,   7.,   2.]),
 array([3.33333333e-02, 1.61566667e 01, 3.22800000e 01, 4.84033333e 01,
        6.45266667e 01, 8.06500000e 01, 9.67733333e 01, 1.12896667e 02,
        1.29020000e 02, 1.45143333e 02, 1.61266667e 02]),
 <a list of 10 Patch objects>)

png

Getting the wins on both sides (Radiant / Dire)

As there should be no bias, lets see which side of the map has the most win or is it equal?

base1 = data.loc[data['radiant_win'] == True]
len(base1)
233537
base2 = data.loc[data['radiant_win'] == False]
len(base2)
227513
# # Validation
total = len(base1)   len(base2)
print(total)
print(len(data))
461050
461050
# # Plotting the graph for both sides, it seems they are nearly equal (no bias on the sides here)
temp_a = ['radiant', 'dire']
temp_b = [len(base1), len(base2)]
plt.bar(temp_a, temp_b)
<BarContainer object of 2 artists>

png

Let's Analyze the Draft

alt text

Basic Draft Rules

  • First team to get ban also gets last ban
  • First team to get ban gets first pick
  • Second team to get ban gets second and third pick consecutively
  • Second team to get ban gets last pick

Getting the first ban heroes

ban_1 = data['1hero_id']
ban1_count = data.groupby(data['1hero_id']).size()
plt.rcParams['figure.figsize'] = 22, 6
plt.xticks(rotation='vertical')
plt.grid()
plt.plot(ban1_count.index, ban1_count.values)
[<matplotlib.lines.Line2D at 0x7f630a86b7b8>]

png

From this figure, we can say that the most banned heroes on the first ban phase from a certain team is Silencer, Undying and Doom.

Getting the second ban heroes

ban2_count = data.groupby(data['2hero_id']).size()
plt.rcParams['figure.figsize'] = 20, 6
plt.xticks(rotation='vertical')
plt.grid()
plt.plot(ban2_count.index, ban2_count.values)
[<matplotlib.lines.Line2D at 0x7f630a709e48>]

png

The second ban phase also shows that Silencer, Undying and Doom are the most banned heroes, same as that of first ban phase

Getting the third ban heroes

ban3_count = data.groupby(data['3hero_id']).size()
plt.rcParams['figure.figsize'] = 20, 6
plt.xticks(rotation='vertical')
plt.grid()
plt.plot(ban3_count.index, ban3_count.values)
[<matplotlib.lines.Line2D at 0x7f6309da1518>]

png

The third ban phase has a different pattern which shows a rise of Antimage, Bloodseeker, Doom, Earthshaker, Ogre Magi, Phantom Lancer, Spirit Breaker, Strom Spirit and Winter Wyvern, a total of 9 new heroes on ban

Getting the fourth ban heroes

ban4_count = data.groupby(data['4hero_id']).size()
plt.rcParams['figure.figsize'] = 20, 6
plt.xticks(rotation='vertical')
plt.grid()
plt.plot(ban4_count.index, ban4_count.values)
[<matplotlib.lines.Line2D at 0x7f6304f7a630>]

png

The fourth ban phase shows similar pattern to the third ban phase with a exclusion of 2 heroes, Queen of Pain and Riki trying to come on top

Getting bans from all phases (1, 2, 3, 4, 9, 10, 11, 12, 17, 18)

heroes_list = []
for i, j in enumerate(heroes_dict):
    hero_name = heroes_dict[j]
    heroes_list.append(hero_name)
total_ban = 10
columns = ['1hero_id', '2hero_id', '3hero_id', '4hero_id', '9hero_id', '10hero_id', '11hero_id', '12hero_id', '17hero_id', '18hero_id']
all_data = pd.DataFrame(columns=columns, index=heroes_list)
# # Sorting alphabetically
all_data.sort_index()
<style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; }
.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}
</style>
1hero_id 2hero_id 3hero_id 4hero_id 9hero_id 10hero_id 11hero_id 12hero_id 17hero_id 18hero_id
Abaddon NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Alchemist NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Ancient Apparition NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Anti-Mage NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Arc Warden NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Axe NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Bane NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Batrider NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Beastmaster NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Bloodseeker NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Bounty Hunter NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Brewmaster NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Bristleback NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Broodmother NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Centaur Warrunner NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Chaos Knight NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Chen NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Clinkz NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Clockwerk NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Crystal Maiden NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Dark Seer NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Dark Willow NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Dazzle NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Death Prophet NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Disruptor NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Doom NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Dragon Knight NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Drow Ranger NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Earth Spirit NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Earthshaker NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
... ... ... ... ... ... ... ... ... ... ...
Slark NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Sniper NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Spectre NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Spirit Breaker NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Storm Spirit NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Sven NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Techies NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Templar Assassin NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Terrorblade NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Tidehunter NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Timbersaw NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Tinker NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Tiny NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Treant Protector NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Troll Warlord NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Tusk NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Underlord NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Undying NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Ursa NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Vengeful Spirit NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Venomancer NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Viper NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Visage NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Warlock NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Weaver NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Windranger NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Winter Wyvern NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Witch Doctor NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Wraith King NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Zeus NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN

116 rows ร— 10 columns

for i in range(total_ban):
    all_data[columns[i]] = data.groupby(data[columns[i]]).size()
all_data
<style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; }
.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}
</style>
1hero_id 2hero_id 3hero_id 4hero_id 9hero_id 10hero_id 11hero_id 12hero_id 17hero_id 18hero_id
Anti-Mage 10887.0 12392.0 16132.0 16880.0 28283.0 27217.0 25382.0 24606.0 18704.0 18923.0
Axe 2514.0 2809.0 3633.0 3745.0 9055.0 8164.0 6385.0 6429.0 5153.0 4957.0
Bane 369.0 361.0 602.0 596.0 752.0 807.0 755.0 751.0 993.0 924.0
Bloodseeker 20065.0 18299.0 15876.0 15072.0 14602.0 12813.0 11326.0 10766.0 7805.0 7472.0
Crystal Maiden 1033.0 1342.0 1965.0 2241.0 2643.0 2644.0 2702.0 2653.0 3519.0 3228.0
Drow Ranger 219.0 251.0 391.0 441.0 1571.0 1540.0 1343.0 1371.0 2249.0 2495.0
Earthshaker 17621.0 18024.0 20185.0 19430.0 12875.0 11931.0 9991.0 9342.0 6693.0 6487.0
Juggernaut 855.0 1028.0 1500.0 1744.0 4520.0 4700.0 5674.0 6254.0 7671.0 7803.0
Mirana 354.0 369.0 520.0 488.0 1141.0 1169.0 1065.0 1046.0 1319.0 1368.0
Shadow Fiend 6470.0 6652.0 7938.0 8425.0 11640.0 11353.0 11989.0 11927.0 16700.0 17998.0
Morphling 86.0 94.0 112.0 106.0 153.0 151.0 154.0 170.0 171.0 204.0
Phantom Lancer 23214.0 26772.0 29649.0 30681.0 29445.0 29746.0 24921.0 23018.0 12802.0 14218.0
Puck 196.0 239.0 377.0 378.0 740.0 786.0 1006.0 1139.0 2272.0 2514.0
Pudge 2530.0 2518.0 2265.0 2406.0 1976.0 1898.0 1956.0 1944.0 2247.0 2497.0
Razor 435.0 437.0 612.0 572.0 1484.0 1415.0 1610.0 1647.0 2975.0 3174.0
Sand King 131.0 129.0 241.0 257.0 530.0 643.0 755.0 726.0 1029.0 962.0
Storm Spirit 8260.0 9621.0 10547.0 11679.0 8649.0 9927.0 10943.0 11175.0 13151.0 14245.0
Sven 1011.0 991.0 1656.0 1966.0 5323.0 5432.0 6030.0 6173.0 6742.0 6744.0
Tiny 560.0 595.0 880.0 891.0 2532.0 2760.0 2130.0 2130.0 2325.0 2216.0
Vengeful Spirit 86.0 94.0 135.0 153.0 544.0 489.0 518.0 480.0 690.0 597.0
Windranger 3140.0 3555.0 4818.0 4973.0 5260.0 5410.0 6861.0 6988.0 8411.0 8450.0
Zeus 2256.0 2836.0 3890.0 4107.0 5688.0 5814.0 5999.0 6171.0 8699.0 8749.0
Kunkka 85.0 81.0 93.0 111.0 291.0 285.0 307.0 340.0 438.0 437.0
Lina 2760.0 3056.0 4048.0 4202.0 4622.0 4912.0 5738.0 5919.0 7156.0 7187.0
Lich 936.0 1010.0 1734.0 1802.0 2654.0 2819.0 2623.0 2713.0 3681.0 3335.0
Lion 1268.0 1318.0 2190.0 2286.0 3289.0 3173.0 3566.0 3566.0 5563.0 5010.0
Shadow Shaman 613.0 634.0 1038.0 1176.0 1432.0 1552.0 1559.0 1572.0 1970.0 1777.0
Slardar 3424.0 3872.0 5531.0 5802.0 6642.0 6375.0 6341.0 5884.0 5773.0 5578.0
Tidehunter 3725.0 4717.0 5406.0 5908.0 8108.0 8026.0 7739.0 7552.0 8911.0 8118.0
Witch Doctor 4167.0 5491.0 7914.0 8895.0 7374.0 7221.0 6942.0 7369.0 8627.0 7820.0
... ... ... ... ... ... ... ... ... ... ...
Nyx Assassin 236.0 258.0 407.0 423.0 840.0 873.0 926.0 926.0 1071.0 1031.0
Naga Siren 578.0 573.0 794.0 841.0 1185.0 1247.0 1345.0 1433.0 1099.0 1149.0
Keeper of the Light 128.0 152.0 271.0 226.0 336.0 360.0 315.0 364.0 376.0 328.0
Io 2267.0 2130.0 1932.0 1861.0 1420.0 1456.0 730.0 727.0 2083.0 1572.0
Visage 103.0 109.0 108.0 82.0 161.0 183.0 83.0 122.0 248.0 194.0
Slark 2085.0 2536.0 3663.0 4017.0 5467.0 6109.0 7432.0 7881.0 7936.0 8194.0
Medusa 905.0 1239.0 1947.0 2509.0 3096.0 4026.0 5219.0 5930.0 6113.0 7121.0
Troll Warlord 427.0 488.0 751.0 783.0 1233.0 1311.0 1585.0 1705.0 2224.0 2228.0
Centaur Warrunner 129.0 134.0 223.0 236.0 678.0 785.0 889.0 901.0 2151.0 1938.0
Magnus 771.0 1075.0 1413.0 1603.0 7427.0 7055.0 6389.0 6340.0 7859.0 7037.0
Timbersaw 221.0 201.0 270.0 297.0 424.0 452.0 543.0 521.0 883.0 874.0
Bristleback 4171.0 4416.0 6131.0 6260.0 7154.0 7788.0 9052.0 8683.0 8964.0 8844.0
Tusk 9493.0 9239.0 10723.0 10392.0 4119.0 4352.0 4590.0 4636.0 3273.0 3074.0
Skywrath Mage 154.0 240.0 360.0 393.0 937.0 893.0 824.0 911.0 1183.0 969.0
Abaddon 494.0 500.0 741.0 756.0 814.0 752.0 907.0 991.0 852.0 872.0
Elder Titan 57.0 57.0 71.0 65.0 62.0 81.0 91.0 90.0 103.0 97.0
Legion Commander 1560.0 1711.0 2356.0 2538.0 3676.0 3984.0 4190.0 4492.0 3395.0 3492.0
Ember Spirit 2008.0 2191.0 3160.0 3332.0 4667.0 4826.0 5817.0 5896.0 5835.0 6070.0
Earth Spirit NaN NaN 2.0 NaN 1.0 1.0 3.0 1.0 1.0 2.0
Terrorblade NaN 2.0 2.0 1.0 2.0 NaN 4.0 4.0 8.0 3.0
Phoenix 303.0 354.0 536.0 572.0 806.0 940.0 1107.0 1165.0 1627.0 1502.0
Oracle NaN NaN NaN NaN NaN NaN 1.0 NaN NaN NaN
Techies 2398.0 2271.0 2055.0 1957.0 1200.0 1276.0 1183.0 1270.0 1234.0 1213.0
Winter Wyvern 7721.0 7507.0 10042.0 9431.0 5778.0 5866.0 5407.0 5151.0 4014.0 3542.0
Arc Warden 1.0 NaN 2.0 NaN NaN 3.0 3.0 1.0 3.0 4.0
Underlord 2.0 NaN 1.0 NaN 1.0 1.0 NaN 2.0 NaN 2.0
Monkey King NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Pangolier NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Dark Willow NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Grimstroke NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN

116 rows ร— 10 columns

# # For this context, null value is the 0 value (i.e hero is not picked on it's respective phase)
all_data.fillna(value=0)
<style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; }
.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}
</style>
1hero_id 2hero_id 3hero_id 4hero_id 9hero_id 10hero_id 11hero_id 12hero_id 17hero_id 18hero_id
Anti-Mage 10887.0 12392.0 16132.0 16880.0 28283.0 27217.0 25382.0 24606.0 18704.0 18923.0
Axe 2514.0 2809.0 3633.0 3745.0 9055.0 8164.0 6385.0 6429.0 5153.0 4957.0
Bane 369.0 361.0 602.0 596.0 752.0 807.0 755.0 751.0 993.0 924.0
Bloodseeker 20065.0 18299.0 15876.0 15072.0 14602.0 12813.0 11326.0 10766.0 7805.0 7472.0
Crystal Maiden 1033.0 1342.0 1965.0 2241.0 2643.0 2644.0 2702.0 2653.0 3519.0 3228.0
Drow Ranger 219.0 251.0 391.0 441.0 1571.0 1540.0 1343.0 1371.0 2249.0 2495.0
Earthshaker 17621.0 18024.0 20185.0 19430.0 12875.0 11931.0 9991.0 9342.0 6693.0 6487.0
Juggernaut 855.0 1028.0 1500.0 1744.0 4520.0 4700.0 5674.0 6254.0 7671.0 7803.0
Mirana 354.0 369.0 520.0 488.0 1141.0 1169.0 1065.0 1046.0 1319.0 1368.0
Shadow Fiend 6470.0 6652.0 7938.0 8425.0 11640.0 11353.0 11989.0 11927.0 16700.0 17998.0
Morphling 86.0 94.0 112.0 106.0 153.0 151.0 154.0 170.0 171.0 204.0
Phantom Lancer 23214.0 26772.0 29649.0 30681.0 29445.0 29746.0 24921.0 23018.0 12802.0 14218.0
Puck 196.0 239.0 377.0 378.0 740.0 786.0 1006.0 1139.0 2272.0 2514.0
Pudge 2530.0 2518.0 2265.0 2406.0 1976.0 1898.0 1956.0 1944.0 2247.0 2497.0
Razor 435.0 437.0 612.0 572.0 1484.0 1415.0 1610.0 1647.0 2975.0 3174.0
Sand King 131.0 129.0 241.0 257.0 530.0 643.0 755.0 726.0 1029.0 962.0
Storm Spirit 8260.0 9621.0 10547.0 11679.0 8649.0 9927.0 10943.0 11175.0 13151.0 14245.0
Sven 1011.0 991.0 1656.0 1966.0 5323.0 5432.0 6030.0 6173.0 6742.0 6744.0
Tiny 560.0 595.0 880.0 891.0 2532.0 2760.0 2130.0 2130.0 2325.0 2216.0
Vengeful Spirit 86.0 94.0 135.0 153.0 544.0 489.0 518.0 480.0 690.0 597.0
Windranger 3140.0 3555.0 4818.0 4973.0 5260.0 5410.0 6861.0 6988.0 8411.0 8450.0
Zeus 2256.0 2836.0 3890.0 4107.0 5688.0 5814.0 5999.0 6171.0 8699.0 8749.0
Kunkka 85.0 81.0 93.0 111.0 291.0 285.0 307.0 340.0 438.0 437.0
Lina 2760.0 3056.0 4048.0 4202.0 4622.0 4912.0 5738.0 5919.0 7156.0 7187.0
Lich 936.0 1010.0 1734.0 1802.0 2654.0 2819.0 2623.0 2713.0 3681.0 3335.0
Lion 1268.0 1318.0 2190.0 2286.0 3289.0 3173.0 3566.0 3566.0 5563.0 5010.0
Shadow Shaman 613.0 634.0 1038.0 1176.0 1432.0 1552.0 1559.0 1572.0 1970.0 1777.0
Slardar 3424.0 3872.0 5531.0 5802.0 6642.0 6375.0 6341.0 5884.0 5773.0 5578.0
Tidehunter 3725.0 4717.0 5406.0 5908.0 8108.0 8026.0 7739.0 7552.0 8911.0 8118.0
Witch Doctor 4167.0 5491.0 7914.0 8895.0 7374.0 7221.0 6942.0 7369.0 8627.0 7820.0
... ... ... ... ... ... ... ... ... ... ...
Nyx Assassin 236.0 258.0 407.0 423.0 840.0 873.0 926.0 926.0 1071.0 1031.0
Naga Siren 578.0 573.0 794.0 841.0 1185.0 1247.0 1345.0 1433.0 1099.0 1149.0
Keeper of the Light 128.0 152.0 271.0 226.0 336.0 360.0 315.0 364.0 376.0 328.0
Io 2267.0 2130.0 1932.0 1861.0 1420.0 1456.0 730.0 727.0 2083.0 1572.0
Visage 103.0 109.0 108.0 82.0 161.0 183.0 83.0 122.0 248.0 194.0
Slark 2085.0 2536.0 3663.0 4017.0 5467.0 6109.0 7432.0 7881.0 7936.0 8194.0
Medusa 905.0 1239.0 1947.0 2509.0 3096.0 4026.0 5219.0 5930.0 6113.0 7121.0
Troll Warlord 427.0 488.0 751.0 783.0 1233.0 1311.0 1585.0 1705.0 2224.0 2228.0
Centaur Warrunner 129.0 134.0 223.0 236.0 678.0 785.0 889.0 901.0 2151.0 1938.0
Magnus 771.0 1075.0 1413.0 1603.0 7427.0 7055.0 6389.0 6340.0 7859.0 7037.0
Timbersaw 221.0 201.0 270.0 297.0 424.0 452.0 543.0 521.0 883.0 874.0
Bristleback 4171.0 4416.0 6131.0 6260.0 7154.0 7788.0 9052.0 8683.0 8964.0 8844.0
Tusk 9493.0 9239.0 10723.0 10392.0 4119.0 4352.0 4590.0 4636.0 3273.0 3074.0
Skywrath Mage 154.0 240.0 360.0 393.0 937.0 893.0 824.0 911.0 1183.0 969.0
Abaddon 494.0 500.0 741.0 756.0 814.0 752.0 907.0 991.0 852.0 872.0
Elder Titan 57.0 57.0 71.0 65.0 62.0 81.0 91.0 90.0 103.0 97.0
Legion Commander 1560.0 1711.0 2356.0 2538.0 3676.0 3984.0 4190.0 4492.0 3395.0 3492.0
Ember Spirit 2008.0 2191.0 3160.0 3332.0 4667.0 4826.0 5817.0 5896.0 5835.0 6070.0
Earth Spirit 0.0 0.0 2.0 0.0 1.0 1.0 3.0 1.0 1.0 2.0
Terrorblade 0.0 2.0 2.0 1.0 2.0 0.0 4.0 4.0 8.0 3.0
Phoenix 303.0 354.0 536.0 572.0 806.0 940.0 1107.0 1165.0 1627.0 1502.0
Oracle 0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0
Techies 2398.0 2271.0 2055.0 1957.0 1200.0 1276.0 1183.0 1270.0 1234.0 1213.0
Winter Wyvern 7721.0 7507.0 10042.0 9431.0 5778.0 5866.0 5407.0 5151.0 4014.0 3542.0
Arc Warden 1.0 0.0 2.0 0.0 0.0 3.0 3.0 1.0 3.0 4.0
Underlord 2.0 0.0 1.0 0.0 1.0 1.0 0.0 2.0 0.0 2.0
Monkey King 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
Pangolier 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
Dark Willow 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
Grimstroke 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0

116 rows ร— 10 columns

From this above table, we can see that 4 heroes (Monkey King, Pangolier, Dark Willow and Grimstroke) have 0 bans, it's because heroes api was updated on steam client which fetched the new heroes but weren't in the old meta.
# # Grouping the heroes for plotting purpose
sum_all_data = all_data.sum(axis=1)
sum_all_data
Anti-Mage              199406.0
Axe                     52844.0
Bane                     6910.0
Bloodseeker            134096.0
Crystal Maiden          23970.0
Drow Ranger             11871.0
Earthshaker            132579.0
Juggernaut              41749.0
Mirana                   8839.0
Shadow Fiend           111092.0
Morphling                1401.0
Phantom Lancer         244466.0
Puck                     9647.0
Pudge                   22237.0
Razor                   14361.0
Sand King                5403.0
Storm Spirit           108197.0
Sven                    42068.0
Tiny                    17019.0
Vengeful Spirit          3786.0
Windranger              57866.0
Zeus                    54209.0
Kunkka                   2468.0
Lina                    49600.0
Lich                    23307.0
Lion                    31229.0
Shadow Shaman           13323.0
Slardar                 55222.0
Tidehunter              68210.0
Witch Doctor            71820.0
                         ...   
Nyx Assassin             6991.0
Naga Siren              10244.0
Keeper of the Light      2856.0
Io                      16178.0
Visage                   1393.0
Slark                   55320.0
Medusa                  38105.0
Troll Warlord           12735.0
Centaur Warrunner        8064.0
Magnus                  46969.0
Timbersaw                4686.0
Bristleback             71463.0
Tusk                    63891.0
Skywrath Mage            6864.0
Abaddon                  7679.0
Elder Titan               774.0
Legion Commander        31394.0
Ember Spirit            43802.0
Earth Spirit               11.0
Terrorblade                26.0
Phoenix                  8912.0
Oracle                      1.0
Techies                 16057.0
Winter Wyvern           64459.0
Arc Warden                 17.0
Underlord                   9.0
Monkey King                 0.0
Pangolier                   0.0
Dark Willow                 0.0
Grimstroke                  0.0
Length: 116, dtype: float64
# # Plotting all the ban values
plt.grid()
plt.plot(sum_all_data.index, sum_all_data.values)
plt.xticks(rotation='vertical')
plt.yticks(np.arange(0, 350000, 50000))
([<matplotlib.axis.YTick at 0x7f6304e4e5f8>,
  <matplotlib.axis.YTick at 0x7f6304e4e1d0>,
  <matplotlib.axis.YTick at 0x7f6304e5f278>,
  <matplotlib.axis.YTick at 0x7f6304cefda0>,
  <matplotlib.axis.YTick at 0x7f6304cf7320>,
  <matplotlib.axis.YTick at 0x7f6304cf7860>,
  <matplotlib.axis.YTick at 0x7f6304cf7da0>],
 <a list of 7 Text yticklabel objects>)

png

The above graphs shows the most banned heroes from all the 10 ban phases where most of them shows good distribution except 3 heroes (Phantom Lancer, Silencer and Undying)

Similarly, Getting the first pick heroes

pick1_count = data.groupby(data['5hero_id']).size()
plt.rcParams['figure.figsize'] = 20, 6
plt.xticks(rotation='vertical')
plt.grid()
plt.plot(pick1_count.index, pick1_count.values)
[<matplotlib.lines.Line2D at 0x7f6304c41860>]

png

This figure shows that picks are not as bad as ban as there are many option of heroes here to pick. These heroes include Crystal Maiden, Dazzzle, Earthshaker, Undying and Witch Doctor. This also shows that Undying is on both graphs (Pick and Ban) which means that Undying Hero was really popular in the meta

Getting the second picked heroes

pick2_count = data.groupby(data['6hero_id']).size()
plt.rcParams['figure.figsize'] = 20, 6
plt.xticks(rotation='vertical')
plt.grid()
plt.plot(pick2_count.index, pick2_count.values)
[<matplotlib.lines.Line2D at 0x7f6304acd710>]

png

Similar to the above graph but with the exception of heroes like Lion an Omniknight.

Getting the third pick heroes

pick3_count = data.groupby(data['7hero_id']).size()
plt.rcParams['figure.figsize'] = 20, 6
plt.xticks(rotation='vertical')
plt.grid()
plt.plot(pick3_count.index, pick3_count.values)
[<matplotlib.lines.Line2D at 0x7f630495b438>]

png

As the six and seven pick always belong to the same team, we can conclude that the heroes of this graph and above can be paired on game. Heros like Crystal Maiden, Dazzle, Disruptor, Earthshaker, Lina, Lion, Ogre Magi, Omniknight, Shadow Sharman, Tush, Undying and Witch Doctor

Getting graph for the most pick

total_pick = 10
columns = ['5hero_id', '6hero_id', '7hero_id', '8hero_id', '13hero_id', '14hero_id', '15hero_id', '16hero_id', '19hero_id', '20hero_id']
pick_all_data = pd.DataFrame(columns=columns, index=heroes_list)
pick_all_data
<style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; }
.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}
</style>
5hero_id 6hero_id 7hero_id 8hero_id 13hero_id 14hero_id 15hero_id 16hero_id 19hero_id 20hero_id
Anti-Mage NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Axe NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Bane NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Bloodseeker NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Crystal Maiden NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Drow Ranger NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Earthshaker NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Juggernaut NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Mirana NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Shadow Fiend NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Morphling NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Phantom Lancer NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Puck NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Pudge NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Razor NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Sand King NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Storm Spirit NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Sven NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Tiny NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Vengeful Spirit NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Windranger NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Zeus NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Kunkka NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Lina NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Lich NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Lion NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Shadow Shaman NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Slardar NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Tidehunter NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Witch Doctor NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
... ... ... ... ... ... ... ... ... ... ...
Nyx Assassin NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Naga Siren NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Keeper of the Light NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Io NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Visage NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Slark NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Medusa NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Troll Warlord NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Centaur Warrunner NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Magnus NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Timbersaw NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Bristleback NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Tusk NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Skywrath Mage NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Abaddon NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Elder Titan NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Legion Commander NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Ember Spirit NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Earth Spirit NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Terrorblade NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Phoenix NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Oracle NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Techies NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Winter Wyvern NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Arc Warden NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Underlord NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Monkey King NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Pangolier NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Dark Willow NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Grimstroke NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN

116 rows ร— 10 columns

for i in range(total_pick):
    pick_all_data[columns[i]] = data.groupby(data[columns[i]]).size()
# # As in our context, we fill Null values with 0 (i.e, not picked = 0)
pick_all_data.fillna(0)
<style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; }
.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}
</style>
5hero_id 6hero_id 7hero_id 8hero_id 13hero_id 14hero_id 15hero_id 16hero_id 19hero_id 20hero_id
Anti-Mage 1473.0 1848.0 2392.0 4153.0 7617.0 7601.0 10191.0 10878.0 8406.0 7696.0
Axe 2190.0 4781.0 5925.0 8543.0 9151.0 9182.0 6280.0 6383.0 4186.0 4300.0
Bane 2753.0 3267.0 3127.0 3087.0 1762.0 2188.0 1598.0 1557.0 1046.0 1177.0
Bloodseeker 3059.0 3238.0 3548.0 3781.0 5002.0 5159.0 5035.0 5079.0 3662.0 3765.0
Crystal Maiden 23045.0 19252.0 16526.0 12551.0 6020.0 5344.0 4148.0 3672.0 2516.0 2449.0
Drow Ranger 643.0 778.0 1266.0 1166.0 2437.0 2606.0 4318.0 4013.0 5552.0 5105.0
Earthshaker 48622.0 42908.0 27645.0 25206.0 11511.0 10859.0 6555.0 6459.0 3515.0 3744.0
Juggernaut 1513.0 1569.0 2802.0 2496.0 6426.0 6529.0 9972.0 9238.0 9286.0 8704.0
Mirana 1732.0 1758.0 2654.0 2370.0 2375.0 2216.0 2256.0 2155.0 2592.0 2480.0
Shadow Fiend 7807.0 7563.0 7064.0 5652.0 9155.0 7577.0 10826.0 9229.0 13617.0 11593.0
Morphling 183.0 200.0 267.0 238.0 475.0 498.0 808.0 789.0 1472.0 1468.0
Phantom Lancer 3531.0 2758.0 3689.0 4218.0 6122.0 5096.0 5679.0 6514.0 5509.0 5444.0
Puck 470.0 526.0 721.0 802.0 1577.0 1717.0 2378.0 2537.0 3990.0 3739.0
Pudge 2196.0 2162.0 2051.0 2189.0 2775.0 3000.0 3208.0 3330.0 6949.0 7078.0
Razor 348.0 499.0 845.0 933.0 2081.0 2669.0 4003.0 4573.0 6139.0 6688.0
Sand King 1863.0 1946.0 2984.0 2699.0 2488.0 2411.0 2095.0 2099.0 1933.0 2023.0
Storm Spirit 1900.0 1663.0 1758.0 1760.0 3311.0 3167.0 4171.0 4233.0 6145.0 5728.0
Sven 1443.0 1772.0 3189.0 3400.0 7796.0 8289.0 10552.0 10672.0 9727.0 9645.0
Tiny 1402.0 1862.0 4017.0 3192.0 4141.0 4672.0 5506.0 5706.0 5101.0 5078.0
Vengeful Spirit 4894.0 5192.0 5787.0 5422.0 3392.0 3382.0 2693.0 2532.0 1718.0 1762.0
Windranger 5793.0 6006.0 8076.0 7514.0 11751.0 11135.0 12809.0 12558.0 14455.0 14261.0
Zeus 2622.0 3085.0 4139.0 4047.0 4758.0 4901.0 5641.0 5460.0 6758.0 6708.0
Kunkka 417.0 475.0 695.0 685.0 1356.0 1341.0 1703.0 1771.0 2328.0 2644.0
Lina 7061.0 7297.0 8726.0 7886.0 6847.0 7031.0 7067.0 6938.0 7519.0 7650.0
Lich 7179.0 7635.0 8946.0 8648.0 4262.0 4547.0 3221.0 3465.0 2335.0 2656.0
Lion 17406.0 18357.0 16378.0 14377.0 7736.0 7930.0 6037.0 5931.0 3759.0 3837.0
Shadow Shaman 9134.0 9050.0 9049.0 8020.0 3924.0 3975.0 3154.0 2971.0 2234.0 2238.0
Slardar 5131.0 5519.0 5978.0 6809.0 9090.0 10425.0 9710.0 10032.0 7164.0 8078.0
Tidehunter 6377.0 7403.0 8928.0 9241.0 9859.0 9527.0 6337.0 6409.0 4216.0 4395.0
Witch Doctor 32153.0 27452.0 25251.0 19410.0 9888.0 9080.0 6628.0 6424.0 3586.0 3634.0
... ... ... ... ... ... ... ... ... ... ...
Nyx Assassin 331.0 663.0 770.0 1263.0 1671.0 1869.0 1638.0 1820.0 1631.0 1881.0
Naga Siren 901.0 1186.0 1177.0 1492.0 1314.0 1490.0 1374.0 1470.0 1713.0 1725.0
Keeper of the Light 1441.0 1630.0 1516.0 1669.0 942.0 1121.0 794.0 850.0 666.0 771.0
Io 3079.0 3695.0 2107.0 1831.0 1825.0 1914.0 1252.0 1398.0 572.0 547.0
Visage 499.0 498.0 569.0 521.0 540.0 556.0 452.0 432.0 366.0 354.0
Slark 1110.0 1107.0 1689.0 1624.0 4424.0 4476.0 7054.0 7179.0 8033.0 7768.0
Medusa 523.0 481.0 693.0 802.0 2522.0 2634.0 4182.0 5208.0 8642.0 9079.0
Troll Warlord 467.0 472.0 719.0 762.0 1587.0 1869.0 2907.0 3027.0 3751.0 3777.0
Centaur Warrunner 885.0 1032.0 2168.0 1911.0 5109.0 4925.0 3916.0 3846.0 3015.0 3038.0
Magnus 1583.0 1653.0 3138.0 2986.0 6344.0 6059.0 5794.0 5628.0 5790.0 5524.0
Timbersaw 502.0 558.0 1085.0 1059.0 2674.0 2754.0 2208.0 2216.0 1812.0 2030.0
Bristleback 3234.0 3646.0 6566.0 6320.0 14142.0 13235.0 9747.0 9399.0 5951.0 6239.0
Tusk 12848.0 10653.0 9702.0 8521.0 8499.0 7777.0 5743.0 5238.0 4005.0 4068.0
Skywrath Mage 1763.0 2561.0 2824.0 3170.0 1895.0 2161.0 1667.0 1591.0 1380.0 1444.0
Abaddon 1117.0 1517.0 1743.0 2068.0 2185.0 2493.0 2091.0 2292.0 1741.0 1895.0
Elder Titan 389.0 422.0 518.0 532.0 603.0 631.0 507.0 511.0 528.0 496.0
Legion Commander 1558.0 1726.0 2920.0 2888.0 6390.0 6678.0 7524.0 7403.0 7024.0 7089.0
Ember Spirit 1364.0 1529.0 1949.0 2129.0 4207.0 4402.0 6366.0 6636.0 8558.0 8454.0
Earth Spirit 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
Terrorblade 2.0 1.0 2.0 2.0 4.0 3.0 7.0 3.0 14.0 7.0
Phoenix 1138.0 1224.0 1865.0 2014.0 2944.0 3215.0 2607.0 2844.0 2633.0 2703.0
Oracle 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
Techies 405.0 375.0 367.0 358.0 351.0 358.0 340.0 421.0 972.0 1008.0
Winter Wyvern 17538.0 17112.0 13430.0 12805.0 5970.0 6151.0 3645.0 3857.0 2227.0 2443.0
Arc Warden 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
Underlord 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
Monkey King 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
Pangolier 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
Dark Willow 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
Grimstroke 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0

116 rows ร— 10 columns

sum_all_pick_data = pick_all_data.sum(axis=1)
sum_all_pick_data.head(2)
Anti-Mage    62255.0
Axe          60921.0
dtype: float64
plt.grid()
plt.plot(sum_all_pick_data.index, sum_all_pick_data.values)
plt.xticks(rotation='vertical')
plt.yticks(np.arange(0, 300000, 50000))
([<matplotlib.axis.YTick at 0x7f6304761438>,
  <matplotlib.axis.YTick at 0x7f6304819e48>,
  <matplotlib.axis.YTick at 0x7f63047a4b38>,
  <matplotlib.axis.YTick at 0x7f63046c6d68>,
  <matplotlib.axis.YTick at 0x7f63046c0a58>,
  <matplotlib.axis.YTick at 0x7f63047106d8>],
 <a list of 6 Text yticklabel objects>)

png

Although the ban phase was really bad distribution, the pick distribution was actually really good for the meta compared to the ban phase graph, which means that all the heroes got playtime on the game

Getting the most populat hero pairings on the basis of winrate

We can take win rates for 1st picked team. (i.e: 5, 8, 14, 16, 19)
We can take win rates for 2nd picked team. (i.e: 6, 7, 13, 15, 20)
temp = data.loc[data['1team_id'] == 0]
win1 = temp.loc[temp['radiant_win'] == True]
temp2 = data.loc[data['1team_id'] == 1]
win2 = temp2.loc[temp2['radiant_win'] == False]
to_concat_dataframes = [win1, win2]
all_win_data_only_1 = pd.concat(to_concat_dataframes)
temp = data.loc[data['1team_id'] == 0]
win1 = temp.loc[temp['radiant_win'] == False]
temp2 = data.loc[data['1team_id'] == 1]
win2 = temp2.loc[temp2['radiant_win'] == True]
to_concat_dataframes = [win1, win2]
all_win_data_only_2 = pd.concat(to_concat_dataframes)
# # Validation
print(all_win_data_only_1.shape)
print(all_win_data_only_2.shape)
print(all_win_data_only_1.shape[0]   all_win_data_only_2.shape[0])
print(data.shape[0])
(233738, 64)
(227312, 64)
461050
461050
all_win_data_only_1.sort_index()
<style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; }
.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}
</style>
match_id radiant_win duration 1is_pick 1team_id 1hero_id 2is_pick 2team_id 2hero_id 3is_pick ... 18is_pick 18team_id 18hero_id 19is_pick 19team_id 19hero_id 20is_pick 20team_id 20hero_id minutes
0 1928898739 True 2885 False 0 Alchemist False 1 Doom False ... False 0.0 Chaos Knight True 1.0 Techies True 0.0 Medusa 48.083333
1 1928932285 True 1894 False 0 Doom False 1 Abaddon False ... False 0.0 Slardar True 1.0 Magnus True 0.0 Bounty Hunter 31.566667
5 1928918721 False 2288 False 1 Silencer False 0 Undying False ... False 1.0 Weaver True 0.0 Bristleback True 1.0 Legion Commander 38.133333
7 1928896797 True 2768 False 0 Huskar False 1 Silencer False ... False 0.0 Queen of Pain True 1.0 Invoker True 0.0 Necrophos 46.133333
12 1928893986 True 2801 False 0 Silencer False 1 Omniknight False ... False 0.0 Lina True 1.0 Gyrocopter True 0.0 Riki 46.683333
13 1928901539 False 2814 False 1 Silencer False 0 Enigma False ... False 1.0 Phantom Assassin True 0.0 Pudge True 1.0 Zeus 46.950000
16 1928888035 False 2759 False 1 Tusk False 0 Phantom Lancer False ... False 1.0 Tiny True 0.0 Slark True 1.0 Clockwerk 45.983333
19 1928927985 True 1990 False 0 Silencer False 1 Tidehunter False ... False 0.0 Tusk True 1.0 Queen of Pain True 0.0 Witch Doctor 33.166667
21 1928890079 False 3048 False 1 Silencer False 0 Tidehunter False ... False 1.0 Pudge True 0.0 Windranger True 1.0 Bristleback 50.800000
22 1928935461 True 1625 False 0 Bloodseeker False 1 Alchemist False ... False 0.0 Anti-Mage True 1.0 Lifestealer True 0.0 Queen of Pain 27.083333
23 1928921906 False 2075 False 1 Slardar False 0 Tusk False ... False 1.0 Ancient Apparition True 0.0 Huskar True 1.0 Clinkz 34.583333
24 1928915628 True 2445 False 0 Silencer False 1 Ursa False ... False 0.0 Sven True 1.0 Luna True 0.0 Drow Ranger 40.750000
26 1928909378 False 2572 False 1 Bloodseeker False 0 Silencer False ... False 1.0 Phantom Lancer True 0.0 Sniper True 1.0 Queen of Pain 42.866667
27 1928914396 True 2417 False 0 Alchemist False 1 Queen of Pain False ... False 0.0 Doom True 1.0 Phantom Assassin True 0.0 Juggernaut 40.283333
30 1928898553 False 2687 False 1 Io False 0 Alchemist False ... False 1.0 Dragon Knight True 0.0 Troll Warlord True 1.0 Queen of Pain 44.783333
31 1928951637 False 1235 False 1 Slardar False 0 Doom False ... False 1.0 Witch Doctor True 0.0 Earthshaker True 1.0 Templar Assassin 20.583333
32 1928921308 True 2229 False 0 Silencer False 1 Omniknight False ... False 0.0 Ursa True 1.0 Faceless Void True 0.0 Axe 37.150000
36 1928932214 True 1807 False 0 Earthshaker False 1 Undying False ... False 0.0 Phantom Lancer True 1.0 Templar Assassin True 0.0 Juggernaut 30.116667
38 1928933341 True 2074 False 0 Undying False 1 Templar Assassin False ... False 0.0 Tidehunter True 1.0 Kunkka True 0.0 Anti-Mage 34.566667
41 1928917969 False 2162 False 1 Doom False 0 Razor False ... False 1.0 Lich True 0.0 Bristleback True 1.0 Enchantress 36.033333
42 1928921955 True 2053 False 0 Undying False 1 Phantom Lancer False ... False 0.0 Silencer True 1.0 Elder Titan True 0.0 Ember Spirit 34.216667
43 1928909735 False 2705 False 1 Alchemist False 0 Spirit Breaker False ... False 1.0 Faceless Void True 0.0 Ember Spirit True 1.0 Shadow Fiend 45.083333
46 1928948236 False 1736 False 1 Phantom Lancer False 0 Razor False ... False 1.0 Faceless Void True 0.0 Dazzle True 1.0 Bristleback 28.933333
47 1928899026 True 3118 False 0 Pudge False 1 Alchemist False ... False 0.0 Windranger True 1.0 Axe True 0.0 Gyrocopter 51.966667
48 1928900188 True 2922 False 0 Silencer False 1 Undying False ... False 0.0 Chaos Knight True 1.0 Windranger True 0.0 Spectre 48.700000
49 1928962208 True 1028 False 0 Silencer False 1 Doom False ... False 0.0 Phantom Assassin True 1.0 Anti-Mage True 0.0 Pudge 17.133333
51 1928893190 False 3308 False 1 Doom False 0 Tusk False ... False 1.0 Phantom Lancer True 0.0 Treant Protector True 1.0 Wraith King 55.133333
52 1928916542 True 2583 False 0 Tidehunter False 1 Bloodseeker False ... False 0.0 Abaddon True 1.0 Spectre True 0.0 Warlock 43.050000
53 1928921042 True 2377 False 0 Undying False 1 Doom False ... False 0.0 Phantom Lancer True 1.0 Slark True 0.0 Death Prophet 39.616667
55 1928965089 False 1037 False 1 Doom False 0 Undying False ... False 1.0 Broodmother True 0.0 Batrider True 1.0 Silencer 17.283333
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
460997 1829145682 False 2957 False 1 Undying False 0 Anti-Mage False ... False 1.0 Faceless Void True 0.0 Gyrocopter True 1.0 Wraith King 49.283333
460998 1829191221 False 2039 False 1 Bloodseeker False 0 Lifestealer False ... False 1.0 Weaver True 0.0 Brewmaster True 1.0 Tiny 33.983333
461000 1829178101 False 2252 False 1 Windranger False 0 Bane False ... False 1.0 Riki True 0.0 Queen of Pain True 1.0 Templar Assassin 37.533333
461001 1829156294 True 3013 False 0 Silencer False 1 Huskar False ... False 0.0 Gyrocopter True 1.0 Zeus True 0.0 Queen of Pain 50.216667
461002 1829193274 True 1807 False 0 Bloodseeker False 1 Sven False ... False 0.0 Storm Spirit True 1.0 Puck True 0.0 Sniper 30.116667
461005 1829120346 True 3632 False 0 Silencer False 1 Phantom Lancer False ... False 0.0 Slark True 1.0 Winter Wyvern True 0.0 Pudge 60.533333
461008 1829150986 False 3087 False 1 Slark False 0 Spirit Breaker False ... False 1.0 Bristleback True 0.0 Pudge True 1.0 Shadow Fiend 51.450000
461011 1829197240 False 2033 False 1 Bloodseeker False 0 Earthshaker False ... False 1.0 Zeus True 0.0 Anti-Mage True 1.0 Windranger 33.883333
461012 1829205428 False 1868 False 1 Undying False 0 Bloodseeker False ... False 1.0 Medusa True 0.0 Spectre True 1.0 Weaver 31.133333
461014 1829169148 False 2593 False 1 Spirit Breaker False 0 Leshrac False ... False 1.0 Slark True 0.0 Ursa True 1.0 Phantom Lancer 43.216667
461016 1829181890 True 2412 False 0 Enigma False 1 Undying False ... False 0.0 Phantom Assassin True 1.0 Chaos Knight True 0.0 Sven 40.200000
461018 1829131276 False 3432 False 1 Silencer False 0 Undying False ... False 1.0 Anti-Mage True 0.0 Juggernaut True 1.0 Night Stalker 57.200000
461019 1829151361 True 3307 False 0 Omniknight False 1 Riki False ... False 0.0 Spirit Breaker True 1.0 Undying True 0.0 Sven 55.116667
461020 1829167848 False 2724 False 1 Silencer False 0 Undying False ... False 1.0 Pugna True 0.0 Lion True 1.0 Sven 45.400000
461022 1829123884 False 3565 False 1 Winter Wyvern False 0 Lina False ... False 1.0 Anti-Mage True 0.0 Wraith King True 1.0 Phantom Assassin 59.416667
461027 1829173133 False 2714 False 1 Silencer False 0 Queen of Pain False ... False 1.0 Phantom Assassin True 0.0 Templar Assassin True 1.0 Ember Spirit 45.233333
461028 1829216259 True 1953 False 0 Omniknight False 1 Silencer False ... False 0.0 Slark True 1.0 Storm Spirit True 0.0 Queen of Pain 32.550000
461030 1829211652 True 2047 False 0 Lifestealer False 1 Anti-Mage False ... False 0.0 Necrophos True 1.0 Shadow Shaman True 0.0 Warlock 34.116667
461031 1829173426 False 2471 False 1 Phantom Lancer False 0 Shadow Fiend False ... False 1.0 Magnus True 0.0 Spirit Breaker True 1.0 Meepo 41.183333
461033 1829141533 False 3274 False 1 Silencer False 0 Phantom Assassin False ... False 1.0 Ursa True 0.0 Bounty Hunter True 1.0 Pudge 54.566667
461035 1829187976 True 2505 False 0 Chaos Knight False 1 Riki False ... False 0.0 Elder Titan True 1.0 Bristleback True 0.0 Pudge 41.750000
461036 1829157021 True 3048 False 0 Storm Spirit False 1 Undying False ... False 0.0 Ursa True 1.0 Broodmother True 0.0 Phoenix 50.800000
461037 1829212312 True 1664 False 0 Silencer False 1 Enigma False ... False 0.0 Queen of Pain True 1.0 Juggernaut True 0.0 Shadow Fiend 27.733333
461038 1829163603 True 3003 False 0 Phantom Lancer False 1 Axe False ... False 0.0 Gyrocopter True 1.0 Storm Spirit True 0.0 Lion 50.050000
461039 1829158252 False 2926 False 1 Bloodseeker False 0 Slark False ... False 1.0 Silencer True 0.0 Death Prophet True 1.0 Skywrath Mage 48.766667
461041 1829201186 True 2123 False 0 Omniknight False 1 Bloodseeker False ... False 0.0 Leshrac True 1.0 Gyrocopter True 0.0 Legion Commander 35.383333
461044 1829146665 True 3181 False 0 Dazzle False 1 Omniknight False ... False 0.0 Riki True 1.0 Juggernaut True 0.0 Anti-Mage 53.016667
461045 1829200497 False 2248 False 1 Undying False 0 Huskar False ... False 1.0 Broodmother True 0.0 Clockwerk True 1.0 Omniknight 37.466667
461046 1829177389 True 2755 False 0 Silencer False 1 Bloodseeker False ... False 0.0 Ursa True 1.0 Shadow Fiend True 0.0 Luna 45.916667
461048 1829220503 False 1609 False 1 Anti-Mage False 0 Omniknight False ... False 1.0 Lion True 0.0 Nature's Prophet True 1.0 Gyrocopter 26.816667

233738 rows ร— 64 columns

all_win_data_only_2.sort_index()
<style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; }
.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}
</style>
match_id radiant_win duration 1is_pick 1team_id 1hero_id 2is_pick 2team_id 2hero_id 3is_pick ... 18is_pick 18team_id 18hero_id 19is_pick 19team_id 19hero_id 20is_pick 20team_id 20hero_id minutes
2 1928903165 True 2424 False 1 Undying False 0 Ancient Apparition False ... False 1.0 Viper True 0.0 Enchantress True 1.0 Enigma 40.400000
3 1928907204 True 2588 False 1 Spirit Breaker False 0 Alchemist False ... False 1.0 Ancient Apparition True 0.0 Dazzle True 1.0 Windranger 43.133333
4 1928865084 True 3658 False 1 Phantom Lancer False 0 Wraith King False ... False 1.0 Spectre True 0.0 Gyrocopter True 1.0 Venomancer 60.966667
6 1928926702 True 1998 False 1 Undying False 0 Silencer False ... False 1.0 Ancient Apparition True 0.0 Death Prophet True 1.0 Kunkka 33.300000
8 1928902687 False 2595 False 0 Silencer False 1 Omniknight False ... False 0.0 Shadow Fiend True 1.0 Weaver True 0.0 Windranger 43.250000
9 1928917475 False 2019 False 0 Doom False 1 Undying False ... False 0.0 Vengeful Spirit True 1.0 Lion True 0.0 Disruptor 33.650000
10 1928908270 False 2329 False 0 Alchemist False 1 Anti-Mage False ... False 0.0 Rubick True 1.0 Viper True 0.0 Dragon Knight 38.816667
11 1928901534 True 2626 False 1 Riki False 0 Windranger False ... False 1.0 Gyrocopter True 0.0 Weaver True 1.0 Juggernaut 43.766667
14 1928897896 False 2841 False 0 Doom False 1 Io False ... False 0.0 Anti-Mage True 1.0 Necrophos True 0.0 Dark Seer 47.350000
15 1928914863 False 2380 False 0 Tusk False 1 Alchemist False ... False 0.0 Faceless Void True 1.0 Spectre True 0.0 Ember Spirit 39.666667
17 1928904698 True 2758 False 1 Doom False 0 Slardar False ... False 1.0 Lion True 0.0 Magnus True 1.0 Disruptor 45.966667
18 1928925391 True 1675 False 1 Alchemist False 0 Templar Assassin False ... False 1.0 Gyrocopter True 0.0 Lifestealer True 1.0 Invoker 27.916667
20 1928947968 True 1499 False 1 Winter Wyvern False 0 Alchemist False ... False 1.0 Anti-Mage True 0.0 Phantom Assassin True 1.0 Legion Commander 24.983333
25 1928882302 False 3297 False 0 Phantom Lancer False 1 Alchemist False ... False 0.0 Sniper True 1.0 Witch Doctor True 0.0 Drow Ranger 54.950000
28 1928898323 False 2830 False 0 Riki False 1 Phantom Lancer False ... False 0.0 Viper True 1.0 Chaos Knight True 0.0 Huskar 47.166667
29 1928898031 True 2984 False 1 Legion Commander False 0 Doom False ... False 1.0 Troll Warlord True 0.0 Ancient Apparition True 1.0 Bristleback 49.733333
33 1928916547 True 2504 False 1 Doom False 0 Undying False ... False 1.0 Bounty Hunter True 0.0 Lich True 1.0 Rubick 41.733333
34 1928922418 False 2250 False 0 Alchemist False 1 Doom False ... False 0.0 Spectre True 1.0 Spirit Breaker True 0.0 Ursa 37.500000
35 1928899945 False 3131 False 0 Doom False 1 Ember Spirit False ... False 0.0 Necrophos True 1.0 Meepo True 0.0 Chaos Knight 52.183333
37 1928904736 True 2738 False 1 Silencer False 0 Earthshaker False ... False 1.0 Crystal Maiden True 0.0 Rubick True 1.0 Storm Spirit 45.633333
39 1928918024 False 2016 False 0 Queen of Pain False 1 Silencer False ... False 0.0 Broodmother True 1.0 Invoker True 0.0 Slardar 33.600000
40 1928904474 True 2710 False 1 Silencer False 0 Legion Commander False ... False 1.0 Razor True 0.0 Earthshaker True 1.0 Lich 45.166667
44 1928906773 True 2527 False 1 Omniknight False 0 Undying False ... False 1.0 Death Prophet True 0.0 Gyrocopter True 1.0 Razor 42.116667
45 1928908555 False 2651 False 0 Doom False 1 Undying False ... False 0.0 Witch Doctor True 1.0 Disruptor True 0.0 Ancient Apparition 44.183333
50 1928907445 False 2720 False 0 Phantom Lancer False 1 Omniknight False ... False 0.0 Earthshaker True 1.0 Magnus True 0.0 Sniper 45.333333
54 1928899687 True 2998 False 1 Earthshaker False 0 Phantom Lancer False ... False 1.0 Huskar True 0.0 Medusa True 1.0 Anti-Mage 49.966667
56 1928920811 True 2014 False 1 Phantom Lancer False 0 Silencer False ... False 1.0 Anti-Mage True 0.0 Storm Spirit True 1.0 Centaur Warrunner 33.566667
57 1928926136 True 1986 False 1 Spirit Breaker False 0 Doom False ... False 1.0 Bounty Hunter True 0.0 Lion True 1.0 Disruptor 33.100000
59 1928912675 False 2303 False 0 Tusk False 1 Doom False ... False 0.0 Phantom Lancer True 1.0 Medusa True 0.0 Wraith King 38.383333
61 1928909182 False 2879 False 0 Doom False 1 Spirit Breaker False ... False 0.0 Broodmother True 1.0 Drow Ranger True 0.0 Gyrocopter 47.983333
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
460979 1829180976 True 2043 False 1 Silencer False 0 Undying False ... False 1.0 Weaver True 0.0 Night Stalker True 1.0 Tidehunter 34.050000
460982 1829211600 True 1546 False 1 Storm Spirit False 0 Silencer False ... False 1.0 Tidehunter True 0.0 Axe True 1.0 Spectre 25.766667
460988 1829191408 True 2322 False 1 Silencer False 0 Witch Doctor False ... False 1.0 Medusa True 0.0 Invoker True 1.0 Shadow Fiend 38.700000
460990 1829202355 True 1407 False 1 Lina False 0 Bounty Hunter False ... False 1.0 Storm Spirit True 0.0 Batrider True 1.0 Phoenix 23.450000
460991 1829150323 False 2739 False 0 Shadow Fiend False 1 Undying False ... False 0.0 Anti-Mage True 1.0 Chaos Knight True 0.0 Sven 45.650000
460994 1829217329 False 1446 False 0 Faceless Void False 1 Naga Siren False ... False 0.0 Tusk True 1.0 Night Stalker True 0.0 Anti-Mage 24.100000
460996 1829155443 False 2380 False 0 Silencer False 1 Wraith King False ... False 0.0 Sven True 1.0 Axe True 0.0 Shadow Fiend 39.666667
460999 1829159866 True 2686 False 1 Storm Spirit False 0 Zeus False ... False 1.0 Earthshaker True 0.0 Clinkz True 1.0 Phantom Lancer 44.766667
461003 1829173298 False 2305 False 0 Death Prophet False 1 Storm Spirit False ... False 0.0 Phantom Assassin True 1.0 Luna True 0.0 Morphling 38.416667
461004 1829154867 True 2973 False 1 Undying False 0 Silencer False ... False 1.0 Storm Spirit True 0.0 Queen of Pain True 1.0 Pudge 49.550000
461006 1829185496 True 2192 False 1 Undying False 0 Omniknight False ... False 1.0 Magnus True 0.0 Sniper True 1.0 Phantom Assassin 36.533333
461007 1829172438 False 2486 False 0 Silencer False 1 Doom False ... False 0.0 Ancient Apparition True 1.0 Pugna True 0.0 Shadow Fiend 41.433333
461009 1829123849 True 3479 False 1 Ursa False 0 Phantom Lancer False ... False 1.0 Omniknight True 0.0 Death Prophet True 1.0 Bristleback 57.983333
461010 1829160208 True 2652 False 1 Doom False 0 Chaos Knight False ... False 1.0 Ogre Magi True 0.0 Bane True 1.0 Pugna 44.200000
461013 1829189540 False 2252 False 0 Witch Doctor False 1 Undying False ... False 0.0 Leshrac True 1.0 Silencer True 0.0 Lifestealer 37.533333
461015 1829198889 False 2133 False 0 Spirit Breaker False 1 Silencer False ... False 0.0 Tidehunter True 1.0 Templar Assassin True 0.0 Bounty Hunter 35.550000
461017 1829153572 False 2997 False 0 Storm Spirit False 1 Phantom Lancer False ... False 0.0 Faceless Void True 1.0 Slark True 0.0 Magnus 49.950000
461021 1829209036 True 1946 False 1 Tidehunter False 0 Bristleback False ... False 1.0 Queen of Pain True 0.0 Necrophos True 1.0 Lina 32.433333
461023 1829234020 False 1078 False 0 Phantom Assassin False 1 Phantom Lancer False ... False 0.0 Techies True 1.0 Viper True 0.0 Vengeful Spirit 17.966667
461024 1829111018 True 4180 False 1 Earthshaker False 0 Huskar False ... False 1.0 Winter Wyvern True 0.0 Enigma True 1.0 Ember Spirit 69.666667
461025 1829186282 False 2266 False 0 Naga Siren False 1 Undying False ... False 0.0 Spirit Breaker True 1.0 Night Stalker True 0.0 Clinkz 37.766667
461026 1829179699 False 2367 False 0 Bloodseeker False 1 Storm Spirit False ... False 0.0 Spirit Breaker True 1.0 Ogre Magi True 0.0 Witch Doctor 39.450000
461029 1829147824 False 3072 False 0 Enigma False 1 Witch Doctor False ... False 0.0 Storm Spirit True 1.0 Zeus True 0.0 Lion 51.200000
461032 1829234154 True 1426 False 1 Phantom Lancer False 0 Riki False ... False 1.0 Pudge True 0.0 Huskar True 1.0 Juggernaut 23.766667
461034 1829153980 True 2956 False 1 Techies False 0 Bloodseeker False ... False 1.0 Lion True 0.0 Legion Commander True 1.0 Wraith King 49.266667
461040 1829185825 True 2304 False 1 Undying False 0 Naga Siren False ... False 1.0 Anti-Mage True 0.0 Slark True 1.0 Lifestealer 38.400000
461042 1829093169 False 4199 False 0 Zeus False 1 Bounty Hunter False ... False 0.0 Storm Spirit True 1.0 Viper True 0.0 Shadow Fiend 69.983333
461043 1829173585 False 2658 False 0 Lifestealer False 1 Spirit Breaker False ... False 0.0 Tidehunter True 1.0 Medusa True 0.0 Spectre 44.300000
461047 1829187140 True 2346 False 1 Phantom Assassin False 0 Tidehunter False ... False 1.0 Puck True 0.0 Windranger True 1.0 Tusk 39.100000
461049 1829227757 True 1584 False 1 Spirit Breaker False 0 Tusk False ... False 1.0 Dark Seer True 0.0 Timbersaw True 1.0 Ember Spirit 26.400000

227312 rows ร— 64 columns

# # Getting the hero with the most wins
total_pick_heroes = 10
pick_heroes_range = [5, 8, 14, 16, 19, 6, 7, 13, 15, 20]
change_count = 5
most_picked_hero_win_list = {}
for i in range(total_pick_heroes):
    hero_id = '{}hero_id'.format(pick_heroes_range[i])
    if i >= 5:
        most_win_hero = all_win_data_only_2.groupby([hero_id]).size().sort_values(ascending=False).index[0]
        most_win_hero_stats = all_win_data_only_2.groupby([hero_id]).size().sort_values(ascending=False)[0]
        if most_win_hero in most_picked_hero_win_list:
            most_picked_hero_win_list[most_win_hero]  = most_win_hero_stats
        else:
            most_picked_hero_win_list[most_win_hero] = most_win_hero_stats
    else:
        most_win_hero = all_win_data_only_1.groupby([hero_id]).size().sort_values(ascending=False).index[0]
        most_win_hero_stats = all_win_data_only_1.groupby([hero_id]).size().sort_values(ascending=False)[0]
        if most_win_hero in most_picked_hero_win_list:
            most_picked_hero_win_list[most_win_hero]  = most_win_hero_stats
        else:
            most_picked_hero_win_list[most_win_hero] = most_win_hero_stats
# # Total games
data.shape[0]
print('Total Games: ', data.shape[0])
Total Games:  461050
most_picked_hero_win_list
{'Earthshaker': 71882,
 'Bristleback': 13658,
 'Gyrocopter': 14346,
 'Windranger': 14129}
# # Validation
71882   13658   14346   14129 < 461050
True

Getting the most winning pairs of 5

# # We can take win rates for 1st picked team. (i.e: 5, 8, 14, 16, 19)
# # We can take win rates for 2nd picked team. (i.e: 6, 7, 13, 15, 20)
grouped_win_1 = all_win_data_only_1.groupby(['5hero_id', '8hero_id', '14hero_id', '16hero_id', '19hero_id']).size()
grouped_win_2 = all_win_data_only_2.groupby(['6hero_id', '7hero_id', '13hero_id', '15hero_id', '20hero_id']).size()
temp_groups = [grouped_win_1, grouped_win_2]
winning_combination_5 = pd.concat(temp_groups)
winning_combination_5 = winning_combination_5.groupby(winning_combination_5.index).sum().sort_values(ascending=False)
(Shadow Fiend, Winter Wyvern, Gyrocopter, Rubick, Ember Spirit)    3
(Earthshaker, Witch Doctor, Spirit Breaker, Anti-Mage, Sven)       3
(Lion, Warlock, Shadow Fiend, Windranger, Invoker)                 3
dtype: int64
max_value = winning_combination_5[0]
winning_combination_5.loc[winning_combination_5.values == max_value]
(Shadow Fiend, Winter Wyvern, Gyrocopter, Rubick, Ember Spirit)             3
(Earthshaker, Witch Doctor, Spirit Breaker, Anti-Mage, Sven)                3
(Lion, Warlock, Shadow Fiend, Windranger, Invoker)                          3
(Earthshaker, Shadow Fiend, Dark Seer, Ember Spirit, Windranger)            3
(Witch Doctor, Crystal Maiden, Bristleback, Sven, Queen of Pain)            3
(Ancient Apparition, Lion, Queen of Pain, Phantom Lancer, Ember Spirit)     3
(Witch Doctor, Spirit Breaker, Io, Tiny, Magnus)                            3
(Witch Doctor, Tidehunter, Enigma, Sven, Shadow Fiend)                      3
(Winter Wyvern, Earthshaker, Clockwerk, Windranger, Ember Spirit)           3
(Shadow Fiend, Earthshaker, Clockwerk, Ancient Apparition, Ember Spirit)    3
(Shadow Fiend, Earthshaker, Gyrocopter, Clockwerk, Bounty Hunter)           3
(Winter Wyvern, Earthshaker, Dark Seer, Shadow Fiend, Windranger)           3
(Omniknight, Crystal Maiden, Bristleback, Phantom Assassin, Viper)          3
(Omniknight, Phantom Assassin, Shadow Shaman, Wraith King, Anti-Mage)       3
(Crystal Maiden, Enigma, Magnus, Sven, Shadow Fiend)                        3
(Crystal Maiden, Vengeful Spirit, Luna, Drow Ranger, Sven)                  3
(Earthshaker, Dazzle, Bristleback, Shadow Fiend, Faceless Void)             3
dtype: int64
# # Validating
winning_combination_5.shape[0] < (118 * 118 * 118 * 118 * 118)
True
Playing the combination of these heroes was the highest (i.e=3). Out of 4 hundred thousand matches, only 6 combinations has the rate of winning and that is only of 3. This shows that picking the best win rate hero doesn't necessarly win the match, there should be good combination of all the heroes of the same team

Getting the most winning pairs of 4

# # Validation
# # C = Combination
# # 5C4 = 5
# # We can take win rates for 1st picked team. (i.e: 5, 8, 14, 16, 19)
# # We can take win rates for 2nd picked team. (i.e: 6, 7, 13, 15, 20)
# # grouped_win_1 = all_win_data_only_1.groupby(['5hero_id', '8hero_id', '14hero_id', '16hero_id', '19hero_id']).size()
grouped_win_1 = all_win_data_only_1.groupby(['5hero_id', '8hero_id', '14hero_id', '16hero_id']).size()
grouped_win_2 = all_win_data_only_1.groupby(['5hero_id', '8hero_id', '14hero_id', '19hero_id']).size()
grouped_win_3 = all_win_data_only_1.groupby(['5hero_id', '8hero_id', '16hero_id', '19hero_id']).size()
grouped_win_4 = all_win_data_only_1.groupby(['5hero_id', '14hero_id', '16hero_id', '19hero_id']).size()
grouped_win_5 = all_win_data_only_1.groupby(['8hero_id', '14hero_id', '16hero_id', '19hero_id']).size()
# # grouped_win_2 = all_win_data_only_2.groupby(['6hero_id', '7hero_id', '13hero_id', '15hero_id', '20hero_id']).size()
grouped_win_6 = all_win_data_only_2.groupby(['6hero_id', '7hero_id', '13hero_id', '15hero_id']).size()
grouped_win_7 = all_win_data_only_2.groupby(['6hero_id', '7hero_id', '13hero_id', '20hero_id']).size()
grouped_win_8 = all_win_data_only_2.groupby(['6hero_id', '7hero_id', '15hero_id', '20hero_id']).size()
grouped_win_9 = all_win_data_only_2.groupby(['6hero_id', '13hero_id', '15hero_id', '20hero_id']).size()
grouped_win_10 = all_win_data_only_2.groupby(['7hero_id', '13hero_id', '15hero_id', '20hero_id']).size()
temp_groups = [grouped_win_1, grouped_win_2, grouped_win_3, grouped_win_4, grouped_win_5, grouped_win_6, grouped_win_7, grouped_win_8, grouped_win_9, grouped_win_10]
winning_combination_4 = pd.concat(temp_groups)
winning_combination_4 = winning_combination_4.groupby(winning_combination_4.index).sum().sort_values(ascending=False)
max_value = winning_combination_4[0]
winning_combination_4.loc[winning_combination_4.values == max_value]
(Crystal Maiden, Vengeful Spirit, Luna, Drow Ranger)    27
dtype: int64
# # Validating
winning_combination_4.shape[0] < (118 * 118 * 118 * 118)
True

Getting the most winning pair of 3

# # We can take win rates for 1st picked team. (i.e: 5, 8, 14, 16, 19)
# # We can take win rates for 2nd picked team. (i.e: 6, 7, 13, 15, 20)
grouped_win_1 = all_win_data_only_1.groupby(['5hero_id', '8hero_id', '14hero_id']).size()
grouped_win_2 = all_win_data_only_1.groupby(['5hero_id', '8hero_id', '16hero_id']).size()
grouped_win_3 = all_win_data_only_1.groupby(['5hero_id', '8hero_id', '19hero_id']).size()
grouped_win_4 = all_win_data_only_1.groupby(['8hero_id', '14hero_id', '16hero_id']).size()
grouped_win_5 = all_win_data_only_1.groupby(['8hero_id', '14hero_id', '19hero_id']).size()
grouped_win_6 = all_win_data_only_1.groupby(['14hero_id', '16hero_id', '19hero_id']).size()
grouped_win_7 = all_win_data_only_1.groupby(['5hero_id', '16hero_id', '19hero_id']).size()
grouped_win_8 = all_win_data_only_1.groupby(['8hero_id', '16hero_id', '19hero_id']).size()
grouped_win_9 = all_win_data_only_1.groupby(['5hero_id', '14hero_id', '19hero_id']).size()
grouped_win_10 = all_win_data_only_1.groupby(['5hero_id', '14hero_id', '16hero_id']).size()
grouped_win_11 = all_win_data_only_2.groupby(['6hero_id', '7hero_id', '13hero_id']).size()
grouped_win_12 = all_win_data_only_2.groupby(['6hero_id', '7hero_id', '15hero_id']).size()
grouped_win_13 = all_win_data_only_2.groupby(['6hero_id', '7hero_id', '20hero_id']).size()
grouped_win_14 = all_win_data_only_2.groupby(['7hero_id', '13hero_id', '15hero_id']).size()
grouped_win_15 = all_win_data_only_2.groupby(['7hero_id', '13hero_id', '20hero_id']).size()
grouped_win_16 = all_win_data_only_2.groupby([ '13hero_id', '15hero_id', '20hero_id']).size()
grouped_win_17 = all_win_data_only_2.groupby(['6hero_id', '15hero_id', '20hero_id']).size()
grouped_win_18 = all_win_data_only_2.groupby(['7hero_id', '15hero_id', '20hero_id']).size()
grouped_win_19 = all_win_data_only_2.groupby(['6hero_id', '13hero_id', '20hero_id']).size()
grouped_win_20 = all_win_data_only_2.groupby(['6hero_id', '13hero_id', '15hero_id']).size()
temp_groups = [
    grouped_win_1, grouped_win_2, grouped_win_3, grouped_win_4, grouped_win_5, grouped_win_6, grouped_win_7, grouped_win_8, grouped_win_9, grouped_win_10,
    grouped_win_11, grouped_win_12, grouped_win_13, grouped_win_14, grouped_win_15, grouped_win_16, grouped_win_17, grouped_win_18, grouped_win_19,grouped_win_20
]
winning_combination_3 = pd.concat(temp_groups)
winning_combination_3 = winning_combination_3.groupby(winning_combination_3.index).sum().sort_values(ascending=False)
max_value = winning_combination_3[0]
winning_combination_3.loc[winning_combination_3.values == max_value]
(Earthshaker, Witch Doctor, Windranger)    443
dtype: int64
# # Validating
winning_combination_3.shape[0] < (118 * 118 * 118)
True

Getting the most winning pair of 2

# # We can take win rates for 1st picked team. (i.e: 5, 8, 14, 16, 19)
# # We can take win rates for 2nd picked team. (i.e: 6, 7, 13, 15, 20)
grouped_win_1 = all_win_data_only_1.groupby(['5hero_id', '8hero_id']).size()
grouped_win_2 = all_win_data_only_1.groupby(['5hero_id', '14hero_id']).size()
grouped_win_3 = all_win_data_only_1.groupby(['5hero_id', '16hero_id']).size()
grouped_win_4 = all_win_data_only_1.groupby(['8hero_id', '19hero_id']).size()
grouped_win_5 = all_win_data_only_1.groupby(['8hero_id', '14hero_id']).size()
grouped_win_6 = all_win_data_only_1.groupby(['8hero_id', '16hero_id']).size()
grouped_win_7 = all_win_data_only_1.groupby(['8hero_id', '19hero_id']).size()
grouped_win_8 = all_win_data_only_1.groupby(['14hero_id', '16hero_id']).size()
grouped_win_9 = all_win_data_only_1.groupby(['14hero_id', '19hero_id']).size()
grouped_win_10 = all_win_data_only_1.groupby(['16hero_id', '19hero_id']).size()
grouped_win_11 = all_win_data_only_2.groupby(['6hero_id', '7hero_id']).size()
grouped_win_12 = all_win_data_only_2.groupby(['6hero_id', '13hero_id']).size()
grouped_win_13 = all_win_data_only_2.groupby(['6hero_id', '15hero_id']).size()
grouped_win_14 = all_win_data_only_2.groupby(['6hero_id', '20hero_id']).size()
grouped_win_15 = all_win_data_only_2.groupby(['7hero_id', '13hero_id']).size()
grouped_win_16 = all_win_data_only_2.groupby([ '7hero_id', '15hero_id']).size()
grouped_win_17 = all_win_data_only_2.groupby(['7hero_id', '20hero_id']).size()
grouped_win_18 = all_win_data_only_2.groupby(['13hero_id', '15hero_id']).size()
grouped_win_19 = all_win_data_only_2.groupby(['13hero_id', '20hero_id']).size()
grouped_win_20 = all_win_data_only_2.groupby(['15hero_id', '20hero_id']).size()
temp_groups = [
    grouped_win_1, grouped_win_2, grouped_win_3, grouped_win_4, grouped_win_5, grouped_win_6, grouped_win_7, grouped_win_8, grouped_win_9, grouped_win_10,
    grouped_win_11, grouped_win_12, grouped_win_13, grouped_win_14, grouped_win_15, grouped_win_16, grouped_win_17, grouped_win_18, grouped_win_19,grouped_win_20
]
winning_combination_2 = pd.concat(temp_groups)
winning_combination_2 = winning_combination_2.groupby(winning_combination_2.index).sum().sort_values(ascending=False)
max_value = winning_combination_2[0]
winning_combination_2.loc[winning_combination_2.values == max_value]
(Earthshaker, Gyrocopter)    8309
dtype: int64
# # Validating
winning_combination_2.shape[0] < (118 * 118)
True

From a Gamers Perspective

Dota totally depends on the meta. This draft is done on 6.* whereas the current meta is on 7.* So, this draft analysis, if used in real life on real games will not be good due to the meta changes.

Notebook Created by: Sulabh Shrestha
- Connect with me on Linkedin & Twitter

Contribute


Support


If you are having issues, please let us know. I have a mailing list located at: [email protected]

Copyright and License


Copyright 2018 Codexponent. Code released under the [MIT]license.