Win Your Daily Fantasy (DFS) League with this Lineup Optimizer

In this post, we use a Shiny app in R to determine the best possible players to pick in a daily/weekly fantasy football (DFS) league. The app includes the most accurate fantasy football projections available, and calculates a robust average of more sources of projections than any other website (see here for a list of the sources of projections). You can even choose how much weight to give each source. Based on your league settings, it determines which players you should pick to maximize your starting lineup’s projected points. It also allows you to change your risk tolerance to avoid picking risky players. Best of all, the app updates the selections automatically with your inputs, and you can download the data for yourself. So let’s get to it. Here’s a more thorough description:

To Use the DFS Optimizer App

To use the DFS Optimizer App, you will need to subscribe to FFA Insider (for more info, see here).

How it Works

First, we use a script to scrape player’s projected points from numerous sources using R. Second, we scrape player prices from various DFS websites. Third, based on the user’s league scoring settings, we calculate players’ projections using an average of the analysts’ projections (by default, the sources are weighted according to historical accuracy). You can choose which projection sources to include, modify the weights, and choose to calculate a mean, weighted average, or robust average. A robust average is less affected by outliers (crazy projections). Fourth, we calculate players’ risk levels, as defined by the average of: 1) injury risk from Sports Injury Predictor, and 2) the standard deviation of the players’ projected points and rankings across analysts. Note that risk is standardized to have a mean of 5 and a standard deviation of 2.

Then, based on how many players you need for each position, your cap available, and your maximum risk tolerance, we use the Rglpk package to find your optimal lineup by selecting the remaining players available that maximize the lineup’s sum of projected points while meeting all of the constraints. For a similar execution using Excel’s Solver function, see here.

It is generally best to select players with minimal risk to ensure solid, if not superior, performance. We include players’ upside potential (ceiling) in the output, as defined by the players’ 90th percentile of their projected points across analysts.

Note that VOR, ADP, ECR, and AAV are not shown for weekly projections (only seasonal projections).

Strategy

Strategy to win your DFS league: pick the players with the highest sum of projected points (especially floor), while minimizing risk (i.e., a low risk and a high floor).

User Inputs

Season: which season of projections to use.Week: which week(s) of projections to use.Number of Starters by Position: how many players in your starting lineup at each position.League Scoring: source of DFS scoring settings.Positions: which positions of players to include in calculations.Calculation Type: the type of average to calculate: mean, weighted average, or robust average. By default, a weighted average is used with analysts weighted by their historical accuracy. You can modify the weights in the weighted average. The mean is equivalent to a weighted average where all analysts are equally weighted (weight = 1). The robust average gives less weight to outliers (crazy projections).Analysts: Select which analysts to include and, if weighted average, the weights for each analyst (i.e., how much weight to give each source of projections when calculating projected points). For instance, if you want to exclude ESPN projections, you would give them a weight of 0. If you want to give Yahoo projections twice the weight of CBS, you would give Yahoo a weight of 2 and CBS a weight of 1. The default weights reflect historical accuracy (higher = more accurate). Note that FantasyPros shows a default weight of zero because we already include all of their sources in our projections, so it would be double counting to give them a weight above 0. You can certainly do so, though, if you’d like. FantasyFootballNerd also shows a default weight of zero because it uses the same projections as FantasyData.Scoring Settings: specify the number of points for each statistical category and position.

Sidebar

Maximum Risk Tolerance: Selects the maximum risk allowed for any player to be considered for inclusion in the optimal starting lineup. Players’ risk levels have a mean of 5 and a standard deviation of 2 (see below for more info on how risk is calculated).Remaining Cap for Starters: How much cap you have remaining to spend on starters.Players You Drafted: Select all players you’ve already picked (click “Pick” button next to player or type player’s name).Other Players Drafted: Select players to exclude.

Output

Lineup with Highest Points: Players with highest sum of projected points within your league cap and risk tolerance.Lineup with Highest Floor: Players with highest sum of projected floor within your league cap and risk tolerance.Lineup with Highest Ceiling: Players with highest sum of projected ceiling within your league cap and risk tolerance.Pick: Click “Pick” button next to player to add to “Players You Drafted”.Rank: Overall rank by projected points.Player (Team): Player name and team. Click player’s name to add to “Other Players Drafted”.Pos: Position.Points: Average projected points for a player across analysts.Ceiling: A player’s upside, calculated as the 90th percentile of a player’s projected points across analysts.Floor: A player’s downside, calculated as the 10th percentile of a player’s projected points across analysts.Pos Rank: Position rank.Dropoff: The “dropoff” in projected points for the next best 2 players at the same position.Risk: Risk of injury and degree of uncertainty of players’ projected points, calculated as the average of: 1) injury risk from Sports Injury Predictor, and 2) the standard deviation of the players’ projected points and rankings across analysts. Standardized within position to have a mean of 5 and a standard deviation of 2 (higher values reflect greater risk).

Graph

Displays two types of graphs:

A density plot of projected points by analyst

Line plot of each optimal starting lineup by projected points, floor, and ceiling

A density plot shows, for each analyst, what proportion of players are projected to score a given number of points. Density plots can be helpful for comparing analysts and finding analysts with wildly different projections. In the line plots, the dot represents the average (mean, weighted average, or robust average) estimate of projected points for each player. The line shows the range from a player’s floor to ceiling.

The DFS Optimizer App

Share this:

Related

My name is Isaac and I’m an assistant professor with a Ph.D. in Clinical Psychology. Why am I writing about fantasy football and data analysis? Because fantasy football involves the intersection of two things I love: sports and statistics. With this site, I hope to demonstrate the relevance of statistics for choosing the best team in fantasy football.

Isaac, can you tell us which DFS sites you support? Before putting in some money, I’d like to know if you support lineup optimizers for the following sites: Yahoo, DraftKings, FantasyAces, FantasyDraft, Draftpot. Thanks!

We currently support Fanduel, DraftKings, Yahoo, FantasyAces, DraftDay, FantasyScore, and StarsDraft. We have also historically supported DraftPot and FantasyFeud but they did not have NFL contests and had inaccurate players lists respectively. We will look to add more sources if there is sufficient interest from readers.

Isaac, I checked in FAQ’s and says the data will update periodically wed thru Sunday.. does the date in the weekly proj. app on the top right mean that’s the last time the salaries and proj. data was scraped? Or does it mean something else? If so, when do you think we can expect them to be updated before tomorrow’s games? Love this subscription btw. Thanks!

I am a subscriber and I appreciate the work put into creating these projections, thank you! I just wanted to add something onto Huey’s idea about excluding games. Could you please add “Exclude Team” as well? This way, the projections will not use a single player from the team that is excluded, and being able to exclude an entire team with one-click is much, much, faster than waiting to “see” if someone from that team pops-into the lineup and then have to excluded them, wait for the re-calculate process, and then…you get the idea. This could happen several times for different players from a single team. Thanks again!

Huey, I got around this by going into Lineup Optimizer, changed the settings to Fanduel, did the preferred averages and then downloaded custom rankings. I then went into RotoGrinders and downloaded their template .csv file. I merged the data between the FF Analytics and RotoGrinders files using a VLookup. FF Analytics uses the Team Name for DST so you’ll need to add the city. I also had to update Robert Griffin and Kadeem Carey’s names to match those of RotoGrinders. Once I merged the FF Analytics data with RotoGrinders I then uploaded the data to RotoGrinders. Now I can select whichever slates I want. I hope that helps, let me know if you have any questions. Would be glad to help.

By the way, I compared optimum lineups from what FF Analytics provided for all games and it was identical in RotoGrinders once I uploaded the data. That tells me both sites are using the same algorithms to generate optimum lineups.

Could you try again without changing the positions (or number of players at each position)? The dialog box isn’t showing the correct positions at the moment, but the app should generate the right positions in the weekly lineups for each source (and you can’t modify them for weekly leagues).

I got the same thing last night just generating a lineup for Fanduel. I thought maybe it’s because I was using an ipad so I tried my laptop this morning and it works fine. Not sure if OS has anything to do with it.

Possibly, but not sure. We’d need more info to reproduce. What settings are you using (esp. specific changes that you made)? What browser are you using? Some have had success on Chrome, others have had success on Safari. Let us know if you get a chance to test on a PC.

Anyone know what are the premium features you get by subscribing to the projection app? the language is very vague “Upgrade your account with a monthly subscription and get the full force of our apps behind your player picks! ”

What’s the difference between your optimizer and others? For instance, I pulled your projections for FantasyAces, put them into RotoGrinders, and got different results. This is surprising, since I imagined that all the optimizers are solving the same math problem.

Sorry if that sounded a bit abrupt! All I meant was that since I’m feeding RotoGrinders projections I pulled off the FantasyFootballAnalytics projections tool, I would expect similar lineups. However, perhaps it has something to do with the way you calculate risk. Just curious!

I just purchased the app and subscribed. 1) can I use the lineup optimizer if my 12 man league doesn’t have caps for our teams? 2) Im having the same problem with it not loading, or the projections. It keeps sailing “There was a problem reaching our servers for user validation.”

I purchased a subscription and am trying to utilize the Weekly Lineup Optimizer, but it’s still not working. I read the recent comments and understand that within “high activity hours” I could run into trouble. That being said, I’ve been attempting this at all hours since yesterday and it still not working.

I select “Week 1” and “DraftKings” scoring in the “Change Data Settings” screen, but instead of loading weekly projections, it reverts back to a blank lineup with season long auction value still referenced.

I have tried logging out, restarting, etc. several times. What are my next steps?

Very sorry about the trouble! Could you try deleting your cache, disabling your adblockers, and/or a different browser? You might try Chrome if you’re not using it (that’s we test development on), or a different browser if you already are. Let us know if you continue to have problems.

Would it be possible to make it is so the app can pull a range of weeks instead of individual weeks? Would be useful to be able to load chunks of the data at once rather than have to load every week individually. Thanks.

Having issues with it now..It generates lineups for Draftkings that are over the salary caps for draftkings which make them useless. It is also giving me the following error: nternalRS_DBI_getconnection:
Corrupt connection handle. IN call “, productionserver: True

I’m not getting lineups over the salary cap for DraftKings. Could you try deleting cache, disabling your ad blockers, and/or a different browser (esp. Chrome)? We’d need more info to reproduce. What specific changes are you making?

Can we also update the tool to allow to choose different slates (e.g., Thu-Mon, Sun-Mon, Sun Only, 1:00EST Games Only, etc) as well as an option to automatically recommend “sleepers.” this would be very useful for GPP systems

I am using the lineup optimizer for Draft Kings and why when I change the data settings to draft kings, I also take the kicker out and add a receiver when I load it the results come up with a kicker everytime and no 3rd receiver. Please help. I have cleared cache and using Chrome

For the Weekly optimizer, the code does not use the user inputs for positions in the lineup (so you shouldn’t need to change the lineup positions). That is read from the database, which is set at 1QB, 2RB, 3WR, 1Flex and 1 DST for DraftKings, so it shouldn’t return a kicker in the lineup. As far as I can it tell it doesn’t. Let us know if you see otherwise.

is there any info on how the optimum lineups did historically – trying to figure out how it would perform if entered into a DK or FD double up each week. One issue it could run into is picking players that are popular picks which could reduce the edge in daily fantasy.

I’m not sure if there’s a way to scrub the player start percentages from DraftKings or if they publish that data each week. One thing that would be helpful though would be to see the score actual total score of each optimal lineup which could be compared against score needed to be in the money at the DFS sites.

It would be helpful to see the three optimal lineups from each week and how they ended up doing. Not sure if you’re able to retroactively call up old optimal lineups though.

Lineup optimizer for Week 4 DraftKings settings fails with a “An error occurred while updating the data. Please try again.” error. Week 4 FanDuel seems to work fine. I run into errors like this pretty much every week and have to log in/out in fresh browser sessions regularly to get it to work 🙁

Also, the Ceiling/Floor as currently calculated isn’t very useful IMO (I understand why you do that since you only get point estimates from the underlying data sources). What is useful though are the low/high values representing the actual predicted distribution of points. Based on historical results, setting the 95% conf interval to [0, 1.5*(your calculated ceiling)] is an ugly hack that seems to be pretty predictive so far this season.

Agreed that the actual performance doesn’t always fall within the predicted interval. There is a tradeoff between precision and confidence. We give greater precision with less confidence. We feel that this approach is more useful than an interval that is well calibrated but incredibly wide and that doesn’t tell you much (especially if it includes zero for all players). In general, research has shown that people prefer informativeness over accuracy (Yaniv & Foster, 1995, 1997). We have plans to write an article about the calibration of our prediction intervals:http://circ.ahajournals.org/content/115/7/928

Re: error, the only thing I was doing was logging in (inside a fresh Chrome incognito window), changing data to Week 4, game type to Draft Kings, clicking Apply, and getting the error. Performing the exact same steps later in the day eventually worked, so I assumed it was a data issue. Let me if there’s other info might help for next time.

Re: article, nice, def looking forward to that!

Re: intervals, I use the interval for producing predicted point distributions of the lineups for DFS play. Individuals’ ranges are wide but the composite lineup distribution is naturally tighter and seems to be in the right ballpark. With that I can quantify things like “probability this lineup hits at least 140 points”, which (ignoring the underlying hack) is at least for me a more useful risk metric. And can be then fed into chances of making the money, probability distribution of $ expectations, lineup portfolio analysis, etc.

Which all depends on being able to extract reasonable distributions at the player level.

Agreed that the interval you use depends on the goal. We have decided to use smaller intervals to help people compare the floors and ceilings of players more easily. We can consider computing multiple sets of intervals, to include more calibrated intervals as well.

1) I don’t think the app is loading at all. When I click on Sign In, the address bar changes to ‘http://apps.fantasyfootballanalytics.net/projections#signup’, but nothing else changes. Both Projections and Lineup Optimizer are completely blank. It’s the same for all other buttons and links. The URL changes, but the screen does not update.
2) Chrome / Chrome Incognito (Version 53.0.2785.143); I’ve also tried Safari and IE
3) Windows 8 and Mac os10 Sierra tested with same results

Hi guys, I had a similar error to Rob’s last week I believe it was, and I read that using Chrome Incognito may help, and it did! (You may want to give it try Rob). Anyway, I am getting another error (despite) using Chrome incognito as well as not in incognito. I cannot copy/paste it, and I limited time so I cannot type the error all out now, but wanted to make you aware that it is also happening. (I do have the exact same “In call” portion at the bottom of the error as Rob has noted above if it helps.

Hi guys, it’s almost 1:00 am on Sunday 10/16/16…game day. This is the only time that I have left to myself that I can spend doing the rest of my lineups, and once again, the optimizer throws-up errors regardless of what browser I use…I have used them all, including Chrome incognito,as I know the drill all to well now with these errors. And asking people for “what error” is , at this point is a ridiculous question because there are too many people that have these errors and too often…and these are clearly just not being ironed out. It was working just fine 24 hours ago, but again, here we go with the errors. Why?

I’m an FFA insider who would gladly pay you any reasonable amount for your monthly fee, even beyond what you currently charge. But the issue is that when I cannot even load the optimizer into any browser more often than not because of these on-going errors, the value becomes zero right? It’s really disappointing that so many people have these errors loading, yet nothing serious has been done to once and for all, just make them stop. Being able to load data is the most basic of requirements to fulfill to your users guys, there’s no other way to say it.

There should never be an issue loading data from a website 99.99% of the time – period. I literally have no issue loading any other site on the web…ever…literally, ever. I have a brand new computer, am running Windows 10, no hardware issues, three different browsers with no browser issues, and reasonable technical skills. I just don’t understand why this isn’t a MAJOR priority…as in your number one item to fix here before doing another thing on data or otherwise. (As in so that it never ever happens one more to any of your users). If the company I work for, for example ever had a website down for even a minute, it would be major news..and a top priority to not only fix it right now, but to learn why it happened and take measures for it not to happen again for that reason.

Think of the problem you have like this…if you have a store with the best product available, a great location and good prices and people from all over for miles and miles come to your store to buy, that sounds awesome…a dream right? But if doors to the store is locked when they get there, how are people supposed to get in? They’re looking in the window at you and your product, but you won’t let them in. This is how not taking care of these errors once and for all makes your users feel. We take the time to give you this valuable feedback in an attempt to get it fixed…not today…but for good. Why would you want people to keep telling you every day when they cannot loan data?

I have had a lot of faith in your analytical skills, no doubt, but this is frustrating guys, just frustrating.

I was monkeying with this a bit and ran into the same issue. I then went and zeroed out all of the weights for the different sites and it ‘worked’ — it gave no data, but it at least didn’t error out. I suspect one of the sites is not cooperating and zeroing that one out, or excluding it from a weighted average may allow the data to be loaded (minus that one site).

So I was working on my lineups for about an hour, and then just after midnight, the errors start popping up again, and now the optimizer doesn’t work again. It was working perfectly for an hour…but right after midnight…it stopped. Hopefully that tells you where to look. It’s definitely not on the users end.

Thank you for the great tools. It seems that no matter how I change the settings the weekly lineup optimizer always gives me 3 RBs and 3 WRs? I’ve tried to get it to give me only 2 RBs and flex in a 4th WR or a second TE but it does not seem to allow me to do this for DFS?

The DFS optimizer doesn’t take position inputs because the positions are fixed by site. Pick the site you’re using (e.g., FanDuel, DraftKings), and they should have the correct positions. You can also use our regular lineup optimizer for season-long leagues that allows changing the number of players to draft at each position (just select week=”Full Season” instead of a week).