How to predict your best footballers’ FIFA 20 ratings. | by Mubarak Ganiyu | Towards Data Science

I passed the ball from Milner to Salah. Salah did a quick dribble, gave the ball to Firmino. Firmino stylishly did a 360 pass to Mane. Mane hits the ball with his left foot into the top right corner of the post. It’s a goal. Another powerful effort by a highly rated Liverpool FC team.
This feeling of being able to control your favorite players and make them do different skills in a virtual world is unfathomable. I have had some of my best experience playing FIFA. I get to see footballers do what I want them to do and have the chance to control the pace and outcome of the game which is why I was so excited to play FIFA 20.
Every year, EA sports releases a new FIFA game. This year, my favorite player, Virgil van Dijk is on the front cover. I could not just wait to install the game and use a 91 rated van Dijk to play against opponents. I was also eager to experience new in-game activities such as volta football, house rules and FIFA ultimate team.
Looking at the players’ ratings, I remembered an article (which can be found here) I wrote a while ago in which I predicted FIFA 19 players’ ratings using a machine learning algorithm. Thus, I decided to write a new article on predicting FIFA 20 players’ ratings.
This was done in two ways. Firstly, by using FIFA 20 players’ attributes. Then, by using the machine learning algorithm developed to predict the FIFA 19 players’ ratings.
The datasets that had the right attributes were found. Two datasets consisting of the 2019 FIFA ratings and the 2020 FIFA ratings were gotten from this link. After they were obtained, they were loaded and cleaned into Jupyter Notebooks. The main features that were retained for data analysis are: name, overall, age, value, wage and potential.
A scatterplot was created to find out how FIFA 20 players’ overall ratings correlated with their potential. A regression line was also built into the scatterplot.
The correlation coefficient for this scatterplot was about 0.647 which suggests that there is a moderate positive relationship between both of variables.
Below is a table showing the correlation coefficient between all the variables.
Upon reviewing other variables’ relationships with overall ratings, it has been concluded that age, wage and value also have a moderate positive relationship with overall.
The dataset was split into two groups: training and testing datasets. The training dataset retained 87.5 % of the entire dataset while the testing dataset retained 12.5 % of the entire dataset.
The purpose of splitting the dataset into two groups was to use the training dataset to learn how the independent variables (age, potential, value and wage) interacted with the dependent variable (overall). Then, the algorithm developed from this interaction was used to predict the overall ratings of the testing dataset.
Here is the code for splitting, training and testing the dataset.
import numpy as npsplit = np.random.rand(len(df_fifa1)) < 0.875train = df_fifa1[split]test = df_fifa1[~split]  regr = linear_model.LinearRegression()
## Trainig & fitting the modelfifa_x_train = train[['age','value_eur','potential','wage_eur']]fifa_y_train = train[['overall']]poly = PolynomialFeatures(degree=4)fifa_x_train_poly = poly.fit_transform(fifa_x_train)regr.fit(fifa_x_train_poly, fifa_y_train)
## Testing the modelfifa_x_test = test[['age','value_eur','potential', 'wage_eur']]fifa_y_test = test[['overall']]fifa_x_test_poly = poly.fit_transform(fifa_x_test)
Using a multiple polynomial regression with a with a degree of four, the predictions were made and its accuracy was tested by using r2-score, pearson correlation coefficient and p value.
The machine learning algorithm was significantly accurate. Its r2-score was about 97.6 %, pearson correlation coefficient of 98.8 % and a p-value of 0.
After making predictions, two tables were created to display both the training datasets’ predicted ratings and the testing datasets’ predicted ratings.
In both datasets, the player’s predicted ratings can be viewed on the first column from the right. This makes Lionel Messi’s predicted rating, 93.59, Ronaldo’s predicted rating, 93.27 and Neymar’s predicted rating, 91.00. Therefore, showing how accurate their ratings are compared to their actual ratings of 94, 93 and 92 respectively and justifying the 97.6 % accuracy of the model.
The same process that was done for generating a predictive model for FIFA 20 players’ ratings based on attributes was repeated for FIFA 19 players’ datasets. Then, the predictive model from the FIFA 19 dataset was used to generate predicted ratings for the FIFA 20 ratings using FIFA 20 players’ attributes.
The model also turned out to be accurate. It had an r-2 score of 97.4 %, pearson correlation coefficient of 98.8 % and a p-value of 0.
According to the table, most of the predicted ratings are quite close to the overall ratings. However, Marc Ter Stegen seems to be an outlier. His rating was predicted to be 104 whereas the maximum one can get is 100. UEFA player of the year, Virgil van Dijk, got a predicted rating of 92.9. His overall rating is 91. FIFA best player of the year, Lionel Messi, got a predicted rating of 92.14. His overall rating is 94.
Looking at the results of the two methods used to predict the ratings, it can be concluded that FIFA uses the same metric every year to determine players’ ratings.
The full version of the code that was used to build these predictive models can be seen here.