728x90
수집한 데이터를 가지고 챔피언들의 티어를 계산하는 코드입니다.
어디서 가중치를 더 줄것인지 혹은 뺄 것인지 정할 수 있고 또 얼마나 더하고 뺄지 산정할 수 있습니다.
기본 틀은 이렇게 되고 사람마다 다 각자 생각이 다르니까 알아서 조정하면서 수정하시면 됩니다.
라인별로 정리했습니다.
라인별 티어 (입력할 라인정보 : 'TOP','JUG','MID','BOT','SUP')
import numpy as np
import pandas as pd
from google.cloud import bigquery
from google.oauth2 import service_account
from google.cloud import storage
import pprint
import json
credentials = service_account.Credentials.from_service_account_file('admin.json')
bigquery_client = bigquery.Client(credentials=credentials, project='cslee-323908')
storage_client = storage.Client(credentials=credentials, project='cslee-323908')
qry = "select id, key from cslee.ChampData"
champdata = bigquery_client.query(qry).to_dataframe()
champname = champdata.drop('key', axis=1)
allcham = champdata.drop('id', axis=1)
allcham2 = np.array(allcham)
chamlist = np.array(allcham2).flatten().tolist()
champname = np.array(champname)
champname = np.array(champname).flatten().tolist()
def f2(x):
return x[1]
win_df = pd.read_csv("C:/RiotProject/practice/finalwin.csv")
lose_df = pd.read_csv("C:/RiotProject/practice/finallose.csv")
all_df = pd.concat([win_df, lose_df])
all_df['JUG'].shape[0]
def make_winrate(position):
win = win_df[[f'{position}']]
lose = lose_df[[f'{position}']]
all = pd.concat([win, lose])
dic = {}
for i, j in zip(chamlist, champname):
if all[all[f'{position}'] == i].shape[0] >= 10000:
try:
dic[j] = (win[win[f'{position}'] == i].shape[0] / all[all[f'{position}'] == i].shape[0]) * 100
except:
pass
dic = dict(sorted(dic.items(), reverse=True, key=f2))
return dic
def make_allpickrate(position):
game_count = all_df[f'{position}'].shape[0]
sum_all = pd.concat([all_df['TOP'], all_df['JUG'], all_df['MID'], all_df['BOT'], all_df['SUP']])
freq = sum_all.groupby(sum_all.iloc[:]).count()
dic = {}
for i, j in zip(chamlist, champname):
try:
howmanytimes = freq.values[((freq.index == i) == True).tolist().index(True)]
dic[j] = (howmanytimes / game_count) * 100
except:
pass
dic = dict(sorted(dic.items(), reverse=True, key=f2))
return dic
def make_lanepickrate(position):
game_count = all_df[f'{position}'].shape[0]
sum_all = pd.concat([all_df[f'{position}']])
freq = sum_all.groupby(sum_all.iloc[:]).count()
dic = {}
for i, j in zip(chamlist, champname):
try:
howmanytimes = freq.values[((freq.index == i) == True).tolist().index(True)]
dic[j] = (howmanytimes / game_count) * 100
except:
pass
dic = dict(sorted(dic.items(), reverse=True, key=f2))
return dic
def make_ban():
df = pd.read_csv('C:/RiotProject/practice/finalbanlist_tot.csv')
ban = pd.concat([df['1'], df['2'], df['3'], df['4'], df['5']])
freq = ban.groupby(ban.iloc[:]).count()
dic = {}
for i, j in zip(chamlist, champname):
try:
dic[j] = (freq.values[((freq.index == i) == True).tolist().index(True)] / ban.iloc[:].shape[0]) * 100
except:
pass
dic = dict(sorted(dic.items(), reverse=True, key=f2))
return dic
def make_tierinfo(position):
winrate = make_winrate(f'{position}')
lanepickrate = make_lanepickrate(f'{position}')
ban = make_ban()
dic = {}
for j in champname:
try:
dic[j] = (winrate[j] * 0.4) + (lanepickrate[j] * 0.7) + (ban[j] * 0.4)
except:
pass
dic = dict(sorted(dic.items(), reverse=True, key=f2))
return dic
# print(json.dumps(make_tierinfo('TOP'), sort_keys=False, indent=4))
# print(json.dumps(make_tierinfo('JUG'), sort_keys=False, indent=4))
# print(json.dumps(make_tierinfo('MID'), sort_keys=False, indent=4))
# print(json.dumps(make_tierinfo('BOT'), sort_keys=False, indent=4))
# print(json.dumps(make_tierinfo('SUP'), sort_keys=False, indent=4))
0.7, 0.4 등등 각각의 수치들을 조정하면 티어정보가 달라집니다.
728x90
'프로젝트 > Riot LoL' 카테고리의 다른 글
베스트 조합 찾아내는 코드 by CSV (0) | 2021.10.19 |
---|---|
RiotAPI를 가지고 인게임데이터 csv로 저장하는 자동화 코드 (0) | 2021.10.19 |
포지션정보넣으면 승률+밴픽률순서로 출력 (0) | 2021.10.19 |
챔피언 별 밴픽률을 구해보자 (0) | 2021.09.24 |
Modeling을 위한 전처리를 해보자 (0) | 2021.09.15 |