Fantasy Football Lineup Optimization - Part 2

Posted on Nov 22, 2021

Click here for Part 1 of Blog:

Blog Part 1

Part 2

The goal for this project was to build an application to optimize fantasy sport lineup generation given the input of player salaries and projected fantasy points for each player. While this blog will focus on NFL fantasy sports contests, this framework can be used for other sports as well. The goal is to maximize value (fantasy points) given the weight restrictions (virtual budget for salary).

The project will explore 2 point projection methods, the average points scored by each player over the course of the season (outlined in Part 1 of the blog) and the point projections provided by DraftKings. Additionally, 2 lineup optimization methods will be explored. “Random Walk” which will randomly pick players to fill a team meeting the positional and salary constraints for a set number of trials. The algorithm will then sort the total projected points for each team generated and return the optimal solution. The second method will use Linear Programming to solve for the optimal solution. Linear programming is a technique for the optimization of a linear objective function, subject to linear equality and linear inequality constraints. The inspiration for this solution is a famous problem in linear programming called the knapsack problem. Picture a hypothetically knapsack that has a finite capacity to carry a certain amount of weight, the owner of the knapsack wants to maximize the value of survival items held within the knapsack. The problem is defined as given a set of items, each with a weight and a value, determine the number of each item to include in a collection so that the total weight is less than or equal to a given limit and the total value is as large as possible. For the fantasy football problem, the total value is defined as the projected fantasy points for a team and the weight is the total salary cap allowed for the contest. The R library lpSolve is used in this case to solve for optimal solution.

Sample script below for the Random Walk Algorithm:

The graph below shows the improvement as trials are increased.

Figure 1 - Increase in optimal lineup as iterations increase

After 10,000 trials the Random Walk yielded a maximum value of 136.4 points.

 

Sample script below for the lpSolver Algorithm:

lpSolver yielded an optimal solution of 174 points, a significant increase from the Random Walk approach.

However, this value of 174 points is only a projection and may or may not be reached depending on the accuracy of the predictions for each player. After exploring the projected values it became clear that average points approach was yielding very similar projections to those provided DraftKings. The histogram below shows the counts of the absolute value of the difference between the player projections defined in the Part 1 blog and the DraftKings projections. Players projected less than 5 fantasy points have been filtered out because they are not likely to be drafted.

Histogram of Difference in Projection(Filter out players with projected points < 5)

 

The density around 0 on the x-axis indicates that the predictions are relatively close in most cases. After seeing this, I decided to explore filtering out more players on the lower end of points projections.

Histogram of Difference in Projection(Filter out players with projected points < 10)

 

Histogram of Difference in Projection(Filter out players with projected points < 15)

 

The histograms shows that the projections are closer for players who are projected more points. There is high correlation (0.95) between the values.

While the application can help optimize lineup selection, the effectiveness of the tool is still limited by the accuracy of the predictions prior to the week of games. The scatter plot below shows lack of linear relationship between the points projections and actual point outcomes each week.

Scatter plot of projected points vs. actual points scored for individual players

 

Conclusion and Future Work

A major issue that has not been resolved is the high variability in player outcomes each week. Neither the DraftKings nor rolling average approach appear to provide the accuracy needed for sustainable and consistent success. It is clear further analysis is needed to increase the accuracy of predictions. This requires analysis of actual NFL game statistics to develop and test a model.

About Author

Leave a Comment

No comments found.

View Posts by Categories


Our Recent Popular Posts


View Posts by Tags

#python #trainwithnycdsa 2019 airbnb Alex Baransky alumni Alumni Interview Alumni Reviews Alumni Spotlight alumni story Alumnus API Application artist aws beautiful soup Best Bootcamp Best Data Science 2019 Best Data Science Bootcamp Best Data Science Bootcamp 2020 Best Ranked Big Data Book Launch Book-Signing bootcamp Bootcamp Alumni Bootcamp Prep Bundles California Cancer Research capstone Career Career Day citibike clustering Coding Course Demo Course Report D3.js data Data Analyst data science Data Science Academy Data Science Bootcamp Data science jobs Data Science Reviews Data Scientist Data Scientist Jobs data visualization Deep Learning Demo Day Discount dplyr employer networking feature engineering Finance Financial Data Science Flask gbm Get Hired ggplot2 googleVis Hadoop higgs boson Hiring hiring partner events Hiring Partners Industry Experts Instructor Blog Instructor Interview Job Job Placement Jobs Jon Krohn JP Morgan Chase Kaggle Kickstarter lasso regression Lead Data Scienctist Lead Data Scientist leaflet linear regression Logistic Regression machine learning Maps matplotlib Medical Research Meet the team meetup Networking neural network Neural networks New Courses nlp NYC NYC Data Science nyc data science academy NYC Open Data NYCDSA NYCDSA Alumni Online Online Bootcamp Online Training Open Data painter pandas Part-time Portfolio Development prediction Prework Programming PwC python Python Data Analysis python machine learning python scrapy python web scraping python webscraping Python Workshop R R Data Analysis R language R Programming R Shiny r studio R Visualization R Workshop R-bloggers random forest Ranking recommendation recommendation system regression Remote remote data science bootcamp Scrapy scrapy visualization seaborn Selenium sentiment analysis Shiny Shiny Dashboard Spark Special Special Summer Sports statistics streaming Student Interview Student Showcase SVM Switchup Tableau team TensorFlow Testimonial tf-idf Top Data Science Bootcamp twitter visualization web scraping Weekend Course What to expect word cloud word2vec XGBoost yelp