Learn how to use Python to project kicker performance.
If you have any questions about the code here, feel free to reach out to me on Twitter or on Reddit.
If you like Fantasy Football and have an interest in learning how to code, check out our Ultimate Guide on Learning Python with Fantasy Football Online Course. Here is a link to purchase for 15% off. The course includes 15 chapters of material, 14 hours of video, hundreds of data sets, lifetime updates, and a Slack channel invite to join the Fantasy Football with Python community.
In this post, I'm going to take you down a bona fide rabbit hole of projecting kicker points for week 6 of the NFL season. I'm not proud of taking 2 hours out of my day to come up with this code, considering I already have Will Lutz on my roster, but once I realized I spent too much time projecting kicker fantasy points, I was already too deep in. Here it is in all it's shame and glory.
First, we are going to pull 2020 play by play data courtesy of nflfastR to find two things - how many 0-39 yard field goals, 40 - 49 yard field goals, 50+ field goals and extra points each team is allowing per game. We're also going to find where offenses are kicking these same categories of field goals. We're then going to join these two DataFrames based off who's playing who in week 6. From there, we're just going to average the results. For example, if CAR is playing ATL, and CAR is giving up 3 field goals a game between the 0 and 39 yard line, and ATL is kicking 2 field goals a game in the 0 and 39 yard line, then we'll say ATL is going to kick 2.5 field goals (what's a 0.5 of a field goal amirite).
Once we get that done, we're going to automate finding the starting kickers for each team. We're going to find those kickers that have the most attempts for their teams, and call them the starting kickers. There's some problems here, namely injuries and kickers losing their starting jobs. A kicker could have the most attempts for their teams but also not be the starting kicker. The only solution for this, as far as I can tell, is to manually input the starting kickers for each team in to pandas. I chose not to do that, and the kicker list we come up with looks fine to me, but you can input them manually to be safe.
Once we get the starting kickers for each team, we are going to then pull their historical %s from within the 39, 40-49, 50+ and also extra points. We're then going to multiply their historical % by the expected kicks within each "bin" we calculated above, and then multiply by the appropriate scoring weights (3 for 30-39 yard field goal, 4 for 40-49 yard field goal, 5 for 50+ and 1 for xp).
One problem I don't have a great solution for is the question of missed kicks. Most leagues deduct a point for each missed kick. To account for this, we're going to calculate a cumulative missed kick percentage. If that number is over 50%, meaning it's more than likely, we'll say the kicker will miss one field goal in the game and needs to be deducted a point. Not the best solution, but these are not robust projections.
This is going to require some serious data munging and manipulation, and hopefully by the end of this post you'll (a) maybe find one of these top kickers sitting on your waivers and pick them up for week 6 and (b) be a lot more comfortable with pandas.
Let's start out by importing pandas. This will be the only library we'll need for this monstrosity.
Next, let's load in our 2020 play by play data. This contains every play for the 2020 season thus far.
This giant block of code below is grabbing plays that were either field goals or extra points, binning them for both defenses and offenses, and then merging them together and averaging them out for a projected kicks in each bin number for each team.
|posteam||0-39 yards||40-49 yards||50+ yards||extra_point||fantasy_points_up_for_grabs|
We now have our expected kicks allowed within the 0-39, 40, 50+ and xps for each team for week 6. Whew. Let's run the process where we try to find starting kickers based off total volume of kicks. Remember, if a player has the most attempted kicks for a given team, they are considered the starting kicker for the team. This is not a perfect solution, and prone to errors, but it's automated. If you want to be sure, just input them manually, although that could take a while.
Awesome, so now what we need to do is find each kickers accuracy within the 0-39, 40-49, etc. We're going to do this for the past 4 years, although you can change it to the past 5. Recall that the extra point distance was changed in 2015, though, so that may affect things.
To start out, we're going to calculate the accuracy % for each of these bins for all players in this 2016 - 2020 time span. The code block below is going to look a lot like the code block where we find each kickers accuracy % within our kickers_df.
Surprisingly, kicks from 50+ yards are almost at 60%. I personally thought that number would be lower.
Now, let's look at our kickers_df and try to calculate these same numbers for each individual kicker.
Awesome, all that's left to do is merge this individual kicker completion percentage with the fg_df and the kickers_df, and then calculate an expected value for fantasy points.
Below, we calculate projected fantasy points. Remember that we have to account for missed kicks as well. If a player's cumualtive miss % is greater than 0.5, we see they are more than likely to miss a kick given their accuracy % and the volume of kicks they're expected to receive. We'll deduct 2 two points instead of 1, which is also not a perfect solution (We're deducting 2 instead of 1 because if a player misses a kick, it's a net loss of 2 points, as they lost the opportunity to gain a potential point for a kick and also were deducted a point. Again not a perfect solution because the potential loss of fantasy points can be greater than 1).
Finally, the last thing to do is sort our dataframe and check out the results.
If you reached the end of this post, congrats and grab Joey Slye if he's still on your waivers. JK, he's probably not.
Thanks for reading! You guys are awesome.