Using Machine Learning to Predict high- performing Players in Fantasy Premier League

Roshan Thapaliya
5 min readMar 29, 2017

--

The code is at https://github.com/277roshan/MachineLearningFinalProject/blob/master/Machine%20Learning%20Final%20Project.ipynb

Fantasy Premier League is the worldwide online-based platform that allows you to select players from Premier League who you feel will perform well in a certain gameweek. The performance of the players is measure based primarily on the goals they score, assists they make, and the clean-sheets they keep. As an online player you get to make a selection of 11 players for a Gameweek. The total points these players get is your score.

I started playing the Fantasy Premier League since 2013/14 season. As a big soccer fan, I watched and followed the Premier League. I got into Fantasy Premier League because a lot of my friends used to talk about this fun online platform- a virtual spin-off of the real life Premier League soccer games.

A Fantasy Premier League dashboard looks like this. You have a budget of 100 pounds to spend on 15 players. In the first Gameweek you make your selection. After that you can transfer in one player every gameweek as a replacement for someone in your team. You also get to select a captain for your team and the points that he gets is doubled and added to your total.

It is very hard to predict which players will perform well in a certain gameweek. Since I am taking an introductory machine learning course at my university, I felt predicting players for fantasy premier league would be an interesting topic for my final project.

The problem statement for my project is to predict if a player will score more than or equal to 8 points(≥8 points) in a certain gameweek.

This will allow the Fantasy Premier League managers to decide which player they want to transfer in for a certain gameweek or which player they might consider captaining. In Fantasy Premier League if a player gets more than 7 points it is a pretty respectable score.

I got my data from

https://fantasy.premierleague.com/drf/bootstrap-static

https://fantasy.premierleague.com/drf/element-summary/[player-id]

I used the first link to get the unique id for each player. The second url was used to get the information about that particular player particularly his performance in previous gameweeks. (The data is in JSON format)

As a first shot at the problem, I used Gaussian Naive Bayes algorithm which is a pretty basic machine learning algorithm. For each player based on their previous performance, we have corresponding decision boundary.

All the players that the algorithm suggested would get ≥ 8 points in next gameweek were

Set 1

[u'Koscielny', u'Chambers', u'Chamberlain', u'Iwobi', u'Boruc', u'Cook', u'Daniels', u'Ak\xe9', u'Arter', u'Stanislas', u'Gosling', u'King', u'Heaton', u'Keane', u'F\xe0bregas', u'Willian', u'Moses', u'Dann', u'Ward', u'McArthur', u'Baines', u'Coleman', u'Dawson', u'Snodgrass', u'Maloney', u'Schmeichel', u'Mahrez', u'Sakho', u'Lovren', u'Clyne', u'Henderson', u'Man\xe9', u'Kolarov', u'Zabaleta', u'Clichy', u'Silva', u'G\xfcndogan', u'Iheanacho', u'de Gea', u'Jones', u'Shaw', u'Blind', u'Martial', u'Vald\xe9s', u'Gibson', u'Bertrand', u'van Dijk', u'Redmond', u'Ward-Prowse', u'Given', u'Shawcross', u'Adam', u'Whelan', u'Arnautovic', u'Bojan', u'Kaboul', u'Jones', u'Kon\xe9', u'Fern\xe1ndez', u'Sigurdsson', u'Fer', u'Lloris', u'Rose', u'Trippier', u'Chadli', u'Eriksen', u'Alli', u'Wanyama', u'Son', u'Janssen', u'Nyom', u'Capoue', u'Evans', u'Brunt', u'Fletcher', u'Phillips', u'Rond\xf3n', u'Randolph', u'Obiang', u'Payet', u'Feghouli', u'Negredo', u'Zu\xf1iga', u'Gueye', u'San\xe9', u'Guzan', u'Ram\xedrez', u'Llorente', u'Pogba', u'Defour', u'Fabio', u'Hendrick', u'Alonso', u'Slimani', u'Anichebe', u'Niang', u'Brady', u'Gabbiadini']

This set includes players who won’t play the next gameweek because of injury, suspension or various other reasons. We can easily disregard them from the list. I will incorporate these factors in the algorithm later on.

Players who actually scored ≥8 in next gameweek were

Set 2

[u’King’, u’Heaton’, u’Willian’, u’Mahrez’, u’Sakho’, u’Ward-Prowse’, u’Eriksen’]

We were looking at next Gameweek and because of blank gameweek for some players, we were predicting for gameweek 28 for some players and gameweek 29 for others.

King scored 18 points
Willian scored 10 points
Mahrez scored 8 points
Sakho scored 9 points
Ward-Prowse scored 10 points
Eriksen scored 9 points
Heaton scored 10 points

Players we predicted correctly/Total players * 100 = 86.0 %

Few notable picks who scored nearly 8 from Set 1

  1. Chadli scored 5
  2. Coleman scored 6
  3. Alli scored 7
  4. Boruc scored 6
  5. Cook scored 7
  6. Daniels scored 6
  7. Keane scored 6
  8. Ward scored 7
  9. Baines scored 6
  10. Coleman scored 6

86% accuracy for this particular prediction was pretty awesome. I will run the algorithm for future gameweeks and see how it fares. How players perform in a certain gameweek is very random and the algorithm might not always get such high accuracy.

Going forward I want to try some more algorithms and see how they perform against Gaussian Naive Bayes. (Any suggestions are welcome)

P.S.

For next week I have generated the following list:

[u’Koscielny’, u’Chambers’, u’Chamberlain’, u’Iwobi’, u’Daniels’, u’Ak\xe9', u’Stanislas’, u’Gray’, u’Barnes’, u’F\xe0bregas’, u’Dann’, u’Ward’, u’Zaha’, u’McArthur’, u’Townsend’, u’Baines’, u’Coleman’, u’Mirallas’, u’Barkley’, u’Dawson’, u’Snodgrass’, u’Maloney’, u’Schmeichel’, u’Fuchs’, u’Mahrez’, u’Sakho’, u’Lovren’, u’Clyne’, u’Henderson’, u’Can’, u’Milner’, u’Firmino’, u’Man\xe9', u’Kolarov’, u’Zabaleta’, u’Clichy’, u’Otamendi’, u’Silva’, u’Yaya Tour\xe9', u’Fernandinho’, u’G\xfcndogan’, u’Ag\xfcero’, u’Iheanacho’, u’de Gea’, u’Darmian’, u’Blind’, u’Martial’, u’Vald\xe9s’, u’Gibson’, u’Stuani’, u’Bertrand’, u’van Dijk’, u’Rodriguez’, u’Given’, u’Shawcross’, u’Adam’, u’Arnautovic’, u’Bojan’, u’van Aanholt’, u’Kon\xe9', u’Fern\xe1ndez’, u’Sigurdsson’, u’Fer’, u’Lloris’, u’Rose’, u’Chadli’, u’Wanyama’, u’Son’, u’Janssen’, u’Nyom’, u’Capoue’, u’Evans’, u’Brunt’, u’Fletcher’, u’Phillips’, u’Rond\xf3n’, u’Payet’, u’Feghouli’, u’Negredo’, u’Zu\xf1iga’, u’Wijnaldum’, u’Gueye’, u’San\xe9', u’Guzan’, u’Ram\xedrez’, u’Llorente’, u’Pogba’, u’Davies’, u’Defour’, u’Fabio’, u’Fraser’, u’Alonso’, u’Martins Indi’, u’Slimani’, u’Anichebe’, u’Niang’, u’Brady’]

Set still contains injured players. Will work on it.

--

--