How To Create Fantasy Premier League Account
EPL Fantasy Blog
How our AI got Top 10 in the Fantasy Premier League using Data Science
Our Moneyball approach to the EPL Fantasy League
Note: This is our main project summary from 2019. For 2020 weekly updates please check out some of my more recent blogs on the EPL Fantasy League.
My friend (Andrew Sproul) and I have been playing the Official Fantasy English Premier League game f o r many years, and despite our firm belief that we know everything about English soccer, we tend to get "unlucky" year after year and somehow never seem to pick the winning team. So, we finally decided to apply Data Science and a "Moneyball" approach to team/player analysis in order to figure out if we were actually picking the best possible combination of players each season. Our research started by pulling the most up-to-date player stats from the Fantasy Game API and running statistical analysis on all the EPL teams and all individual players using Python. The final goal of our project was to write a Python Algorithm, which uses the data from our analysis to make "smart" picks and build the most optimal Fantasy League squad given our limited budget of 100MM.
Note: Most optimal Fantasy squad will be measured in terms of the total amount of Fantasy points returned per Fantasy dollars spent = ROI.
Our analysis will be guided by the following hypothesis and aims to answer the key questions below:
- Main hypothesis to test:
- Most recreational EPL Fantasy players use personal bias and favoritism when picking their squad for their Fantasy teams. In other words, people typically base their decisions on which teams they support and on which EPL players are the "hottest" at the moment and do not look at individual players as long-term investments and their ROI per Fantasy dollar spent.
- We believe that if we remove bias and favoritism from the decision-making process and focus on individual player stats and overall team performance when picking our Fantasy squad, we can do much better overall than the Average Joe at the end of the season.
2. Key questions our analysis aims to answer:
- Is there a correlation between individual player Fantasy League stats, their team's total points in the English Premier League, and that team's corresponding table position?
- Can we identify the teams that have a lot of under-performing, overpriced players and those that have a very solid but undervalued squad, so we can tell our algorithm to pick from these teams accordingly? (Note: "undervalued" and "overvalued" is measured in terms of Fantasy League costs and not on the actual player value in the real world.)
- Can we approach the Official English Premier League Fantasy game as an equivalent of the stock market and look at individual players as financial assets and try to find all the underpriced and overpriced players based on their ROI and invest our Fantasy dollars budget accordingly?
Individual Player ROI = Player Fantasy points / Player Fantasy Cost (in other words our total points return per 1MM Fantasy-dollars spent on a player.)
- Our theory is that this can help spend our limited Fantasy League budget of 100MM on players that will generate the maximum number of points possible per Fantasy Dollar spent throughout the length of the season.
- If that turns out to be true, can we then use Python to build an algorithm that optimizes the use of our budget by picking as many of the high ROI players as possible combined with some of the expensive superstars to maximize total points returned per total budget spent?
- How does our Algorithm stack against the average person who plays the EPL Fantasy game? What overall ranking did our team achieve and did they beat the average player by a significant margin?
Note: This project was executed on Nov 14th, 2018, after Gameweek 10, so all the data and tables presented in the article are accurate up to that date.
Main Steps of Our Procedure Below:
1. Looking at individual team stats
First, we started by arranging all the Barclays EPL teams by their current table standings and looking at the aggregate squad points for all their players to see if that correlates directly to the team's table position.
We can clearly see that in general there is a linear correlation between how well a team is doing in the English Premier League and the cumulative fantasy points of its players. The orange bars above show the total cost of each team's players in terms of Fantasy League currency. This helps us identify teams that generate a decent return of Fantasy Points per dollar spent (ROI) on average such as — Manchester City, Liverpool, Chelsea, AFC Bournemouth, Watford, and Wolverhampton. This also exposes a few of the teams that would be considered a bad investment such as — Tottenham, Arsenal, Manchester United, Fulham, Huddersfield, West Ham, and Southampton.
Next, we plotted each Team's cumulative player ROI against the number of players that the coach uses on a regular basis (players who have played at least 360 minutes so far in the season). This will help us identify the teams that have too many expensive and under-performing players who rarely play the full 90 minutes each game due to the frequent squad rotation their coach employs, which makes them a bad investment in the long run, since they will not be generating fantasy points consistently each game. Also, this graph below will help us identify the teams with coaches that do not use frequent player rotation, which results in those teams having a more consistent core of regular squad players. That will inform our algorithm to pick more players from those teams since their players are expected to generate a higher aggregate ROI in the long run because they would be involved in a lot more game action on average compared to players from teams that use frequent player rotation.
In the graph above we're looking for teams with a very tall blue bar (cumulative player ROI) and a shorter orange bar (total number of players that the coach uses on a regular basis). The leader in this category is Wolverhampton, with an AVG ROI of 8.21 and only 11 players that the coach uses on a regular basis (an average of 8.21pts yield per dollar spent on each Wolverhampton player). That means that most of Wolverhampton's players are undervalued compared to their performance and that the coach uses the same 11 players on a regular basis and only uses subs towards the end of the game or when a regular team player gets injured. Even teams like Manchester City, Liverpool and Chelsea are in this category with 13–14 regular squad players, which means that picking players from any of the teams above is a good investment in the long run because the regular squad players play more minutes on average compared to players on the bench.
The big losers in this category are Manchester United, Tottenham, Arsenal, Everton, West Ham and Fulham with ROIs in the 4–5 range and with a number of regular squad players going as high as 15–16. This means that by picking players from these teams, you are making a "bad investment" by risking having your players not play every game due to the coach's use of frequent squad rotation. Also, the stats clearly show that these teams' players are very overpriced compared to their performance in the Fantasy League indicated by their lower than average ROIs.
2. Looking at individual player stats
After identifying which teams yield a higher cumulative ROI, we then zoomed in on the individual players. In stock market terms, we have identified all the high-yield market sectors — the teams — and now we want to start analyzing all the individual stocks in each sector — the players. The plan is to isolate a list of players with the highest ROIs and write a Python algorithm that will use smart logic to pick the most optimal combination of players, which will generate the highest return on investment for our limited budget of 100MM.
Looking at the scatter plot of Player Cost vs. Player Total Fantasy Points above, we would want our AI to pick players who appear as west-north as possible on the plot (players of low cost who generate a lot of Fantasy Points). Note that we would also want to include some of the top players from the east-north corner of the plot since these would be some of the star league players who generate a lot of points, and even though they are a bit expensive, they still end up with a decent ROI. The graph below plots the Top 20 ROI vs. the Bottom 20 ROI players. So, we'd expect our final algorithm to pick as many of these high yield players as possible. And we want to stay away from players who are very overpriced compared to their performance ( High-Cost / Low Fantasy Points) such as Hary Kane, Alexis Sanchez, Romelu Lukaku, Christian Ericksen, Alvaro Morata, Paul Pogba, Dele Alli and more.
We decided to plot the stats above, including the AVG ROI of all players in the league (green line = 5.74) to get a visual idea of what "overperforming" and "underperforming" players look like. For example, Marcos Alonso, who is the top yield player in the league has an ROI of 12.11, which is more than double the AVG of 5.74, which makes him a no-brainer pick for our algorithm.
In the Pie Charts below, we can see a distribution of the teams with the most-overpriced players versus the teams with the most undervalued players. We are expecting our final algorithm to pick players from a variety of teams that have a lot of high-yield players such as — Bournemouth, Wolves, Liverpool Chelsea, Manchester City, Watford, and Everton. This smart approach is very different than the approach that the average Joe uses to play the Fantasy game, which is to mostly pick players from his/her favorite team, plus a few players from 4 or 5 of the most popular teams — Arsenal, Tottenham, Manchester United, Chelsea, Liverpool or Manchester City, and then fill in the rest of their fantasy team with cheap "filler" players who never play during the real games and do not generate any Fantasy points.
3. Writing the Python Algorithm for picking the optimal Fantasy team
Now it's time for the most fun part — writing the actual Python algorithm and comparing the results of the AI picks to what an average person might pick for their Fantasy team.
To understand the logic of our Algorithm one must first understand the rules and constraints of the EPL Fantasy Game below:
- Each fantasy player starts with a limited budget of 100MM and has to buy 15 soccer players (11 for the main squad + 4 subs) in order to compete.
- You need to have at least 2 Goalkeepers, 5 Defenders, 5 Midfielders, and 3 Forwards in order to complete your squad and be eligible to play.
- You cannot have more than 3 players from the same soccer team.
So, we started our python algorithm with an if-else statement for these conditions and then added our own conditions and logic on top of that, so that each time that the algorithm loops through our list of players, it can use smart logic to make a valid pick guided by our conditions below:
- Check if a player is injured, suspended or unavailable to play and if so, do not pick that player for our Fantasy team even if they have a high ROI.
- Pick the top three star players with the most cumulative league points in the league first. (We will test the outcome of this condition with different numbers of star-players and pick the version that generates the biggest return on investment, while still allowing enough left-over budget to fill our squad with a lot of the Top 50 ROI players.)
- Every time we pick a player and add them to our team, we subtract their cost from our 100MM budget and we add their position and team-name to a list, to make sure that we stop buying players for the positions and the teams that hit their constraint limit.
- Once the optimal number of expensive superstar players are picked, the Algorithm starts going through the list of players with the highest ROI and tries to get us as many of the top names as it can, until we get close to depleting our budget and filling all of the team positions.
- Algorithm prints a list of the players it picked at the end and gives us the remaining budget and the total fantasy points of the team.
Here is some of our condensed Python Code for the team picking algorithm:
Below you can see a screenshot of the final team that our Algo picked:
Note: The team below is only accurate up to Nov 14th, 2018. Our Algorithm is designed to update the player stats after every Gameweek and make new picks based on the fluctuations in team/player ROI stats.
Note: We wrote a similar algorithm for the AVG Joe team, which focuses more on spending the budget on star players from big teams, who are often overpriced and might not return the highest cumulative ROI for our limited budget of 100M.
Note: We also asked a classmate to pick a random team of his own, so we can compare his picks and verify that our random team-selector function for the AVG Joe algorithm is accurate.
4. Comparing our Results
Now that both algorithms have been built and executed, let's compare the results of our "Money Team" vs. the "AVG Joe's Team vs. the "Random Classmate Team" to see which one performed best and by what margin. The final results showed that our team scored a total of 944 points vs. only 812 pts. for the AVG Joe team (similar to our classmate's team), which is a significant 132pt difference! The bar-plot below demonstrates our results:
Interesting questions to answer: Did our Algorithm return the highest ROI team? Did it beat the others by a significant margin? Did our Algorithm successfully pick players from some middle of the table teams, which we initially identified as undervalued? Did the AVG Joe Algorithm and our classmate pick more of the expensive overpriced players from the top teams?
Below we can see that our Algorithm picked a combination of players from most of the high ROI teams that we identified at the beginning of our project:
This is a much more balanced and unbiased selection method than what the AVG Joe used when selecting his/her players. Please note that the pie chart below shows the team list for the 11 players that the AVG Joe team selected as their main squad. Since the AVG Joe spent most of his/her budget on picking 11 very expensive players, he/she had to spend the remaining budget on the cheapest available players to fill in all the substitute positions, but none of these players can be used to generate fantasy points due to the fact that they never actually played in the real EPL games and were only used as team-fillers. These are a few sub-players from Brighton and Cardiff.
Conclusion:
Removing team/player biases and favoritism and focusing on the actual player stats, allowed our Algorithm to get the most bang for our buck and beat the average EPL Fantasy player by a total of 132 pts or a whole 16.25%! In the end, it turned out that my friend and I were not actually 'unlucky' and there was a reason why our Fantasy League teams performed very poorly year after year. This deep dive into the player data allowed us to realize that we were allowing team favoritism and a tendency to buy a lot of the overpriced players to hurt our overall Fantasy League performance.
5. Next Steps
We plan to keep monitoring the data, checking for any drastic changes and outliers in the player stats further in the season when players start getting injured and the battle for points trophies gets more heated. We would also like to compare how the algorithm's team performs at the end of the season compared to most recreational players in the world. Also, we plan to update this blog once a month for those of you who are interested in following our AI's progress, so please revisit the blog at the end of each month for performance updates and enjoy the rest of the EPL action!!!
How To Create Fantasy Premier League Account
Source: https://towardsdatascience.com/how-our-ai-got-top-10-in-the-fantasy-premier-league-using-data-science-ba88b185b354
Posted by: hansonachough1942.blogspot.com

0 Response to "How To Create Fantasy Premier League Account"
Post a Comment