-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathchoice.py
More file actions
33 lines (26 loc) · 785 Bytes
/
choice.py
File metadata and controls
33 lines (26 loc) · 785 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# # Importing Packages
import os
import copy
import config
import dota2api
import numpy as np
import pandas as pd
from sklearn import preprocessing
# # applying roulette wheel
def roulette_wheel(id_hero, all_win_data_only, heroes_dict):
hero_id = id_hero
grouped1 = all_win_data_only.groupby(all_win_data_only[hero_id]).size()
data_bucket = []
for i in range(len(grouped1)):
count = grouped1.iloc[i]
for j in range(count):
data_bucket.append(count)
# # Shuffling
np.random.shuffle(data_bucket)
# # Choosing
choice = np.random.choice(data_bucket)
# # Hero ID
hero_id = grouped1.loc[grouped1.values == choice].index[0]
# # Hero Name
hero_name = heroes_dict[hero_id]
return hero_name