League of Legends
라이브러리 설정, 데이터 읽어들이기
데이터 셋 : https://www.kaggle.com/bobbyscience/league-of-legends-diamond-ranked-games-10-min
League of Legends 게임 시작 10분이내 일어나는 여러 상황을 통해 승패를 예측하는 데이터 셋이다.
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
df = pd.read_csv('high_diamond_ranked_10min.csv')
pd.set_option('display.max_columns', None)
df.sample(10)
gameId | blueWins | blueWardsPlaced | blueWardsDestroyed | blueFirstBlood | blueKills | blueDeaths | blueAssists | blueEliteMonsters | blueDragons | blueHeralds | blueTowersDestroyed | blueTotalGold | blueAvgLevel | blueTotalExperience | blueTotalMinionsKilled | blueTotalJungleMinionsKilled | blueGoldDiff | blueExperienceDiff | blueCSPerMin | blueGoldPerMin | redWardsPlaced | redWardsDestroyed | redFirstBlood | redKills | redDeaths | redAssists | redEliteMonsters | redDragons | redHeralds | redTowersDestroyed | redTotalGold | redAvgLevel | redTotalExperience | redTotalMinionsKilled | redTotalJungleMinionsKilled | redGoldDiff | redExperienceDiff | redCSPerMin | redGoldPerMin | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
4555 | 4445985804 | 1 | 19 | 4 | 1 | 7 | 2 | 8 | 1 | 1 | 0 | 0 | 17459 | 7.2 | 19021 | 231 | 64 | 2929 | 1296 | 23.1 | 1745.9 | 15 | 1 | 0 | 2 | 7 | 2 | 0 | 0 | 0 | 0 | 14530 | 7.0 | 17725 | 191 | 64 | -2929 | -1296 | 19.1 | 1453.0 |
3756 | 4505375338 | 1 | 21 | 3 | 0 | 5 | 5 | 8 | 2 | 1 | 1 | 0 | 16709 | 7.0 | 18855 | 222 | 68 | 728 | 2095 | 22.2 | 1670.9 | 15 | 7 | 1 | 5 | 5 | 8 | 0 | 0 | 0 | 0 | 15981 | 6.8 | 16760 | 224 | 44 | -728 | -2095 | 22.4 | 1598.1 |
5222 | 4495636315 | 1 | 13 | 1 | 1 | 4 | 3 | 5 | 0 | 0 | 0 | 0 | 17262 | 7.0 | 18608 | 248 | 52 | 1673 | 1200 | 24.8 | 1726.2 | 12 | 1 | 0 | 3 | 4 | 2 | 2 | 1 | 1 | 0 | 15589 | 6.8 | 17408 | 197 | 69 | -1673 | -1200 | 19.7 | 1558.9 |
2104 | 4490390200 | 1 | 13 | 3 | 0 | 7 | 5 | 2 | 1 | 1 | 0 | 0 | 17247 | 7.2 | 19189 | 249 | 63 | 2152 | 2575 | 24.9 | 1724.7 | 17 | 2 | 1 | 5 | 7 | 7 | 0 | 0 | 0 | 0 | 15095 | 6.8 | 16614 | 178 | 40 | -2152 | -2575 | 17.8 | 1509.5 |
2400 | 4381068813 | 0 | 42 | 1 | 1 | 7 | 3 | 8 | 1 | 1 | 0 | 0 | 16146 | 6.6 | 16204 | 196 | 43 | 2037 | -281 | 19.6 | 1614.6 | 19 | 5 | 0 | 3 | 7 | 3 | 0 | 0 | 0 | 0 | 14109 | 6.4 | 16485 | 172 | 57 | -2037 | 281 | 17.2 | 1410.9 |
3512 | 4419275391 | 0 | 15 | 2 | 0 | 6 | 6 | 5 | 0 | 0 | 0 | 0 | 15856 | 7.0 | 17723 | 224 | 47 | -460 | 60 | 22.4 | 1585.6 | 16 | 2 | 1 | 6 | 6 | 7 | 1 | 1 | 0 | 0 | 16316 | 6.8 | 17663 | 238 | 36 | 460 | -60 | 23.8 | 1631.6 |
5749 | 4464945993 | 0 | 15 | 1 | 1 | 8 | 7 | 8 | 2 | 1 | 1 | 0 | 17898 | 7.4 | 19411 | 232 | 58 | 942 | 1300 | 23.2 | 1789.8 | 16 | 2 | 0 | 7 | 8 | 6 | 0 | 0 | 0 | 0 | 16956 | 7.0 | 18111 | 245 | 43 | -942 | -1300 | 24.5 | 1695.6 |
9082 | 4518444031 | 0 | 16 | 5 | 1 | 10 | 8 | 12 | 1 | 1 | 0 | 0 | 17357 | 7.0 | 18388 | 191 | 59 | -310 | 570 | 19.1 | 1735.7 | 27 | 2 | 0 | 8 | 10 | 9 | 1 | 0 | 1 | 0 | 17667 | 7.2 | 17818 | 194 | 56 | 310 | -570 | 19.4 | 1766.7 |
7260 | 4479460532 | 1 | 21 | 3 | 0 | 3 | 4 | 3 | 1 | 1 | 0 | 0 | 14850 | 6.8 | 17967 | 226 | 57 | -858 | 847 | 22.6 | 1485.0 | 21 | 3 | 1 | 4 | 3 | 5 | 0 | 0 | 0 | 0 | 15708 | 6.8 | 17120 | 239 | 44 | 858 | -847 | 23.9 | 1570.8 |
4272 | 4504894173 | 0 | 17 | 1 | 1 | 8 | 1 | 9 | 0 | 0 | 0 | 0 | 16763 | 6.6 | 17181 | 209 | 36 | 3371 | 1173 | 20.9 | 1676.3 | 18 | 1 | 0 | 1 | 8 | 2 | 0 | 0 | 0 | 0 | 13392 | 6.4 | 16008 | 195 | 50 | -3371 | -1173 | 19.5 | 1339.2 |
df.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 9879 entries, 0 to 9878
Data columns (total 40 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 gameId 9879 non-null int64
1 blueWins 9879 non-null int64
2 blueWardsPlaced 9879 non-null int64
3 blueWardsDestroyed 9879 non-null int64
4 blueFirstBlood 9879 non-null int64
5 blueKills 9879 non-null int64
6 blueDeaths 9879 non-null int64
7 blueAssists 9879 non-null int64
8 blueEliteMonsters 9879 non-null int64
9 blueDragons 9879 non-null int64
10 blueHeralds 9879 non-null int64
11 blueTowersDestroyed 9879 non-null int64
12 blueTotalGold 9879 non-null int64
13 blueAvgLevel 9879 non-null float64
14 blueTotalExperience 9879 non-null int64
15 blueTotalMinionsKilled 9879 non-null int64
16 blueTotalJungleMinionsKilled 9879 non-null int64
17 blueGoldDiff 9879 non-null int64
18 blueExperienceDiff 9879 non-null int64
19 blueCSPerMin 9879 non-null float64
20 blueGoldPerMin 9879 non-null float64
21 redWardsPlaced 9879 non-null int64
22 redWardsDestroyed 9879 non-null int64
23 redFirstBlood 9879 non-null int64
24 redKills 9879 non-null int64
25 redDeaths 9879 non-null int64
26 redAssists 9879 non-null int64
27 redEliteMonsters 9879 non-null int64
28 redDragons 9879 non-null int64
29 redHeralds 9879 non-null int64
30 redTowersDestroyed 9879 non-null int64
31 redTotalGold 9879 non-null int64
32 redAvgLevel 9879 non-null float64
33 redTotalExperience 9879 non-null int64
34 redTotalMinionsKilled 9879 non-null int64
35 redTotalJungleMinionsKilled 9879 non-null int64
36 redGoldDiff 9879 non-null int64
37 redExperienceDiff 9879 non-null int64
38 redCSPerMin 9879 non-null float64
39 redGoldPerMin 9879 non-null float64
dtypes: float64(6), int64(34)
memory usage: 3.0 MB
EDA 및 기초 통계 분석
df.describe()
gameId | blueWins | blueWardsPlaced | blueWardsDestroyed | blueFirstBlood | blueKills | blueDeaths | blueAssists | blueEliteMonsters | blueDragons | blueHeralds | blueTowersDestroyed | blueTotalGold | blueAvgLevel | blueTotalExperience | blueTotalMinionsKilled | blueTotalJungleMinionsKilled | blueGoldDiff | blueExperienceDiff | blueCSPerMin | blueGoldPerMin | redWardsPlaced | redWardsDestroyed | redFirstBlood | redKills | redDeaths | redAssists | redEliteMonsters | redDragons | redHeralds | redTowersDestroyed | redTotalGold | redAvgLevel | redTotalExperience | redTotalMinionsKilled | redTotalJungleMinionsKilled | redGoldDiff | redExperienceDiff | redCSPerMin | redGoldPerMin | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
count | 9.879000e+03 | 9879.000000 | 9879.000000 | 9879.000000 | 9879.000000 | 9879.000000 | 9879.000000 | 9879.000000 | 9879.000000 | 9879.000000 | 9879.000000 | 9879.000000 | 9879.000000 | 9879.000000 | 9879.000000 | 9879.000000 | 9879.000000 | 9879.000000 | 9879.000000 | 9879.000000 | 9879.000000 | 9879.000000 | 9879.000000 | 9879.000000 | 9879.000000 | 9879.000000 | 9879.000000 | 9879.000000 | 9879.000000 | 9879.000000 | 9879.000000 | 9879.000000 | 9879.000000 | 9879.000000 | 9879.000000 | 9879.000000 | 9879.000000 | 9879.000000 | 9879.000000 | 9879.000000 |
mean | 4.500084e+09 | 0.499038 | 22.288288 | 2.824881 | 0.504808 | 6.183925 | 6.137666 | 6.645106 | 0.549954 | 0.361980 | 0.187974 | 0.051422 | 16503.455512 | 6.916004 | 17928.110133 | 216.699565 | 50.509667 | 14.414111 | -33.620306 | 21.669956 | 1650.345551 | 22.367952 | 2.723150 | 0.495192 | 6.137666 | 6.183925 | 6.662112 | 0.573135 | 0.413098 | 0.160036 | 0.043021 | 16489.041401 | 6.925316 | 17961.730438 | 217.349226 | 51.313088 | -14.414111 | 33.620306 | 21.734923 | 1648.904140 |
std | 2.757328e+07 | 0.500024 | 18.019177 | 2.174998 | 0.500002 | 3.011028 | 2.933818 | 4.064520 | 0.625527 | 0.480597 | 0.390712 | 0.244369 | 1535.446636 | 0.305146 | 1200.523764 | 21.858437 | 9.898282 | 2453.349179 | 1920.370438 | 2.185844 | 153.544664 | 18.457427 | 2.138356 | 0.500002 | 2.933818 | 3.011028 | 4.060612 | 0.626482 | 0.492415 | 0.366658 | 0.216900 | 1490.888406 | 0.305311 | 1198.583912 | 21.911668 | 10.027885 | 2453.349179 | 1920.370438 | 2.191167 | 149.088841 |
min | 4.295358e+09 | 0.000000 | 5.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 10730.000000 | 4.600000 | 10098.000000 | 90.000000 | 0.000000 | -10830.000000 | -9333.000000 | 9.000000 | 1073.000000 | 6.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 11212.000000 | 4.800000 | 10465.000000 | 107.000000 | 4.000000 | -11467.000000 | -8348.000000 | 10.700000 | 1121.200000 |
25% | 4.483301e+09 | 0.000000 | 14.000000 | 1.000000 | 0.000000 | 4.000000 | 4.000000 | 4.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 15415.500000 | 6.800000 | 17168.000000 | 202.000000 | 44.000000 | -1585.500000 | -1290.500000 | 20.200000 | 1541.550000 | 14.000000 | 1.000000 | 0.000000 | 4.000000 | 4.000000 | 4.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 15427.500000 | 6.800000 | 17209.500000 | 203.000000 | 44.000000 | -1596.000000 | -1212.000000 | 20.300000 | 1542.750000 |
50% | 4.510920e+09 | 0.000000 | 16.000000 | 3.000000 | 1.000000 | 6.000000 | 6.000000 | 6.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 16398.000000 | 7.000000 | 17951.000000 | 218.000000 | 50.000000 | 14.000000 | -28.000000 | 21.800000 | 1639.800000 | 16.000000 | 2.000000 | 0.000000 | 6.000000 | 6.000000 | 6.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 16378.000000 | 7.000000 | 17974.000000 | 218.000000 | 51.000000 | -14.000000 | 28.000000 | 21.800000 | 1637.800000 |
75% | 4.521733e+09 | 1.000000 | 20.000000 | 4.000000 | 1.000000 | 8.000000 | 8.000000 | 9.000000 | 1.000000 | 1.000000 | 0.000000 | 0.000000 | 17459.000000 | 7.200000 | 18724.000000 | 232.000000 | 56.000000 | 1596.000000 | 1212.000000 | 23.200000 | 1745.900000 | 20.000000 | 4.000000 | 1.000000 | 8.000000 | 8.000000 | 9.000000 | 1.000000 | 1.000000 | 0.000000 | 0.000000 | 17418.500000 | 7.200000 | 18764.500000 | 233.000000 | 57.000000 | 1585.500000 | 1290.500000 | 23.300000 | 1741.850000 |
max | 4.527991e+09 | 1.000000 | 250.000000 | 27.000000 | 1.000000 | 22.000000 | 22.000000 | 29.000000 | 2.000000 | 1.000000 | 1.000000 | 4.000000 | 23701.000000 | 8.000000 | 22224.000000 | 283.000000 | 92.000000 | 11467.000000 | 8348.000000 | 28.300000 | 2370.100000 | 276.000000 | 24.000000 | 1.000000 | 22.000000 | 22.000000 | 28.000000 | 2.000000 | 1.000000 | 1.000000 | 2.000000 | 22732.000000 | 8.200000 | 22269.000000 | 289.000000 | 92.000000 | 10830.000000 | 9333.000000 | 28.900000 | 2273.200000 |
- 당장 보이는 것은 blue 경우 정글에서 red보다 herald를 죽일 확률이 높고 red는 그 반대.
# correlation 히트맵 시각화
fig = plt.figure(figsize=(4,10))
sns.heatmap(df.corr()[['blueWins']], annot=True)
<matplotlib.axes._subplots.AxesSubplot at 0x1d802aed648>
- 전체 골드 수급량, 골드-경험치 수급이 승리로 이어질 가능성이 높다.
df.corr()
gameId | blueWins | blueWardsPlaced | blueWardsDestroyed | blueFirstBlood | blueKills | blueDeaths | blueAssists | blueEliteMonsters | blueDragons | blueHeralds | blueTowersDestroyed | blueTotalGold | blueAvgLevel | blueTotalExperience | blueTotalMinionsKilled | blueTotalJungleMinionsKilled | blueGoldDiff | blueExperienceDiff | blueCSPerMin | blueGoldPerMin | redWardsPlaced | redWardsDestroyed | redFirstBlood | redKills | redDeaths | redAssists | redEliteMonsters | redDragons | redHeralds | redTowersDestroyed | redTotalGold | redAvgLevel | redTotalExperience | redTotalMinionsKilled | redTotalJungleMinionsKilled | redGoldDiff | redExperienceDiff | redCSPerMin | redGoldPerMin | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
gameId | 1.000000 | 0.000985 | 0.005361 | -0.012057 | -0.011577 | -0.038993 | -0.013160 | -0.023329 | 0.016599 | 0.008962 | 0.015551 | -0.007467 | -0.033754 | -0.040956 | -0.040852 | -0.002917 | -0.004193 | -0.014670 | -0.012315 | -0.002917 | -0.033754 | 0.007405 | -0.001197 | 0.011577 | -0.013160 | -0.038993 | -0.008664 | 0.017296 | 0.017416 | 0.006163 | 0.003557 | -0.010622 | -0.012419 | -0.021187 | -0.005118 | 0.006040 | 0.014670 | 0.012315 | -0.005118 | -0.010622 |
blueWins | 0.000985 | 1.000000 | 0.000087 | 0.044247 | 0.201769 | 0.337358 | -0.339297 | 0.276685 | 0.221944 | 0.213768 | 0.092385 | 0.115566 | 0.417213 | 0.357820 | 0.396141 | 0.224909 | 0.131445 | 0.511119 | 0.489558 | 0.224909 | 0.417213 | -0.023671 | -0.055400 | -0.201769 | -0.339297 | 0.337358 | -0.271047 | -0.221551 | -0.209516 | -0.097172 | -0.103696 | -0.411396 | -0.352127 | -0.387588 | -0.212171 | -0.110994 | -0.511119 | -0.489558 | -0.212171 | -0.411396 |
blueWardsPlaced | 0.005361 | 0.000087 | 1.000000 | 0.034447 | 0.003228 | 0.018138 | -0.002612 | 0.033217 | 0.019892 | 0.017676 | 0.010104 | 0.009462 | 0.019725 | 0.034349 | 0.031719 | -0.033925 | 0.010501 | 0.015800 | 0.027943 | -0.033925 | 0.019725 | -0.012906 | 0.115549 | -0.003228 | -0.002612 | 0.018138 | -0.009009 | -0.022817 | -0.020121 | -0.011964 | -0.008225 | -0.005685 | -0.008882 | -0.013000 | -0.012395 | 0.001224 | -0.015800 | -0.027943 | -0.012395 | -0.005685 |
blueWardsDestroyed | -0.012057 | 0.044247 | 0.034447 | 1.000000 | 0.017717 | 0.033748 | -0.073182 | 0.067793 | 0.041700 | 0.040504 | 0.016940 | -0.009150 | 0.060054 | 0.060294 | 0.067462 | 0.111028 | -0.023452 | 0.078585 | 0.077946 | 0.111028 | 0.060054 | 0.135966 | 0.123919 | -0.017717 | -0.073182 | 0.033748 | -0.046212 | -0.034509 | -0.034439 | -0.012712 | -0.023943 | -0.067467 | -0.059090 | -0.057314 | 0.040023 | -0.035732 | -0.078585 | -0.077946 | 0.040023 | -0.067467 |
blueFirstBlood | -0.011577 | 0.201769 | 0.003228 | 0.017717 | 1.000000 | 0.269425 | -0.247929 | 0.229485 | 0.151603 | 0.134309 | 0.077509 | 0.083316 | 0.312058 | 0.177617 | 0.190365 | 0.125642 | 0.018190 | 0.378511 | 0.240665 | 0.125642 | 0.312058 | -0.019142 | -0.043304 | -1.000000 | -0.247929 | 0.269425 | -0.201140 | -0.141627 | -0.135327 | -0.060246 | -0.069584 | -0.301479 | -0.182602 | -0.194920 | -0.156711 | -0.024559 | -0.378511 | -0.240665 | -0.156711 | -0.301479 |
blueKills | -0.038993 | 0.337358 | 0.018138 | 0.033748 | 0.269425 | 1.000000 | 0.004044 | 0.813667 | 0.178540 | 0.170436 | 0.076195 | 0.180314 | 0.888751 | 0.434867 | 0.472155 | -0.030880 | -0.112506 | 0.654148 | 0.583730 | -0.030880 | 0.888751 | -0.034239 | -0.092278 | -0.269425 | 0.004044 | 1.000000 | -0.020344 | -0.224564 | -0.207949 | -0.104423 | -0.082491 | -0.161127 | -0.412219 | -0.462333 | -0.472203 | -0.214454 | -0.654148 | -0.583730 | -0.472203 | -0.161127 |
blueDeaths | -0.013160 | -0.339297 | -0.002612 | -0.073182 | -0.247929 | 0.004044 | 1.000000 | -0.026372 | -0.204764 | -0.188852 | -0.095527 | -0.071441 | -0.162572 | -0.414755 | -0.460122 | -0.468560 | -0.228102 | -0.640000 | -0.577613 | -0.468560 | -0.162572 | 0.008102 | 0.038672 | 0.247929 | 1.000000 | 0.004044 | 0.804023 | 0.163340 | 0.150746 | 0.076639 | 0.156780 | 0.885728 | 0.433383 | 0.464584 | -0.040521 | -0.100271 | 0.640000 | 0.577613 | -0.040521 | 0.885728 |
blueAssists | -0.023329 | 0.276685 | 0.033217 | 0.067793 | 0.229485 | 0.813667 | -0.026372 | 1.000000 | 0.149043 | 0.170873 | 0.028434 | 0.123663 | 0.748352 | 0.292661 | 0.303022 | -0.062035 | -0.134023 | 0.549761 | 0.437002 | -0.062035 | 0.748352 | -0.032474 | -0.064501 | -0.229485 | -0.026372 | 0.813667 | -0.007481 | -0.182985 | -0.189563 | -0.058074 | -0.060880 | -0.133948 | -0.356928 | -0.396652 | -0.337515 | -0.160915 | -0.549761 | -0.437002 | -0.337515 | -0.133948 |
blueEliteMonsters | 0.016599 | 0.221944 | 0.019892 | 0.041700 | 0.151603 | 0.178540 | -0.204764 | 0.149043 | 1.000000 | 0.781039 | 0.640271 | 0.166644 | 0.239396 | 0.203530 | 0.232774 | 0.118762 | 0.198378 | 0.281464 | 0.263991 | 0.118762 | 0.239396 | -0.017292 | -0.005288 | -0.151603 | -0.204764 | 0.178540 | -0.156764 | -0.455139 | -0.471754 | -0.144104 | -0.052029 | -0.216616 | -0.169649 | -0.189816 | -0.074838 | -0.087893 | -0.281464 | -0.263991 | -0.074838 | -0.216616 |
blueDragons | 0.008962 | 0.213768 | 0.017676 | 0.040504 | 0.134309 | 0.170436 | -0.188852 | 0.170873 | 0.781039 | 1.000000 | 0.020381 | 0.039750 | 0.186413 | 0.160683 | 0.179083 | 0.086686 | 0.159595 | 0.233875 | 0.211496 | 0.086686 | 0.186413 | -0.027102 | -0.023049 | -0.134309 | -0.188852 | 0.170436 | -0.162406 | -0.506546 | -0.631930 | -0.016827 | -0.032865 | -0.192871 | -0.149806 | -0.159485 | -0.059803 | -0.098446 | -0.233875 | -0.211496 | -0.059803 | -0.192871 |
blueHeralds | 0.015551 | 0.092385 | 0.010104 | 0.016940 | 0.077509 | 0.076195 | -0.095527 | 0.028434 | 0.640271 | 0.020381 | 1.000000 | 0.217901 | 0.153974 | 0.128201 | 0.152386 | 0.083509 | 0.121291 | 0.162943 | 0.162496 | 0.083509 | 0.153974 | 0.005653 | 0.019885 | -0.077509 | -0.095527 | 0.076195 | -0.051209 | -0.105593 | 0.022035 | -0.210012 | -0.042872 | -0.109557 | -0.087337 | -0.107718 | -0.046253 | -0.019622 | -0.162943 | -0.162496 | -0.046253 | -0.109557 |
blueTowersDestroyed | -0.007467 | 0.115566 | 0.009462 | -0.009150 | 0.083316 | 0.180314 | -0.071441 | 0.123663 | 0.166644 | 0.039750 | 0.217901 | 1.000000 | 0.350941 | 0.124453 | 0.139398 | 0.092291 | 0.008165 | 0.294060 | 0.218320 | 0.092291 | 0.350941 | 0.003660 | -0.038623 | -0.083316 | -0.071441 | 0.180314 | -0.036254 | -0.041099 | -0.028482 | -0.031973 | 0.011738 | -0.122465 | -0.204429 | -0.210167 | -0.186879 | -0.038505 | -0.294060 | -0.218320 | -0.186879 | -0.122465 |
blueTotalGold | -0.033754 | 0.417213 | 0.019725 | 0.060054 | 0.312058 | 0.888751 | -0.162572 | 0.748352 | 0.239396 | 0.186413 | 0.153974 | 0.350941 | 1.000000 | 0.616968 | 0.676193 | 0.284902 | 0.090769 | 0.816803 | 0.729345 | 0.284902 | 1.000000 | -0.020069 | -0.090611 | -0.312058 | -0.162572 | 0.888751 | -0.128921 | -0.227236 | -0.201794 | -0.117257 | -0.119579 | -0.314212 | -0.447049 | -0.491268 | -0.452593 | -0.175275 | -0.816803 | -0.729345 | -0.452593 | -0.314212 |
blueAvgLevel | -0.040956 | 0.357820 | 0.034349 | 0.060294 | 0.177617 | 0.434867 | -0.414755 | 0.292661 | 0.203530 | 0.160683 | 0.128201 | 0.124453 | 0.616968 | 1.000000 | 0.901297 | 0.506279 | 0.371371 | 0.653538 | 0.718822 | 0.506279 | 0.616968 | 0.001020 | -0.052770 | -0.177617 | -0.414755 | 0.434867 | -0.366039 | -0.167348 | -0.137854 | -0.100798 | -0.183090 | -0.440031 | -0.228466 | -0.248941 | -0.123316 | -0.013128 | -0.653538 | -0.718822 | -0.123316 | -0.440031 |
blueTotalExperience | -0.040852 | 0.396141 | 0.031719 | 0.067462 | 0.190365 | 0.472155 | -0.460122 | 0.303022 | 0.232774 | 0.179083 | 0.152386 | 0.139398 | 0.676193 | 0.901297 | 1.000000 | 0.570850 | 0.412967 | 0.717968 | 0.800815 | 0.570850 | 0.676193 | -0.006032 | -0.057446 | -0.190365 | -0.460122 | 0.472155 | -0.397254 | -0.186937 | -0.145501 | -0.124000 | -0.187414 | -0.485059 | -0.254508 | -0.281446 | -0.141276 | -0.010528 | -0.717968 | -0.800815 | -0.141276 | -0.485059 |
blueTotalMinionsKilled | -0.002917 | 0.224909 | -0.033925 | 0.111028 | 0.125642 | -0.030880 | -0.468560 | -0.062035 | 0.118762 | 0.086686 | 0.083509 | 0.092291 | 0.284902 | 0.506279 | 0.570850 | 1.000000 | 0.172282 | 0.450497 | 0.447264 | 1.000000 | 0.284902 | 0.014210 | 0.030234 | -0.125642 | -0.468560 | -0.030880 | -0.337314 | -0.069986 | -0.053958 | -0.047115 | -0.145974 | -0.447904 | -0.142399 | -0.144832 | 0.000484 | 0.092225 | -0.450497 | -0.447264 | 0.000484 | -0.447904 |
blueTotalJungleMinionsKilled | -0.004193 | 0.131445 | 0.010501 | -0.023452 | 0.018190 | -0.112506 | -0.228102 | -0.134023 | 0.198378 | 0.159595 | 0.121291 | 0.008165 | 0.090769 | 0.371371 | 0.412967 | 0.172282 | 1.000000 | 0.167510 | 0.265443 | 0.172282 | 0.090769 | 0.004671 | -0.018008 | -0.018190 | -0.228102 | -0.112506 | -0.169318 | -0.075076 | -0.053295 | -0.056702 | -0.048078 | -0.182167 | -0.013881 | -0.011657 | 0.109806 | -0.026363 | -0.167510 | -0.265443 | 0.109806 | -0.182167 |
blueGoldDiff | -0.014670 | 0.511119 | 0.015800 | 0.078585 | 0.378511 | 0.654148 | -0.640000 | 0.549761 | 0.281464 | 0.233875 | 0.162943 | 0.294060 | 0.816803 | 0.653538 | 0.717968 | 0.450497 | 0.167510 | 1.000000 | 0.894729 | 0.450497 | 0.816803 | -0.019042 | -0.099725 | -0.378511 | -0.640000 | 0.654148 | -0.528081 | -0.281296 | -0.234566 | -0.165611 | -0.273861 | -0.804347 | -0.652929 | -0.714405 | -0.452633 | -0.172066 | -1.000000 | -0.894729 | -0.452633 | -0.804347 |
blueExperienceDiff | -0.012315 | 0.489558 | 0.027943 | 0.077946 | 0.240665 | 0.583730 | -0.577613 | 0.437002 | 0.263991 | 0.211496 | 0.162496 | 0.218320 | 0.729345 | 0.718822 | 0.800815 | 0.447264 | 0.265443 | 0.894729 | 1.000000 | 0.447264 | 0.729345 | -0.026556 | -0.085829 | -0.240665 | -0.577613 | 0.583730 | -0.422972 | -0.269283 | -0.218872 | -0.166162 | -0.197678 | -0.721190 | -0.721925 | -0.800089 | -0.437205 | -0.273224 | -0.894729 | -1.000000 | -0.437205 | -0.721190 |
blueCSPerMin | -0.002917 | 0.224909 | -0.033925 | 0.111028 | 0.125642 | -0.030880 | -0.468560 | -0.062035 | 0.118762 | 0.086686 | 0.083509 | 0.092291 | 0.284902 | 0.506279 | 0.570850 | 1.000000 | 0.172282 | 0.450497 | 0.447264 | 1.000000 | 0.284902 | 0.014210 | 0.030234 | -0.125642 | -0.468560 | -0.030880 | -0.337314 | -0.069986 | -0.053958 | -0.047115 | -0.145974 | -0.447904 | -0.142399 | -0.144832 | 0.000484 | 0.092225 | -0.450497 | -0.447264 | 0.000484 | -0.447904 |
blueGoldPerMin | -0.033754 | 0.417213 | 0.019725 | 0.060054 | 0.312058 | 0.888751 | -0.162572 | 0.748352 | 0.239396 | 0.186413 | 0.153974 | 0.350941 | 1.000000 | 0.616968 | 0.676193 | 0.284902 | 0.090769 | 0.816803 | 0.729345 | 0.284902 | 1.000000 | -0.020069 | -0.090611 | -0.312058 | -0.162572 | 0.888751 | -0.128921 | -0.227236 | -0.201794 | -0.117257 | -0.119579 | -0.314212 | -0.447049 | -0.491268 | -0.452593 | -0.175275 | -0.816803 | -0.729345 | -0.452593 | -0.314212 |
redWardsPlaced | 0.007405 | -0.023671 | -0.012906 | 0.135966 | -0.019142 | -0.034239 | 0.008102 | -0.032474 | -0.017292 | -0.027102 | 0.005653 | 0.003660 | -0.020069 | 0.001020 | -0.006032 | 0.014210 | 0.004671 | -0.019042 | -0.026556 | 0.014210 | -0.020069 | 1.000000 | 0.019784 | 0.019142 | 0.008102 | -0.034239 | 0.023791 | 0.027452 | 0.018717 | 0.021769 | -0.006230 | 0.010666 | 0.041737 | 0.036506 | -0.021842 | 0.004666 | 0.019042 | 0.026556 | -0.021842 | 0.010666 |
redWardsDestroyed | -0.001197 | -0.055400 | 0.115549 | 0.123919 | -0.043304 | -0.092278 | 0.038672 | -0.064501 | -0.005288 | -0.023049 | 0.019885 | -0.038623 | -0.090611 | -0.052770 | -0.057446 | 0.030234 | -0.018008 | -0.099725 | -0.085829 | 0.030234 | -0.090611 | 0.019784 | 1.000000 | 0.043304 | 0.038672 | -0.092278 | 0.055798 | 0.039335 | 0.046132 | 0.005255 | 0.003855 | 0.070784 | 0.075537 | 0.079975 | 0.128062 | -0.009313 | 0.099725 | 0.085829 | 0.128062 | 0.070784 |
redFirstBlood | 0.011577 | -0.201769 | -0.003228 | -0.017717 | -1.000000 | -0.269425 | 0.247929 | -0.229485 | -0.151603 | -0.134309 | -0.077509 | -0.083316 | -0.312058 | -0.177617 | -0.190365 | -0.125642 | -0.018190 | -0.378511 | -0.240665 | -0.125642 | -0.312058 | 0.019142 | 0.043304 | 1.000000 | 0.247929 | -0.269425 | 0.201140 | 0.141627 | 0.135327 | 0.060246 | 0.069584 | 0.301479 | 0.182602 | 0.194920 | 0.156711 | 0.024559 | 0.378511 | 0.240665 | 0.156711 | 0.301479 |
redKills | -0.013160 | -0.339297 | -0.002612 | -0.073182 | -0.247929 | 0.004044 | 1.000000 | -0.026372 | -0.204764 | -0.188852 | -0.095527 | -0.071441 | -0.162572 | -0.414755 | -0.460122 | -0.468560 | -0.228102 | -0.640000 | -0.577613 | -0.468560 | -0.162572 | 0.008102 | 0.038672 | 0.247929 | 1.000000 | 0.004044 | 0.804023 | 0.163340 | 0.150746 | 0.076639 | 0.156780 | 0.885728 | 0.433383 | 0.464584 | -0.040521 | -0.100271 | 0.640000 | 0.577613 | -0.040521 | 0.885728 |
redDeaths | -0.038993 | 0.337358 | 0.018138 | 0.033748 | 0.269425 | 1.000000 | 0.004044 | 0.813667 | 0.178540 | 0.170436 | 0.076195 | 0.180314 | 0.888751 | 0.434867 | 0.472155 | -0.030880 | -0.112506 | 0.654148 | 0.583730 | -0.030880 | 0.888751 | -0.034239 | -0.092278 | -0.269425 | 0.004044 | 1.000000 | -0.020344 | -0.224564 | -0.207949 | -0.104423 | -0.082491 | -0.161127 | -0.412219 | -0.462333 | -0.472203 | -0.214454 | -0.654148 | -0.583730 | -0.472203 | -0.161127 |
redAssists | -0.008664 | -0.271047 | -0.009009 | -0.046212 | -0.201140 | -0.020344 | 0.804023 | -0.007481 | -0.156764 | -0.162406 | -0.051209 | -0.036254 | -0.128921 | -0.366039 | -0.397254 | -0.337314 | -0.169318 | -0.528081 | -0.422972 | -0.337314 | -0.128921 | 0.023791 | 0.055798 | 0.201140 | 0.804023 | -0.020344 | 1.000000 | 0.129698 | 0.142671 | 0.030000 | 0.107425 | 0.736215 | 0.277040 | 0.279788 | -0.078234 | -0.130417 | 0.528081 | 0.422972 | -0.078234 | 0.736215 |
redEliteMonsters | 0.017296 | -0.221551 | -0.022817 | -0.034509 | -0.141627 | -0.224564 | 0.163340 | -0.182985 | -0.455139 | -0.506546 | -0.105593 | -0.041099 | -0.227236 | -0.167348 | -0.186937 | -0.069986 | -0.075076 | -0.281296 | -0.269283 | -0.069986 | -0.227236 | 0.027452 | 0.039335 | 0.141627 | 0.163340 | -0.224564 | 0.129698 | 1.000000 | 0.811234 | 0.619153 | 0.158999 | 0.228861 | 0.222537 | 0.244205 | 0.129705 | 0.216969 | 0.281296 | 0.269283 | 0.129705 | 0.228861 |
redDragons | 0.017416 | -0.209516 | -0.020121 | -0.034439 | -0.135327 | -0.207949 | 0.150746 | -0.189563 | -0.471754 | -0.631930 | 0.022035 | -0.028482 | -0.201794 | -0.137854 | -0.145501 | -0.053958 | -0.053295 | -0.234566 | -0.218872 | -0.053958 | -0.201794 | 0.018717 | 0.046132 | 0.135327 | 0.150746 | -0.207949 | 0.142671 | 0.811234 | 1.000000 | 0.043114 | 0.026950 | 0.178168 | 0.191497 | 0.204941 | 0.103151 | 0.214187 | 0.234566 | 0.218872 | 0.103151 | 0.178168 |
redHeralds | 0.006163 | -0.097172 | -0.011964 | -0.012712 | -0.060246 | -0.104423 | 0.076639 | -0.058074 | -0.144104 | -0.016827 | -0.210012 | -0.031973 | -0.117257 | -0.100798 | -0.124000 | -0.047115 | -0.056702 | -0.165611 | -0.166162 | -0.047115 | -0.117257 | 0.021769 | 0.005255 | 0.060246 | 0.076639 | -0.104423 | 0.030000 | 0.619153 | 0.043114 | 1.000000 | 0.235475 | 0.151762 | 0.123056 | 0.142024 | 0.083087 | 0.083068 | 0.165611 | 0.166162 | 0.083087 | 0.151762 |
redTowersDestroyed | 0.003557 | -0.103696 | -0.008225 | -0.023943 | -0.069584 | -0.082491 | 0.156780 | -0.060880 | -0.052029 | -0.032865 | -0.042872 | 0.011738 | -0.119579 | -0.183090 | -0.187414 | -0.145974 | -0.048078 | -0.273861 | -0.197678 | -0.145974 | -0.119579 | -0.006230 | 0.003855 | 0.069584 | 0.156780 | -0.082491 | 0.107425 | 0.158999 | 0.026950 | 0.235475 | 1.000000 | 0.327503 | 0.113035 | 0.129002 | 0.092564 | 0.006374 | 0.273861 | 0.197678 | 0.092564 | 0.327503 |
redTotalGold | -0.010622 | -0.411396 | -0.005685 | -0.067467 | -0.301479 | -0.161127 | 0.885728 | -0.133948 | -0.216616 | -0.192871 | -0.109557 | -0.122465 | -0.314212 | -0.440031 | -0.485059 | -0.447904 | -0.182167 | -0.804347 | -0.721190 | -0.447904 | -0.314212 | 0.010666 | 0.070784 | 0.301479 | 0.885728 | -0.161127 | 0.736215 | 0.228861 | 0.178168 | 0.151762 | 0.327503 | 1.000000 | 0.614025 | 0.669646 | 0.278715 | 0.102632 | 0.804347 | 0.721190 | 0.278715 | 1.000000 |
redAvgLevel | -0.012419 | -0.352127 | -0.008882 | -0.059090 | -0.182602 | -0.412219 | 0.433383 | -0.356928 | -0.169649 | -0.149806 | -0.087337 | -0.204429 | -0.447049 | -0.228466 | -0.254508 | -0.142399 | -0.013881 | -0.652929 | -0.721925 | -0.142399 | -0.447049 | 0.041737 | 0.075537 | 0.182602 | 0.433383 | -0.412219 | 0.277040 | 0.222537 | 0.191497 | 0.123056 | 0.113035 | 0.614025 | 1.000000 | 0.901748 | 0.489672 | 0.382009 | 0.652929 | 0.721925 | 0.489672 | 0.614025 |
redTotalExperience | -0.021187 | -0.387588 | -0.013000 | -0.057314 | -0.194920 | -0.462333 | 0.464584 | -0.396652 | -0.189816 | -0.159485 | -0.107718 | -0.210167 | -0.491268 | -0.248941 | -0.281446 | -0.144832 | -0.011657 | -0.714405 | -0.800089 | -0.144832 | -0.491268 | 0.036506 | 0.079975 | 0.194920 | 0.464584 | -0.462333 | 0.279788 | 0.244205 | 0.204941 | 0.142024 | 0.129002 | 0.669646 | 0.901748 | 1.000000 | 0.558985 | 0.427214 | 0.714405 | 0.800089 | 0.558985 | 0.669646 |
redTotalMinionsKilled | -0.005118 | -0.212171 | -0.012395 | 0.040023 | -0.156711 | -0.472203 | -0.040521 | -0.337515 | -0.074838 | -0.059803 | -0.046253 | -0.186879 | -0.452593 | -0.123316 | -0.141276 | 0.000484 | 0.109806 | -0.452633 | -0.437205 | 0.000484 | -0.452593 | -0.021842 | 0.128062 | 0.156711 | -0.040521 | -0.472203 | -0.078234 | 0.129705 | 0.103151 | 0.083087 | 0.092564 | 0.278715 | 0.489672 | 0.558985 | 1.000000 | 0.165652 | 0.452633 | 0.437205 | 1.000000 | 0.278715 |
redTotalJungleMinionsKilled | 0.006040 | -0.110994 | 0.001224 | -0.035732 | -0.024559 | -0.214454 | -0.100271 | -0.160915 | -0.087893 | -0.098446 | -0.019622 | -0.038505 | -0.175275 | -0.013128 | -0.010528 | 0.092225 | -0.026363 | -0.172066 | -0.273224 | 0.092225 | -0.175275 | 0.004666 | -0.009313 | 0.024559 | -0.100271 | -0.214454 | -0.130417 | 0.216969 | 0.214187 | 0.083068 | 0.006374 | 0.102632 | 0.382009 | 0.427214 | 0.165652 | 1.000000 | 0.172066 | 0.273224 | 0.165652 | 0.102632 |
redGoldDiff | 0.014670 | -0.511119 | -0.015800 | -0.078585 | -0.378511 | -0.654148 | 0.640000 | -0.549761 | -0.281464 | -0.233875 | -0.162943 | -0.294060 | -0.816803 | -0.653538 | -0.717968 | -0.450497 | -0.167510 | -1.000000 | -0.894729 | -0.450497 | -0.816803 | 0.019042 | 0.099725 | 0.378511 | 0.640000 | -0.654148 | 0.528081 | 0.281296 | 0.234566 | 0.165611 | 0.273861 | 0.804347 | 0.652929 | 0.714405 | 0.452633 | 0.172066 | 1.000000 | 0.894729 | 0.452633 | 0.804347 |
redExperienceDiff | 0.012315 | -0.489558 | -0.027943 | -0.077946 | -0.240665 | -0.583730 | 0.577613 | -0.437002 | -0.263991 | -0.211496 | -0.162496 | -0.218320 | -0.729345 | -0.718822 | -0.800815 | -0.447264 | -0.265443 | -0.894729 | -1.000000 | -0.447264 | -0.729345 | 0.026556 | 0.085829 | 0.240665 | 0.577613 | -0.583730 | 0.422972 | 0.269283 | 0.218872 | 0.166162 | 0.197678 | 0.721190 | 0.721925 | 0.800089 | 0.437205 | 0.273224 | 0.894729 | 1.000000 | 0.437205 | 0.721190 |
redCSPerMin | -0.005118 | -0.212171 | -0.012395 | 0.040023 | -0.156711 | -0.472203 | -0.040521 | -0.337515 | -0.074838 | -0.059803 | -0.046253 | -0.186879 | -0.452593 | -0.123316 | -0.141276 | 0.000484 | 0.109806 | -0.452633 | -0.437205 | 0.000484 | -0.452593 | -0.021842 | 0.128062 | 0.156711 | -0.040521 | -0.472203 | -0.078234 | 0.129705 | 0.103151 | 0.083087 | 0.092564 | 0.278715 | 0.489672 | 0.558985 | 1.000000 | 0.165652 | 0.452633 | 0.437205 | 1.000000 | 0.278715 |
redGoldPerMin | -0.010622 | -0.411396 | -0.005685 | -0.067467 | -0.301479 | -0.161127 | 0.885728 | -0.133948 | -0.216616 | -0.192871 | -0.109557 | -0.122465 | -0.314212 | -0.440031 | -0.485059 | -0.447904 | -0.182167 | -0.804347 | -0.721190 | -0.447904 | -0.314212 | 0.010666 | 0.070784 | 0.301479 | 0.885728 | -0.161127 | 0.736215 | 0.228861 | 0.178168 | 0.151762 | 0.327503 | 1.000000 | 0.614025 | 0.669646 | 0.278715 | 0.102632 | 0.804347 | 0.721190 | 0.278715 | 1.000000 |
-blue kill 과 red death (반대도 마찬가지), firstblood 간의 관계는 대척 관계이므로 모두 변수에 넣는다면 다중공선성 발생
sns.histplot(data=df, x='blueGoldDiff', hue='blueWins', palette='RdBu', kde=True)
<matplotlib.axes._subplots.AxesSubplot at 0x1d802543a08>
- blueGoldDiff 변수에 따라 승패가 명확하게 갈린다.
sns.histplot(data=df, x='blueKills', hue='blueWins', palette='RdBu', kde=True, bins=8)
<matplotlib.axes._subplots.AxesSubplot at 0x1d803583308>
- blue kills 어느정도 상관성이 있음
sns.jointplot(data=df, x='blueKills', y='blueGoldDiff', hue='blueWins')
<seaborn.axisgrid.JointGrid at 0x1d8036438c8>
- 두 가지 feature가 상보적이다. 상관성이 높다.
sns.jointplot(data=df, x='blueExperienceDiff', y='blueGoldDiff', hue='blueWins')
<seaborn.axisgrid.JointGrid at 0x1d80376dbc8>
- 골드 수급과 경험치 수급은 상관관계가 아주 높다. (당연하게도)
sns.countplot(data=df, x='blueDragons', hue='blueWins', palette='RdBu')
<matplotlib.axes._subplots.AxesSubplot at 0x1d804886508>
sns.countplot(data=df, x='redDragons', hue='blueWins', palette='RdBu')
<matplotlib.axes._subplots.AxesSubplot at 0x1d8048ca0c8>
- blue가 Dragons을 죽였을때 승리확률이 높음
- red는 Dragons 죽이든 죽이지 않든 승패에 크게 영향을 미치지 않음. Dragons의 경우 red보다 Blue에 더 영향을 미침.
sns.countplot(data=df, x='blueFirstBlood', hue='blueWins',palette='RdBu')
<matplotlib.axes._subplots.AxesSubplot at 0x1d80493b848>
- blue 첫 킬을 달성한다면 blue가 이기는 사건이 많음. 반대도 마찬가지, 균형이 맞는 변수.
데이터 전처리
# 수치형 데이터 표준화
from sklearn.preprocessing import StandardScaler
df.columns
Index(['gameId', 'blueWins', 'blueWardsPlaced', 'blueWardsDestroyed',
'blueFirstBlood', 'blueKills', 'blueDeaths', 'blueAssists',
'blueEliteMonsters', 'blueDragons', 'blueHeralds',
'blueTowersDestroyed', 'blueTotalGold', 'blueAvgLevel',
'blueTotalExperience', 'blueTotalMinionsKilled',
'blueTotalJungleMinionsKilled', 'blueGoldDiff', 'blueExperienceDiff',
'blueCSPerMin', 'blueGoldPerMin', 'redWardsPlaced', 'redWardsDestroyed',
'redFirstBlood', 'redKills', 'redDeaths', 'redAssists',
'redEliteMonsters', 'redDragons', 'redHeralds', 'redTowersDestroyed',
'redTotalGold', 'redAvgLevel', 'redTotalExperience',
'redTotalMinionsKilled', 'redTotalJungleMinionsKilled', 'redGoldDiff',
'redExperienceDiff', 'redCSPerMin', 'redGoldPerMin'],
dtype='object')
# 다중공선성을 불러일으킬만한 변수 제거
df.drop(['gameId','redFirstBlood', 'redKills', 'redDeaths', 'redAssists',
'redTotalGold', 'redTotalExperience', 'redGoldDiff','redExperienceDiff'], axis=1, inplace=True)
df.columns
Index(['blueWins', 'blueWardsPlaced', 'blueWardsDestroyed', 'blueFirstBlood',
'blueKills', 'blueDeaths', 'blueAssists', 'blueEliteMonsters',
'blueDragons', 'blueHeralds', 'blueTowersDestroyed', 'blueTotalGold',
'blueAvgLevel', 'blueTotalExperience', 'blueTotalMinionsKilled',
'blueTotalJungleMinionsKilled', 'blueGoldDiff', 'blueExperienceDiff',
'blueCSPerMin', 'blueGoldPerMin', 'redWardsPlaced', 'redWardsDestroyed',
'redEliteMonsters', 'redDragons', 'redHeralds', 'redTowersDestroyed',
'redAvgLevel', 'redTotalMinionsKilled', 'redTotalJungleMinionsKilled',
'redCSPerMin', 'redGoldPerMin'],
dtype='object')
X_num = df[['blueWardsPlaced', 'blueWardsDestroyed',
'blueKills', 'blueDeaths', 'blueAssists', 'blueEliteMonsters',
'blueTowersDestroyed', 'blueTotalGold',
'blueAvgLevel', 'blueTotalExperience', 'blueTotalMinionsKilled',
'blueTotalJungleMinionsKilled', 'blueGoldDiff', 'blueExperienceDiff',
'blueCSPerMin', 'blueGoldPerMin', 'redWardsPlaced', 'redWardsDestroyed',
'redEliteMonsters', 'redTowersDestroyed',
'redAvgLevel', 'redTotalMinionsKilled', 'redTotalJungleMinionsKilled',
'redCSPerMin', 'redGoldPerMin']]
X_cat = df[['blueFirstBlood', 'blueDragons', 'blueHeralds', 'redDragons', 'redHeralds']]
scaler = StandardScaler()
scaler.fit(X_num)
X_scaled = scaler.transform(X_num)
X_scaled = pd.DataFrame(X_scaled, index=X_num.index, columns=X_num.columns)
X = pd.concat([X_scaled, X_cat], axis=1)
y = df['blueWins']
X
blueWardsPlaced | blueWardsDestroyed | blueKills | blueDeaths | blueAssists | blueEliteMonsters | blueTowersDestroyed | blueTotalGold | blueAvgLevel | blueTotalExperience | blueTotalMinionsKilled | blueTotalJungleMinionsKilled | blueGoldDiff | blueExperienceDiff | blueCSPerMin | blueGoldPerMin | redWardsPlaced | redWardsDestroyed | redEliteMonsters | redTowersDestroyed | redAvgLevel | redTotalMinionsKilled | redTotalJungleMinionsKilled | redCSPerMin | redGoldPerMin | blueFirstBlood | blueDragons | blueHeralds | redDragons | redHeralds | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 0.316996 | -0.379275 | 0.935301 | -0.046926 | 1.071495 | -0.879231 | -0.210439 | 0.460179 | -1.035635 | -0.740639 | -0.992782 | -1.465951 | 0.256228 | 0.013342 | -0.992782 | 0.460179 | -0.399207 | 1.532493 | -0.914893 | -0.198353 | -0.410475 | -0.928741 | 0.367685 | -0.928741 | 0.052293 | 1 | 0 | 0 | 0 | 0 |
1 | -0.570992 | -0.839069 | -0.393216 | -0.387796 | -0.404768 | -0.879231 | -0.210439 | -1.166792 | -1.035635 | -1.385391 | -1.953558 | -0.758722 | -1.191254 | -0.593342 | -1.953558 | -1.166792 | -0.561751 | -0.805870 | 2.277700 | 4.412301 | -0.410475 | 1.033784 | 0.068504 | 1.033784 | 0.758619 | 0 | 0 | 0 | 1 | 1 |
2 | -0.404494 | -1.298863 | 0.271042 | 1.657424 | -0.650812 | 0.719503 | -0.210439 | -0.254307 | -1.691092 | -1.422043 | -1.404543 | -0.455624 | -0.483614 | -0.520436 | -1.404543 | -0.254307 | -0.399207 | 0.129475 | -0.914893 | -0.198353 | -0.410475 | -0.654900 | -2.324944 | -0.654900 | 0.533909 | 0 | 1 | 0 | 0 | 0 |
3 | 1.149484 | -0.839069 | -0.725346 | -0.387796 | -0.404768 | 0.719503 | -0.210439 | -0.876959 | 0.275280 | 0.021567 | -0.718275 | 0.453671 | -0.544350 | 0.013863 | -0.718275 | -0.876959 | -0.399207 | -0.338198 | -0.914893 | -0.198353 | 0.244627 | 0.805583 | -0.430131 | 0.805583 | -0.007406 | 0 | 0 | 1 | 0 | 0 |
4 | 2.925460 | 0.540312 | -0.061087 | -0.046926 | -0.158724 | -0.879231 | -0.210439 | -0.067382 | 0.275280 | 0.512211 | -0.306513 | 0.655736 | -0.415133 | 0.137283 | -0.306513 | -0.067382 | -0.290844 | -0.338198 | 0.681403 | -0.198353 | 0.244627 | 0.349182 | 1.564408 | 0.349182 | 0.613731 | 0 | 0 | 0 | 1 | 0 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
9874 | -0.293496 | -0.379275 | 0.271042 | -0.728666 | -0.404768 | 0.719503 | -0.210439 | 0.821656 | 0.930738 | 0.865408 | -0.260762 | 1.868129 | 1.020936 | 1.303263 | -0.260762 | 0.821656 | 1.280419 | 0.129475 | -0.914893 | -0.198353 | -0.410475 | 0.531742 | -1.726582 | 0.531742 | -0.833801 | 1 | 1 | 0 | 0 | 0 |
9875 | 1.759976 | -1.298863 | -0.061087 | -0.728666 | 0.333364 | 0.719503 | -0.210439 | -0.172894 | 0.930738 | 1.105315 | 0.745765 | -0.253559 | 0.312888 | 0.479942 | 0.745765 | -0.172894 | -0.561751 | 8.547582 | -0.914893 | -0.198353 | 0.244627 | -0.517980 | 0.467412 | -0.517980 | -0.692938 | 0 | 1 | 0 | 0 | 0 |
9876 | 0.039499 | -0.839069 | -0.061087 | 0.293944 | -0.404768 | -0.879231 | -0.210439 | -0.391082 | 0.275280 | 0.086541 | -0.306513 | -0.556657 | -0.990702 | -0.959957 | -0.306513 | -0.391082 | -0.453388 | -1.273543 | 0.681403 | -0.198353 | 1.554831 | 1.992226 | 0.866319 | 1.992226 | 1.227490 | 0 | 0 | 0 | 1 | 0 |
9877 | -0.459994 | 0.540312 | -1.389604 | -1.069536 | -0.896856 | 0.719503 | -0.210439 | -1.331573 | -1.035635 | -0.582367 | 0.334004 | -0.253559 | -0.347874 | -0.547516 | 0.334004 | -1.331573 | 2.364049 | 0.597148 | -0.914893 | -0.198353 | 0.899729 | 1.353264 | -1.128220 | 1.353264 | -0.798921 | 1 | 1 | 0 | 0 | 0 |
9878 | -0.237997 | -1.298863 | -0.061087 | -0.046926 | -0.404768 | -0.879231 | -0.210439 | -0.154657 | 0.275280 | -0.505730 | -0.443767 | -0.657690 | 0.371994 | -0.012696 | -0.443767 | -0.154657 | -0.724295 | -0.338198 | 0.681403 | -0.198353 | -0.410475 | -0.746180 | -0.529858 | -0.746180 | -0.771419 | 1 | 0 | 0 | 1 | 0 |
9879 rows × 30 columns
학습 테스트 데이터 분리
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=1)
분류하기
회귀분석 모델
from sklearn.linear_model import LogisticRegression
model_lr = LogisticRegression()
model_lr.fit(X_train, y_train)
LogisticRegression(C=1.0, class_weight=None, dual=False, fit_intercept=True,
intercept_scaling=1, l1_ratio=None, max_iter=100,
multi_class='auto', n_jobs=None, penalty='l2',
random_state=None, solver='lbfgs', tol=0.0001, verbose=0,
warm_start=False)
from sklearn.metrics import classification_report
pred = model_lr.predict(X_test)
print(classification_report(y_test, pred))
precision recall f1-score support
0 0.73 0.75 0.74 1469
1 0.75 0.73 0.74 1495
accuracy 0.74 2964
macro avg 0.74 0.74 0.74 2964
weighted avg 0.74 0.74 0.74 2964
앙상블 모델 적용(XGBoost)
from xgboost import XGBClassifier
model_xgb = XGBClassifier()
model_xgb.fit(X_train, y_train)
C:\Users\dissi\anaconda31\lib\site-packages\xgboost\sklearn.py:888: UserWarning: The use of label encoder in XGBClassifier is deprecated and will be removed in a future release. To remove this warning, do the following: 1) Pass option use_label_encoder=False when constructing XGBClassifier object; and 2) Encode your labels (y) as integers starting with 0, i.e. 0, 1, 2, ..., [num_class - 1].
warnings.warn(label_encoder_deprecation_msg, UserWarning)
[15:25:49] WARNING: C:/Users/Administrator/workspace/xgboost-win64_release_1.3.0/src/learner.cc:1061: Starting in XGBoost 1.3.0, the default evaluation metric used with the objective 'binary:logistic' was changed from 'error' to 'logloss'. Explicitly set eval_metric if you'd like to restore the old behavior.
XGBClassifier(base_score=0.5, booster='gbtree', colsample_bylevel=1,
colsample_bynode=1, colsample_bytree=1, gamma=0, gpu_id=-1,
importance_type='gain', interaction_constraints='',
learning_rate=0.300000012, max_delta_step=0, max_depth=6,
min_child_weight=1, missing=nan, monotone_constraints='()',
n_estimators=100, n_jobs=4, num_parallel_tree=1,
objective='binary:logistic', random_state=0, reg_alpha=0,
reg_lambda=1, scale_pos_weight=1, subsample=1,
tree_method='exact', use_label_encoder=True,
validate_parameters=1, verbosity=None)
pred = model_xgb.predict(X_test)
print(classification_report(y_test, pred))
precision recall f1-score support
0 0.71 0.71 0.71 1469
1 0.72 0.72 0.72 1495
accuracy 0.72 2964
macro avg 0.72 0.72 0.72 2964
weighted avg 0.72 0.72 0.72 2964
모델평가
회귀분석 모델
model_coef = pd.DataFrame(data=model_lr.coef_[0], index=X.columns, columns=['model coefficient'])
model_coef.sort_values(by='model coefficient', inplace=True)
plt.figure(figsize=(12, 10))
plt.barh(model_coef.index, model_coef['model coefficient'])
plt.show()
xgboost 모델
plt.figure(figsize=(12,10))
plt.barh(X.columns, model_xgb.feature_importances_)
plt.show()