2016欧洲杯分析:谁是最粗暴的球队

浏览: 1099

Clipboard Image.png

前言

    欧洲杯战火还在高卢人的土地上熊熊燃烧,为了不错过这场4年一战的盛会,各路豪杰也是摩拳擦掌、跃跃欲试。然而赛程过半,究竟鹿死谁手,我们拭目以待。而这一次我们不去谈论太过严肃的话题,转而通过对2016年欧洲杯犯规数据的可视化分析,来分析球队犯规的发生与其比赛结果的关系。

数据读取与处理

    我们载入所需的包,数据的获取可以到[Rstudio project I have uploaded on Github](https://github.com/AndreaCirilloAC/euro_2016_stat)下载,数据最后的更新日期是6月28日。
library(plyr)
library(dplyr)
library(choroplethr)
library(choroplethrMaps)
library(ggplot2)
library(dummies)
players_stat <- read.csv('players_stats.txt',sep = ";",header = TRUE)
players_stat$Team <- tolower(players_stat$Team)
team_stat <- read.csv('team_stats.txt' ,sep = ";",header = TRUE)
names(team_stat)[1]<- "Team"
team_stat$Team <- tolower(team_stat$Team)
possession_stat <- read.csv('possession.txt', sep = ";",header = TRUE)
names(possession_stat)[1]<- "time"
possession_stat$team <- tolower(possession_stat$team)

哪个队犯规最多?

    我们运用地图可视化方法来展示。会用到choroplethr包中的country_choropleth()函数。choroplethr包是绘制等值线图的包,可help查看其用法。首先让我们看看各个队犯规情况。
by_team <- group_by(players_stat,Team)
team_sums <- summarise(by_team,sum(Yellow.Cards),sum(Red.Cards),sum(Fouls.Committed),sum(Fouls.Suffered))
team_sums


fouls_data <- data.frame("region" = team_sums$Team,"value" = team_sums$`sum(Fouls.Committed)`)
# plotfouls_plot <- country_choropleth(fouls_data,title = "number of Fouls Committed by region",legend = "# fouls",num_colors = 1) +xlim(-31.266001, 39.869301) +ylim(27.636311, 81.008797) +coord_map("lambert", lat0 = 20, lat1 = 88)
fouls_plot


   由图可以发现罗马尼亚应该是“最暴力”的球队了,让我们再拿犯规的红黄牌barplot来看个究竟。
ggplot(team_sums,aes(x = Team,y = `sum(Yellow.Cards)`, fill = `sum(Yellow.Cards)` )) +
 geom_bar(stat = 'identity') +
 coord_flip()


    确实,罗马尼亚和阿尔巴尼亚黄牌数“数一数二”。而红牌数只有阿尔巴尼亚和奥地利获得。而纵观所有数据,可以确定罗马尼亚和阿尔巴尼亚应该是目前为止欧洲杯上“最粗暴的球队了”。

犯规次数多是否可以帮助赢得比赛呢?

    为了回答这个技术问题,我们尝试绘制犯规总次数与球队赢球的散点图,来直观看看二者关系:
ggplot(team_stat,aes(x = team_sums$`sum(Fouls.Committed)`,y = team_stat$Wins, label = Team)) + 
 geom_point() +
 geom_text(nudge_y = 0.1) +
 geom_smooth(method = 'lm', formula = y~x)


   由图可以看出,似乎犯规越多球队取胜的次数越少,但好像由于冰岛这个极值的影响,使得回归模型出现了偏移。我们删除这个高杠杆值后,再来绘图。
team_stat2 <- team_stat[team_stat$Team != "iceland",]team_sums2 <- team_sums[team_sums$Team != "iceland",]ggplot(team_stat2,aes(x = team_sums2$`sum(Fouls.Committed)`,y = team_stat2$Wins, label = Team)) + 
 geom_point() +
 geom_text(nudge_y = 0.1) +
 geom_smooth(method = 'lm', formula = y~x)


    这回我们发现其实犯规次数与是否赢球基本无相关关系。让我们再来考虑一个似乎合情合理的假设:犯规可减少失球率。

犯规次数多点是否可以减少失球率呢?

还是拿数据说话,绘制犯规次数与失球率的散点图:
ggplot(team_stat,aes(x = team_sums$`sum(Fouls.Committed)`,                       y = team_stat$Total.goals.against, label = Team)) +
 geom_point() +
 geom_text(nudge_y = 0.1) +
 geom_smooth(method = 'lm', formula = y~x)



  最后图形的结论与我们的假设基本一致,犯规次数与失球率呈负相关,犯规越多,失球越少。似乎也是有道理的,大量的犯规使一些威胁球得到化解。

说明

本文是对Andrea Cirillo:Euro 2016 analytics: Who’s playing the toughest game?的部分进行了翻译,仅供学习和参考。
推荐 0
本文由 余文华 创作,采用 知识共享署名-相同方式共享 3.0 中国大陆许可协议 进行许可。
转载、引用前需联系作者,并署名作者且注明文章出处。
本站文章版权归原作者及原出处所有 。内容为作者个人观点, 并不代表本站赞同其观点和对其真实性负责。本站是一个个人学习交流的平台,并不用于任何商业目的,如果有任何问题,请及时联系我们,我们将根据著作权人的要求,立即更正或者删除有关内容。本站拥有对此声明的最终解释权。

0 个评论

要回复文章请先登录注册