├── .RData ├── .Rhistory ├── .ipynb_checkpoints └── Ideal_Team_Lineup_World_Cup_2018-checkpoint.ipynb ├── CompleteDataset.csv ├── Ideal_Team_Lineup_World_Cup_2018.ipynb ├── LICENSE ├── README.md └── images ├── Ages.png ├── Argentina-Choices.png ├── Argentina.png ├── Belgium-Choices.png ├── Belgium.png ├── Brazil-Choices.png ├── Brazil.png ├── England-Choices.png ├── England.png ├── France-Choices.png ├── France.png ├── Germany-Choices.png ├── Germany.png ├── Nationalities.png ├── Overalls.png ├── Portugal-Choices.png ├── Portugal.png ├── Positions.png ├── Spain-Choices.png ├── Spain.png ├── Top-10-Players.png ├── Top-5-Players.png ├── Values.png ├── Wages.png ├── average-rating.png ├── average-wage.png ├── cavani.jpg ├── de-bruyne.jpg ├── fifa-world-cup-2018.jpg ├── griezmann.jpeg ├── kane.jpg ├── kroos.jpeg ├── messi.jpg ├── modric.jpg ├── neymar.jpg ├── ramos.jpg ├── ronaldo.jpg └── total-value.png /.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanhnamle1994/world-cup-2018/85736566405a3dc0d10d775793ec14880c74b0bc/.RData -------------------------------------------------------------------------------- /.Rhistory: -------------------------------------------------------------------------------- 1 | # load the CSV file 2 | epl <- read.csv("epldata_final.csv") 3 | # header names 4 | names(epl) 5 | # preview the first 5 rows 6 | head(epl) 7 | # load the library 8 | library(mlbench) 9 | # load the dataset 10 | data(epl) 11 | # display first 20 rows of data 12 | head(epl, n=20) 13 | # load the CSV file 14 | epl <- read.csv("epldata_final.csv") 15 | # header names 16 | names(epl) 17 | # preview the first 6 rows 18 | head(epl, n = 20) 19 | # load the CSV file 20 | epl <- read.csv("epldata_final.csv") 21 | # header names 22 | names(epl) 23 | # preview the first 6 rows 24 | head(epl, n = 20) 25 | # load the CSV file 26 | epl <- read.csv("epldata_final.csv") 27 | # header names 28 | names(epl) 29 | # preview the first 6 rows 30 | head(epl, n = 20) 31 | # display the dimensions of the dataset 32 | dim(epl) 33 | # load library 34 | library(mlbench) 35 | # load the CSV file 36 | epl <- read.csv("epldata_final.csv") 37 | # header names 38 | names(epl) 39 | # preview the first 6 rows 40 | head(epl, n = 20) 41 | # display the dimensions of the dataset 42 | dim(epl) 43 | # list types for each attribute 44 | sapply(epl, class) 45 | # load library 46 | library(mlbench) 47 | # load the CSV file 48 | epl <- read.csv("epldata_final.csv") 49 | # header names 50 | names(epl) 51 | # preview the first 6 rows 52 | head(epl, n = 20) 53 | # display the dimensions of the dataset 54 | dim(epl) 55 | # list types for each attribute 56 | sapply(epl, class) 57 | # load library 58 | library(mlbench) 59 | # load the CSV file 60 | epl <- read.csv("epldata_final.csv") 61 | # header names 62 | names(epl) 63 | # preview the first 6 rows 64 | head(epl, n = 20) 65 | # display the dimensions of the dataset 66 | dim(epl) 67 | # list types for each attribute 68 | sapply(epl, class) 69 | # summarize the dataset 70 | summary(epl) 71 | View(epl) 72 | knitr::opts_chunk$set(echo = TRUE) 73 | library(tidyverse) 74 | install.packages("tidyverse") 75 | install.packages("tidyverse") 76 | knitr::opts_chunk$set(echo = TRUE) 77 | library(tidyverse) 78 | install.packages("tidyverse", dependencies=TRUE) 79 | knitr::opts_chunk$set(echo = TRUE) 80 | library(tidyverse) 81 | install.packages("Rcpp") 82 | install.packages("tidyverse", dependencies=TRUE) 83 | library("tidyverse", lib.loc="~/Library/R/3.3/library") 84 | install.packages("installr") 85 | library(installr) 86 | knitr::opts_chunk$set(echo = TRUE) 87 | library(tidyverse) 88 | library(forcats) 89 | epl <- read.csv("epldata_final.csv") 90 | epl <- epl %>% mutate( 91 | position_cat= as.factor(position_cat), 92 | region=as.factor(region), 93 | club_id=as.numeric(as.factor(club)), 94 | age_cat = as.factor(age_cat), 95 | big_club=ifelse(club_id %in% c(1,5,10,11,12,17),1,0) 96 | ) 97 | ageCat <- function(age){ 98 | if (age < 22)return(1) 99 | else if( age < 25)return(2) 100 | else if( age < 28)return(3) 101 | else if( age < 30)return(4) 102 | else if( age < 32)return(5) 103 | else return(6) 104 | } 105 | epl <- epl %>%rowwise() %>% mutate(age_cat=ageCat(age)) 106 | epl <- epl %>% mutate(age_cat = as.factor(age_cat)) 107 | epl <- transform(epl,age_category=cut(age,breaks=c(16,21,25,28,31,38),labels = c("17-21","22-25", 108 | "26-28","29-31","32-38"))) 109 | View(epl) 110 | View(epl) 111 | knitr::opts_chunk$set(echo = TRUE) 112 | library(tidyverse) 113 | library(forcats) 114 | epl <- epl %>%rowwise() %>% mutate(age_cat=ageCat(age)) 115 | epl <- epl %>% mutate(age_cat = as.factor(age_cat)) 116 | epl <- transform(epl,age_category=cut(age,breaks=c(16,21,25,28,31,38),labels = c("17-21","22-25", 117 | "26-28","29-31","32-38"))) 118 | View(epl) 119 | View(epl) 120 | knitr::opts_chunk$set(echo = TRUE) 121 | library(tidyverse) 122 | library(forcats) 123 | epl <- read.csv("epldata_final.csv") 124 | epl <- epl %>% mutate( 125 | position_cat= as.factor(position_cat), 126 | region=as.factor(region), 127 | club_id=as.numeric(as.factor(club)), 128 | age_cat = as.factor(age_cat), 129 | big_club=ifelse(club_id %in% c(1,5,10,11,12,17),1,0) 130 | ) 131 | ageCat <- function(age){ 132 | if (age < 22)return(1) 133 | else if( age < 25)return(2) 134 | else if( age < 28)return(3) 135 | else if( age < 30)return(4) 136 | else if( age < 32)return(5) 137 | else return(6) 138 | } 139 | epl <- epl %>%rowwise() %>% mutate(age_cat=ageCat(age)) 140 | epl <- epl %>% mutate(age_cat = as.factor(age_cat)) 141 | epl <- transform(epl,age_category=cut(age,breaks=c(16,21,25,28,31,38),labels = c("17-21","22-25", 142 | "26-28","29-31","32-38"))) 143 | temp <- epl %>% arrange(desc(age)) 144 | knitr::kable(head(temp,n=6)) 145 | temp <- epl %>% arrange(desc(age)) 146 | knitr::kable(head(temp,n=6)) 147 | temp <- epl %>% arrange(desc(age)) 148 | knitr::kable(head(temp,n=6)) 149 | epl <- read_csv("epldata_final.csv") 150 | epl <- epl %>% mutate( 151 | position_cat= as.factor(position_cat), 152 | region=as.factor(region), 153 | club_id=as.numeric(as.factor(club)), 154 | age_cat = as.factor(age_cat), 155 | big_club=ifelse(club_id %in% c(1,5,10,11,12,17),1,0) 156 | ) 157 | ageCat <- function(age){ 158 | if (age < 22)return(1) 159 | else if( age < 25)return(2) 160 | else if( age < 28)return(3) 161 | else if( age < 30)return(4) 162 | else if( age < 32)return(5) 163 | else return(6) 164 | } 165 | epl <- epl %>%rowwise() %>% mutate(age_cat=ageCat(age)) 166 | epl <- epl %>% mutate(age_cat = as.factor(age_cat)) 167 | epl <- transform(df,age_category=cut(age,breaks=c(16,21,25,28,31,38),labels = c("17-21","22-25", 168 | "26-28","29-31","32-38"))) 169 | epl <- epl %>% mutate( 170 | position_cat= as.factor(position_cat), 171 | region=as.factor(region), 172 | club_id=as.numeric(as.factor(club)), 173 | age_cat = as.factor(age_cat), 174 | big_club=ifelse(club_id %in% c(1,5,10,11,12,17),1,0) 175 | ) 176 | ageCat <- function(age){ 177 | if (age < 22)return(1) 178 | else if( age < 25)return(2) 179 | else if( age < 28)return(3) 180 | else if( age < 30)return(4) 181 | else if( age < 32)return(5) 182 | else return(6) 183 | } 184 | epl <- epl %>%rowwise() %>% mutate(age_cat=ageCat(age)) 185 | epl <- epl %>% mutate(age_cat = as.factor(age_cat)) 186 | epl <- transform(epl,age_category=cut(age,breaks=c(16,21,25,28,31,38),labels = c("17-21","22-25", 187 | "26-28","29-31","32-38"))) 188 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 James Le 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # World Cup 2018 Data Analysis 2 | 3 | In this project, I did an in-depth analysis and visualization on the FIFA18 dataset. The dataset is collected at this [GitHub Repo](https://github.com/amanthedorkknight/fifa18-all-player-statistics). The goal is to predict the best possible international squad lineups for these 10 teams: France, Germany, Spain, England, Brazil, Argentina, Belgium, Portugal, Uruguay, and Croatia at the 2018 World Cup this summer in Russia. 4 | 5 | The complete notebook can be accessed [here](http://nbviewer.jupyter.org/github/khanhnamle1994/fifa18/blob/master/Ideal_Team_Lineup_World_Cup_2018.ipynb). 6 | 7 | I also wrote an accompanied blog post: [FIFA World Cup 2018: A Data-Drive Approach to Ideal Team Line Up](https://towardsdatascience.com/fifa-world-cup-2018-a-data-driven-approach-to-ideal-team-line-ups-93505cfe36f8). 8 | 9 | ![world-cup](images/fifa-world-cup-2018.jpg) 10 | 11 | ## Dataset 12 | 13 | - Every player featuring in FIFA 18 14 | - 70+ attributes 15 | - Player and Flag Images 16 | - Playing Position Data 17 | - Attributes based on actual data of the latest EA's FIFA 18 game 18 | - Attributes include on all player style statistics like Dribbling, Aggression, GK Skills etc. 19 | - Player personal data like Nationality, Photo, Club, Age, Wage, Salary etc. 20 | 21 | The dataset contains all the statistics and playing attributes of all the players in the Full version of FIFA 18. 22 | 23 | ## Data Source 24 | 25 | The data is scraped from the website [https://sofifa.com][1] by extracting the Player personal data and Player Ids and then the playing and style statistics. 26 | 27 | ## Requirements 28 | 29 | * [Python 2.7](https://www.python.org/download/releases/2.7/) or [Python 3.6](https://www.python.org/downloads/release/python-360/) 30 | * [Jupyter Notebook](http://jupyter.org/) 31 | 32 | ## License 33 | 34 | MIT. See the LICENSE file for the copyright notice. 35 | -------------------------------------------------------------------------------- /images/Ages.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanhnamle1994/world-cup-2018/85736566405a3dc0d10d775793ec14880c74b0bc/images/Ages.png -------------------------------------------------------------------------------- /images/Argentina-Choices.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanhnamle1994/world-cup-2018/85736566405a3dc0d10d775793ec14880c74b0bc/images/Argentina-Choices.png -------------------------------------------------------------------------------- /images/Argentina.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanhnamle1994/world-cup-2018/85736566405a3dc0d10d775793ec14880c74b0bc/images/Argentina.png -------------------------------------------------------------------------------- /images/Belgium-Choices.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanhnamle1994/world-cup-2018/85736566405a3dc0d10d775793ec14880c74b0bc/images/Belgium-Choices.png -------------------------------------------------------------------------------- /images/Belgium.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanhnamle1994/world-cup-2018/85736566405a3dc0d10d775793ec14880c74b0bc/images/Belgium.png -------------------------------------------------------------------------------- /images/Brazil-Choices.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanhnamle1994/world-cup-2018/85736566405a3dc0d10d775793ec14880c74b0bc/images/Brazil-Choices.png -------------------------------------------------------------------------------- /images/Brazil.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanhnamle1994/world-cup-2018/85736566405a3dc0d10d775793ec14880c74b0bc/images/Brazil.png -------------------------------------------------------------------------------- /images/England-Choices.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanhnamle1994/world-cup-2018/85736566405a3dc0d10d775793ec14880c74b0bc/images/England-Choices.png -------------------------------------------------------------------------------- /images/England.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanhnamle1994/world-cup-2018/85736566405a3dc0d10d775793ec14880c74b0bc/images/England.png -------------------------------------------------------------------------------- /images/France-Choices.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanhnamle1994/world-cup-2018/85736566405a3dc0d10d775793ec14880c74b0bc/images/France-Choices.png -------------------------------------------------------------------------------- /images/France.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanhnamle1994/world-cup-2018/85736566405a3dc0d10d775793ec14880c74b0bc/images/France.png -------------------------------------------------------------------------------- /images/Germany-Choices.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanhnamle1994/world-cup-2018/85736566405a3dc0d10d775793ec14880c74b0bc/images/Germany-Choices.png -------------------------------------------------------------------------------- /images/Germany.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanhnamle1994/world-cup-2018/85736566405a3dc0d10d775793ec14880c74b0bc/images/Germany.png -------------------------------------------------------------------------------- /images/Nationalities.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanhnamle1994/world-cup-2018/85736566405a3dc0d10d775793ec14880c74b0bc/images/Nationalities.png -------------------------------------------------------------------------------- /images/Overalls.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanhnamle1994/world-cup-2018/85736566405a3dc0d10d775793ec14880c74b0bc/images/Overalls.png -------------------------------------------------------------------------------- /images/Portugal-Choices.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanhnamle1994/world-cup-2018/85736566405a3dc0d10d775793ec14880c74b0bc/images/Portugal-Choices.png -------------------------------------------------------------------------------- /images/Portugal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanhnamle1994/world-cup-2018/85736566405a3dc0d10d775793ec14880c74b0bc/images/Portugal.png -------------------------------------------------------------------------------- /images/Positions.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanhnamle1994/world-cup-2018/85736566405a3dc0d10d775793ec14880c74b0bc/images/Positions.png -------------------------------------------------------------------------------- /images/Spain-Choices.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanhnamle1994/world-cup-2018/85736566405a3dc0d10d775793ec14880c74b0bc/images/Spain-Choices.png -------------------------------------------------------------------------------- /images/Spain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanhnamle1994/world-cup-2018/85736566405a3dc0d10d775793ec14880c74b0bc/images/Spain.png -------------------------------------------------------------------------------- /images/Top-10-Players.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanhnamle1994/world-cup-2018/85736566405a3dc0d10d775793ec14880c74b0bc/images/Top-10-Players.png -------------------------------------------------------------------------------- /images/Top-5-Players.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanhnamle1994/world-cup-2018/85736566405a3dc0d10d775793ec14880c74b0bc/images/Top-5-Players.png -------------------------------------------------------------------------------- /images/Values.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanhnamle1994/world-cup-2018/85736566405a3dc0d10d775793ec14880c74b0bc/images/Values.png -------------------------------------------------------------------------------- /images/Wages.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanhnamle1994/world-cup-2018/85736566405a3dc0d10d775793ec14880c74b0bc/images/Wages.png -------------------------------------------------------------------------------- /images/average-rating.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanhnamle1994/world-cup-2018/85736566405a3dc0d10d775793ec14880c74b0bc/images/average-rating.png -------------------------------------------------------------------------------- /images/average-wage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanhnamle1994/world-cup-2018/85736566405a3dc0d10d775793ec14880c74b0bc/images/average-wage.png -------------------------------------------------------------------------------- /images/cavani.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanhnamle1994/world-cup-2018/85736566405a3dc0d10d775793ec14880c74b0bc/images/cavani.jpg -------------------------------------------------------------------------------- /images/de-bruyne.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanhnamle1994/world-cup-2018/85736566405a3dc0d10d775793ec14880c74b0bc/images/de-bruyne.jpg -------------------------------------------------------------------------------- /images/fifa-world-cup-2018.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanhnamle1994/world-cup-2018/85736566405a3dc0d10d775793ec14880c74b0bc/images/fifa-world-cup-2018.jpg -------------------------------------------------------------------------------- /images/griezmann.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanhnamle1994/world-cup-2018/85736566405a3dc0d10d775793ec14880c74b0bc/images/griezmann.jpeg -------------------------------------------------------------------------------- /images/kane.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanhnamle1994/world-cup-2018/85736566405a3dc0d10d775793ec14880c74b0bc/images/kane.jpg -------------------------------------------------------------------------------- /images/kroos.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanhnamle1994/world-cup-2018/85736566405a3dc0d10d775793ec14880c74b0bc/images/kroos.jpeg -------------------------------------------------------------------------------- /images/messi.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanhnamle1994/world-cup-2018/85736566405a3dc0d10d775793ec14880c74b0bc/images/messi.jpg -------------------------------------------------------------------------------- /images/modric.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanhnamle1994/world-cup-2018/85736566405a3dc0d10d775793ec14880c74b0bc/images/modric.jpg -------------------------------------------------------------------------------- /images/neymar.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanhnamle1994/world-cup-2018/85736566405a3dc0d10d775793ec14880c74b0bc/images/neymar.jpg -------------------------------------------------------------------------------- /images/ramos.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanhnamle1994/world-cup-2018/85736566405a3dc0d10d775793ec14880c74b0bc/images/ramos.jpg -------------------------------------------------------------------------------- /images/ronaldo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanhnamle1994/world-cup-2018/85736566405a3dc0d10d775793ec14880c74b0bc/images/ronaldo.jpg -------------------------------------------------------------------------------- /images/total-value.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanhnamle1994/world-cup-2018/85736566405a3dc0d10d775793ec14880c74b0bc/images/total-value.png --------------------------------------------------------------------------------