Fluxo
07-12-23
Criação de Indicadores com Base nas Métricas ConsideradasRedução da Complexidade de Problemas com Muitas VariáveisScout de Players com base nos Indicadores, Correlação e ClusterizaçãoImportando Bibliotecas
Carregando e Pré-Visualizando os Dados
gameid datacompleteness url league year split playoffs
1 ESPORTSTMNT06_2753012 complete LFL2 2023 Spring 0
2 ESPORTSTMNT06_2753012 complete LFL2 2023 Spring 0
date game patch participantid side position playername
1 2023-01-10 17:07:16 1 13.01 1 Blue top Wylenz
2 2023-01-10 17:07:16 1 13.01 2 Blue jng Julbu
playerid teamname
1 oe:player:60aff1184bec1d2b2efdae84f5b6e3e Klanik Esport
2 oe:player:fd78e127e45463dcfc2ea3836af0335 Klanik Esport
teamid champion ban1 ban2 ban3 ban4
1 oe:team:0ade5e44c23039bca133eee58ec1b83 Jax Sylas Caitlyn Wukong Akali
2 oe:team:0ade5e44c23039bca133eee58ec1b83 Poppy Sylas Caitlyn Wukong Akali
ban5 gamelength result kills deaths assists teamkills teamdeaths doublekills
1 Yone 2612 1 4 0 6 13 7 1
2 Yone 2612 1 2 2 4 13 7 0
triplekills quadrakills pentakills firstblood firstbloodkill firstbloodassist
1 1 0 0 0 0 0
2 0 0 0 0 0 0
firstbloodvictim team.kpm ckpm firstdragon dragons opp_dragons
1 0 0.2986 0.4594 NA NA NA
2 0 0.2986 0.4594 NA NA NA
elementaldrakes opp_elementaldrakes infernals mountains clouds oceans
1 NA NA NA NA NA NA
2 NA NA NA NA NA NA
chemtechs hextechs dragons..type.unknown. elders opp_elders firstherald
1 NA NA NA NA NA NA
2 NA NA NA NA NA NA
heralds opp_heralds firstbaron barons opp_barons firsttower towers opp_towers
1 NA NA NA 0 0 NA NA NA
2 NA NA NA 1 0 NA NA NA
firstmidtower firsttothreetowers turretplates opp_turretplates inhibitors
1 NA NA NA NA 1
2 NA NA NA NA 0
opp_inhibitors damagetochampions dpm damageshare damagetakenperminute
1 0 14283 328.0934 0.1500270 719.5406
2 0 6219 142.8560 0.0653236 847.3047
damagemitigatedperminute wardsplaced wpm wardskilled wcpm
1 878.9127 20 0.4594 5 0.1149
2 1513.9663 18 0.4135 11 0.2527
controlwardsbought visionscore vspm totalgold earnedgold earned.gpm
1 11 49 1.1256 18855 13251 304.3874
2 17 61 1.4012 12082 6478 148.8055
earnedgoldshare goldspent gspd total.cs minionkills monsterkills
1 0.295868 15955 NA 399 367 32
2 0.144640 11675 NA 159 23 136
monsterkillsownjungle monsterkillsenemyjungle cspm goldat10 xpat10 csat10
1 NA NA 9.1654 3163 4772 83
2 NA NA 3.6524 3035 3302 54
opp_goldat10 opp_xpat10 opp_csat10 golddiffat10 xpdiffat10 csdiffat10
1 3087 4814 81 76 -42 2
2 2948 3140 66 87 162 -12
killsat10 assistsat10 deathsat10 opp_killsat10 opp_assistsat10 opp_deathsat10
1 0 0 0 0 0 0
2 0 0 0 0 0 0
goldat15 xpat15 csat15 opp_goldat15 opp_xpat15 opp_csat15 golddiffat15
1 5059 7946 143 4737 7683 131 322
2 4325 4637 74 4682 5960 117 -357
xpdiffat15 csdiffat15 killsat15 assistsat15 deathsat15 opp_killsat15
1 263 12 0 0 0 0
2 -1323 -43 0 0 0 0
opp_assistsat15 opp_deathsat15
1 0 0
2 0 0
Filtrando os dados por players e ligas e mais relevantes
Verificando a quantidade de dados nulos e substituindo por 0
Em uma análise de componentes principais é comum usarmos apenas variáveis quantitativas, assim filtraremos apenas esse tipo de variável.
[1] "year" "playoffs"
[3] "game" "patch"
[5] "participantid" "gamelength"
[7] "result" "kills"
[9] "deaths" "assists"
[11] "teamkills" "teamdeaths"
[13] "doublekills" "triplekills"
[15] "quadrakills" "pentakills"
[17] "firstblood" "firstbloodkill"
[19] "firstbloodassist" "firstbloodvictim"
[21] "team.kpm" "ckpm"
[23] "firstdragon" "dragons"
[25] "opp_dragons" "elementaldrakes"
[27] "opp_elementaldrakes" "infernals"
[29] "mountains" "clouds"
[31] "oceans" "chemtechs"
[33] "hextechs" "dragons..type.unknown."
[35] "elders" "opp_elders"
[37] "firstherald" "heralds"
[39] "opp_heralds" "firstbaron"
[41] "barons" "opp_barons"
[43] "firsttower" "towers"
[45] "opp_towers" "firstmidtower"
[47] "firsttothreetowers" "turretplates"
[49] "opp_turretplates" "inhibitors"
[51] "opp_inhibitors" "damagetochampions"
[53] "dpm" "damageshare"
[55] "damagetakenperminute" "damagemitigatedperminute"
[57] "wardsplaced" "wpm"
[59] "wardskilled" "wcpm"
[61] "controlwardsbought" "visionscore"
[63] "vspm" "totalgold"
[65] "earnedgold" "earned.gpm"
[67] "earnedgoldshare" "goldspent"
[69] "gspd" "total.cs"
[71] "minionkills" "monsterkills"
[73] "monsterkillsownjungle" "monsterkillsenemyjungle"
[75] "cspm" "goldat10"
[77] "xpat10" "csat10"
[79] "opp_goldat10" "opp_xpat10"
[81] "opp_csat10" "golddiffat10"
[83] "xpdiffat10" "csdiffat10"
[85] "killsat10" "assistsat10"
[87] "deathsat10" "opp_killsat10"
[89] "opp_assistsat10" "opp_deathsat10"
[91] "goldat15" "xpat15"
[93] "csat15" "opp_goldat15"
[95] "opp_xpat15" "opp_csat15"
[97] "golddiffat15" "xpdiffat15"
[99] "csdiffat15" "killsat15"
[101] "assistsat15" "deathsat15"
[103] "opp_killsat15" "opp_assistsat15"
[105] "opp_deathsat15"
Removendo variáveis que tem variabilidade igual zero, ou seja, que todas as métricas são iguais
year playoffs game
0.0 0.1 0.9
patch participantid gamelength
0.3 8.2 112793.1
result kills deaths
0.3 7.2 3.6
assists teamkills teamdeaths
20.6 51.0 51.0
doublekills triplekills quadrakills
0.3 0.1 0.0
pentakills firstblood firstbloodkill
0.0 0.1 0.1
firstbloodassist firstbloodvictim team.kpm
0.1 0.1 0.1
ckpm firstdragon dragons
0.1 0.0 0.0
opp_dragons elementaldrakes opp_elementaldrakes
0.0 0.0 0.0
infernals mountains clouds
0.0 0.0 0.0
oceans chemtechs hextechs
0.0 0.0 0.0
dragons..type.unknown. elders opp_elders
0.0 0.0 0.0
firstherald heralds opp_heralds
0.0 0.0 0.0
firstbaron barons opp_barons
0.0 0.1 0.1
firsttower towers opp_towers
0.0 0.0 0.0
firstmidtower firsttothreetowers turretplates
0.0 0.0 0.0
opp_turretplates inhibitors opp_inhibitors
0.0 0.2 0.2
damagetochampions dpm damageshare
82709552.7 63023.2 0.0
damagetakenperminute damagemitigatedperminute wardsplaced
67568.1 216160.8 342.8
wpm wardskilled wcpm
0.3 39.0 0.0
controlwardsbought visionscore vspm
27.1 941.9 0.7
totalgold earnedgold earned.gpm
11737986.1 9502998.3 7778.9
earnedgoldshare goldspent gspd
0.0 10303172.2 0.0
total.cs minionkills monsterkills
11482.2 14380.0 3106.2
monsterkillsownjungle monsterkillsenemyjungle cspm
509.7 11.4 10.1
goldat10 xpat10 csat10
2144717.0 3292647.4 1422.1
opp_goldat10 opp_xpat10 opp_csat10
2144751.7 3292681.9 1422.1
golddiffat10 xpdiffat10 csdiffat10
198045.7 126140.4 98.5
killsat10 assistsat10 deathsat10
0.4 0.8 0.3
opp_killsat10 opp_assistsat10 opp_deathsat10
0.4 0.8 0.3
goldat15 xpat15 csat15
5496502.4 8571258.2 3653.3
opp_goldat15 opp_xpat15 opp_csat15
5496543.0 8571303.6 3653.3
golddiffat15 xpdiffat15 csdiffat15
655736.3 354794.2 220.0
killsat15 assistsat15 deathsat15
0.9 2.0 0.7
opp_killsat15 opp_assistsat15 opp_deathsat15
0.9 2.0 0.7
Excluindo variáveis que restaram e qua não fazem sentido fazer parte da ACP
Separando métricas por categorias
{
coletivo = c("result" , "teamkills" , "teamdeaths" , "team.kpm")
individual = c("kills" , "deaths" , "assists" ,
"doublekills" , "triplekills" , "quadrakills" , "pentakills" ,
"firstblood" , "firstbloodkill" , "firstbloodassist" , "firstbloodvictim" ,
"ckpm", "damagetochampions" , "dpm" , "damageshare" , "damagetakenperminute" , "damagemitigatedperminute")
objetivos = c( "barons" , "opp_barons" , "inhibitors" , "opp_inhibitors" )
estrategia = c( "wardsplaced" , "wpm" , "wardskilled" , "wcpm" , "controlwardsbought" ,
"visionscore" , "vspm" )
recursos = c("totalgold" , "earnedgold" , "earned.gpm" , "earnedgoldshare" , "goldspent" , "total.cs" , "minionkills" , "monsterkills"
, "monsterkillsownjungle" , "monsterkillsenemyjungle" , "cspm" )
vs = c( "goldat10" , "xpat10" ,
"csat10" , "opp_goldat10" , "opp_xpat10" , "opp_csat10" , "killsat10" ,
"assistsat10" , "deathsat10" , "opp_killsat10" , "opp_assistsat10" , "opp_deathsat10" ,
"goldat15" , "xpat15" , "csat15" , "opp_goldat15" , "opp_xpat15" ,
"opp_csat15" , "killsat15" , "assistsat15" , "deathsat15" , "opp_killsat15" ,
"opp_assistsat15" , "opp_deathsat15" )
report = c("goldat10","csat10" , "opp_goldat10","opp_csat10","goldat15" , "csat15" ,"opp_goldat15" ,"opp_csat15",
"kills" , "deaths" , "assists" , "damageshare","dpm" ,"vspm" ,"cspm","wpm","wcpm","totalgold")
}Selecionando as categorias para aplicação da técnica PCA
Visualizando os Componentes
mat = (acpcor$loadings[,1:5])
p <- heatmaply(round(mat,2),
dendrogram = "none",
xlab = "", ylab = "",
main = "",
scale = "column",
margins = c(60,100,40,20),
grid_color = "white",
grid_width = 0.00001,
titleX = FALSE,
hide_colorbar = TRUE,
branches_lwd = 0.1,
#labCol = colnames(mat),
#labRow = rownames(mat),
heatmap_layers = theme(axis.line=element_blank()),
col = colorRampPalette(c("#FFCC00","#FF9900",
"#FF6600","#FF3300","#FF0000"))(100),
na.rm = T,cellnote = round(mat,2)
,cellnote_size = 10,cellnote_textposition = "middle center")
pAtribuindo e Visualizando os Indicadores de Desempenho dos Jogadores
playername position comp1 comp2 comp3 comp4
90517 Cabochard top 1.0131218 1.12557711 -1.7840841 -0.07665366
32415 Megumiin mid 2.0229472 1.51849961 -2.1519201 -0.91393050
57742 Kaiser sup -3.1993720 2.95520990 -0.1660689 -0.16224906
53492 1116 mid 2.5154117 0.64932274 0.7716631 1.18995874
65647 Lamabear jng 1.5923575 0.83805307 0.1278154 -1.19544018
41473 Poss top 2.3745301 1.08079665 -2.3584177 -0.36220051
55110 Rest top 2.3351196 0.29566399 -0.4567987 1.06986991
117343 Stefan jng 0.9607217 1.63671317 -0.6641658 -0.31447198
107793 NinjaKiwi bot 3.1974384 0.31024417 0.5437928 0.30121008
115989 Worst bot 3.0967350 -0.04906406 -0.8307133 -0.11335895
33991 Sheiden jng 1.2836784 1.00381471 -1.2143635 0.78605069
72620 twohoyrz mid 3.0901028 1.02810752 -0.6669905 0.06831494
47023 Perry jng 0.4773769 0.86931449 0.2298968 1.69672922
47610 Breathe top -3.0517829 -2.60346189 -1.0383228 -0.98851824
80260 Ayu bot 2.5905032 0.57544293 -0.6027779 0.05413734
avg_comp = dados |> filter(league == 'CBLOL' | league == 'CBLOLA') |> group_by(playername,playerid) |> select(comp1,comp2,comp3,comp4,comp5) |> summarise_all(mean)
qtd_part = dados |> filter(league == 'CBLOL' | league == 'CBLOLA') |> group_by(playername,playerid) |> summarise(qtd = n())
players = merge(avg_comp,qtd_part,by = c('playername','playerid'))
sel = players |> filter(qtd >= quantile(players$qtd,.5)) |> top_n(10,comp1) %>% select(playername,comp1) |> arrange(-comp1)
ggplot(data = sel, mapping = aes(x = reorder(playername,+comp1), y = comp1, fill = playername))+
labs(title = "comp1")+
xlab("")+ ylab("")+
geom_bar(stat = "identity")+
theme(legend.position = "none",panel.background = element_rect(fill = "#17202A"),plot.title = element_text(hjust = 0.5),axis.text.x = element_blank(), panel.grid = element_blank())+
geom_text(aes(label = round(comp1,3)), vjust = 0.5,hjust = 1,color = "white")+
coord_flip()sel = players |> filter(qtd >= quantile(players$qtd,.5)) |> top_n(10,comp2) %>% select(playername,comp2) |> arrange(-comp2)
ggplot(data = sel, mapping = aes(x = reorder(playername,+comp2), y = comp2, fill = playername))+
labs(title = "comp2")+
xlab("")+ ylab("")+
geom_bar(stat = "identity")+
theme(legend.position = "none",panel.background = element_rect(fill = "#17202A"),plot.title = element_text(hjust = 0.5),axis.text.x = element_blank(), panel.grid = element_blank())+
geom_text(aes(label = round(comp2,3)), vjust = 0.5,hjust = 1,color = "white")+
coord_flip()sel = players |> filter(qtd >= quantile(players$qtd,.5)) |> top_n(10,comp3) %>% select(playername,comp3) |> arrange(-comp3)
ggplot(data = sel, mapping = aes(x = reorder(playername,+comp3), y = comp3, fill = playername))+
labs(title = "comp3")+
xlab("")+ ylab("")+
geom_bar(stat = "identity")+
theme(legend.position = "none",panel.background = element_rect(fill = "#17202A"),plot.title = element_text(hjust = 0.5),axis.text.x = element_blank(), panel.grid = element_blank())+
geom_text(aes(label = round(comp3,3)), vjust = 0.5,hjust = 1,color = "white")+
coord_flip()sel = players |> filter(qtd >= quantile(players$qtd,.5)) |> top_n(10,comp4) %>% select(playername,comp4) |> arrange(-comp4)
ggplot(data = sel, mapping = aes(x = reorder(playername,+comp4), y = comp4, fill = playername))+
labs(title = "comp4")+
xlab("")+ ylab("")+
geom_bar(stat = "identity")+
theme(legend.position = "none",panel.background = element_rect(fill = "#17202A"),plot.title = element_text(hjust = 0.5),axis.text.x = element_blank(), panel.grid = element_blank())+
geom_text(aes(label = round(comp4,3)), vjust = 0.5,hjust = 1,color = "white")+
coord_flip()sel = players |> filter(qtd >= quantile(players$qtd,.5)) |> top_n(10,comp5) %>% select(playername,comp5) |> arrange(-comp5)
ggplot(data = sel, mapping = aes(x = reorder(playername,+comp5), y = comp5, fill = playername))+
labs(title = "comp5")+
xlab("")+ ylab("")+
geom_bar(stat = "identity")+
theme(legend.position = "none",panel.background = element_rect(fill = "#17202A"),plot.title = element_text(hjust = 0.5),axis.text.x = element_blank(), panel.grid = element_blank())+
geom_text(aes(label = round(comp5,3)), vjust = 0.5,hjust = 1,color = "white")+
coord_flip()