Data Driven Fantasy Football Lineup Optimization - Part 2

Posted on Nov 22, 2021
The skills the author demoed here can be learned through taking Data Science with Machine Learning bootcamp with NYC Data Science Academy.
Click here for Part 1 of Blog:

Blog Part 1

Part 2

The goal for this project was to use gathered data 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).

Methods

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.

Data from the Algorithms

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.

Data Driven Fantasy Football Lineup Optimization - Part 2

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.

Data Driven Fantasy Football Lineup Optimization - Part 2

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

Data Driven Fantasy Football Lineup Optimization - Part 2

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

Hugh Goode

Hugh is a Data Scientist with a BS in Civil Engineering from the The College of New Jersey and an MS in Engineering Management from Duke University. After 5 years as an engineer, he pivoted to pursue Data...
View all posts by Hugh Goode >

Leave a Comment

No comments found.

View Posts by Categories


Our Recent Popular Posts


View Posts by Tags

#python #trainwithnycdsa 2019 2020 Revenue 3-points agriculture air quality airbnb airline alcohol Alex Baransky algorithm alumni Alumni Interview Alumni Reviews Alumni Spotlight alumni story Alumnus ames dataset ames housing dataset apartment rent API Application artist aws bank loans 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 boston safety Bundles cake recipe California Cancer Research capstone car price Career Career Day citibike classic cars classpass clustering Coding Course Demo Course Report covid 19 credit credit card crime frequency crops D3.js data data analysis Data Analyst data analytics data for tripadvisor reviews data science Data Science Academy Data Science Bootcamp Data science jobs Data Science Reviews Data Scientist Data Scientist Jobs data visualization database Deep Learning Demo Day Discount disney dplyr drug data e-commerce economy employee employee burnout employer networking environment feature engineering Finance Financial Data Science fitness studio Flask flight delay gbm Get Hired ggplot2 googleVis Hadoop hallmark holiday movie happiness healthcare frauds higgs boson Hiring hiring partner events Hiring Partners hotels housing housing data housing predictions housing price hy-vee Income Industry Experts Injuries Instructor Blog Instructor Interview insurance italki Job Job Placement Jobs Jon Krohn JP Morgan Chase Kaggle Kickstarter las vegas airport lasso regression Lead Data Scienctist Lead Data Scientist leaflet league linear regression Logistic Regression machine learning Maps market matplotlib Medical Research Meet the team meetup methal health miami beach movie music Napoli NBA netflix Networking neural network Neural networks New Courses NHL nlp NYC NYC Data Science nyc data science academy NYC Open Data nyc property NYCDSA NYCDSA Alumni Online Online Bootcamp Online Training Open Data painter pandas Part-time performance phoenix pollutants Portfolio Development precision measurement prediction Prework Programming public safety 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 seafood type Selenium sentiment analysis sentiment classification Shiny Shiny Dashboard Spark Special Special Summer Sports statistics streaming Student Interview Student Showcase SVM Switchup Tableau teachers team team performance TensorFlow Testimonial tf-idf Top Data Science Bootcamp Top manufacturing companies Transfers tweets twitter videos visualization wallstreet wallstreetbets web scraping Weekend Course What to expect whiskey whiskeyadvocate wildfire word cloud word2vec XGBoost yelp youtube trending ZORI