Note : This analysis is done on the stats available in Understat website from 2014-2020 and only the club stats were taken into consideration.
In this project I have tried to compare the different stats of two different soccer players to compare their performance and know who comes out on top.
Concepts needed: Numpy, Pandas, Visualization, Web Scraping, Data Cleaning, EDA
Libraries Used: json, pandas, BeautifulSoup, urlopen, MinMaxScaler, Seaborn, Matplotlib, Plotly
- Getting the required data from Undestat website
- Data Cleaning and Exploration for different aspects of the players
- Comparative analysis
- Shots analysis
- Final Comparison
First I scraped the players’ season wise data from the understat website. Then, I combined both the player’s data into a single dataframe. Then, I cleaned the data and removed null and error values. I also perform Exploratory data analysis to summarize their main characteristics. The visual EDA helped in drawing meaningful patterns and insights. The visual EDA for the Consolidated Data for all seasons per player is given below.
xG → Expected Goals
npg → Non Penalty Goals
xGChain --> Calculating xG for possessions that lead to a shot where the player was involved at least once in that possession, INCLUDING the final pass or the shot.
xGBuildup --> Calculating xG for possessions that lead to a shot where the player was involved at least once in that possession, EXCLUDING the final pass or the shot.
Then, I performed EDA on Season-wise Stats (Consolidated data per season per player).
Then, performed EDA on different factors like Shots and Assisting Player Comparison. The results are shown below.
It was interesting to note that both players have had a fruitful relationship with their respective left-backs.
Then, performed a comparison between Shots vs Goals and plotted it using a Scatter Plot.
It was clearly observed that Lionel Messi had a better Goals to Shot ratio than Cristiano Ronaldo.
Then, a comparison between Total Goals vs Non-penalty Goals was done. It was also plotted using the scatter plot.
From the graph, it was concluded that both Lionel Messi and Cristiano Ronaldo have almost the same ratio when comparing in 2014. But, Messi had more Non-Penalty Goals than Ronaldo in 2016,2017 and 2018.
Then, a comparison between Total Goals scored and Total Expected Goals was done for both the players.
It was observed that both the players have kept their expectations and in some seasons have even scored more goals than that was expected.
Then, a comparison between Total goals and Total Assists per Season was done.
And It was clear from the graph that Messi has a better Goals to Assist ratio which shows Messi is a better playmaker than Ronaldo.
A comparison between xGChain and xGBuildup was also done.
Then, I plotted a shot map for both the players. Below is the shot map for Cristiano Ronaldo.
Below is the shot map for Lionel Messi.
The pitch heat map for both the players was also plotted. The following is the heat map for Cristiano Ronaldo.
The following is the heat map for Lionel Messi.
The final comparison was made using the Radar Plot.
From the Radar Plot it is clear that Ronaldo has more shots than Messi and Messi has more key passes and xGChain than Ronaldo.
So, Go through the analysis and make up your mind.