- Notifications
You must be signed in to change notification settings - Fork4
Models for Fantasy Football Expected Points
License
ffverse/ffopportunity
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Models and Data for Expected Fantasy Points
ffopportunity builds a dataframe of Expected Fantasy Points bypreprocessing and applying an xgboost model to nflverse play-by-playdata. It also includes utilities to download precomputed data fromautomated GitHub releases.
Expected Fantasy Points are a measure of player opportunities in fantasyfootball - essentially aiming to quantify how many points the averageplayer would score given a specific situation and opportunity. It usesxgboost and tidymodels trained on public nflverse data from 2006-2020 todo this.
For more on the modeling details, see the articles posted to thiswebsite:https://ffopportunity.ffverse.com/articles/
Install the development version from GitHub with:
install.packages("ffopportunity",repos= c("https://ffverse.r-universe.dev", getOption("repos")))# or use remotes/devtools# install.packages("remotes")remotes::install_github("ffverse/ffopportunity")
The two main functions of {ffopportunity} areep_load()
andep_build()
.
You can download the latest version of the EP data withep_load()
asfollows:
library(ffopportunity)#> Warning: package 'ffopportunity' was built under R version 4.2.1ep_load(season=2020:2021,type="weekly")#> → <ffopportunity predictions>#> → Generated 2022-09-12 12:59:18 with ep model version "latest"#> # A tibble: 11,769 × 159#> season posteam week game_id playe…¹ full_…² posit…³ pass_…⁴ rec_a…⁵ rush_…⁶#> <chr> <chr> <dbl> <chr> <chr> <chr> <chr> <dbl> <dbl> <dbl>#> 1 2020 SF 1 2020_01… 00-003… Jimmy … QB 33 0 1#> 2 2020 SF 1 2020_01… 00-003… George… TE 0 5 1#> 3 2020 ARI 1 2020_01… 00-003… Kyler … QB 39 0 11#> 4 2020 ARI 1 2020_01… 00-003… DeAndr… WR 0 16 0#> 5 2020 ARI 1 2020_01… 00-002… Larry … WR 0 5 0#> 6 2020 ARI 1 2020_01… <NA> <NA> <NA> 0 2 0#> 7 2020 SF 1 2020_01… 00-003… Raheem… RB 0 5 15#> 8 2020 ARI 1 2020_01… 00-003… Kenyan… RB 0 2 16#> 9 2020 ARI 1 2020_01… 00-003… Christ… WR 0 5 0#> 10 2020 SF 1 2020_01… 00-003… Trent … WR 0 5 0#> # … with 11,759 more rows, 149 more variables: pass_air_yards <dbl>,#> # rec_air_yards <dbl>, pass_completions <dbl>, receptions <dbl>,#> # pass_completions_exp <dbl>, receptions_exp <dbl>, pass_yards_gained <dbl>,#> # rec_yards_gained <dbl>, rush_yards_gained <dbl>,#> # pass_yards_gained_exp <dbl>, rec_yards_gained_exp <dbl>,#> # rush_yards_gained_exp <dbl>, pass_touchdown <dbl>, rec_touchdown <dbl>,#> # rush_touchdown <dbl>, pass_touchdown_exp <dbl>, rec_touchdown_exp <dbl>, …#> # ℹ Use `print(n = ...)` to see more rows, and `colnames()` to see all variable names
You can also build EP from base nflverse data withep_build()
asfollows:
ep_build(season=2021,version="latest")
#> -- Starting ep build for 2021 season(s)! 2022-01-11 07:58:44 -------------------#> > Loading pbp 2022-01-11 07:58:44#> > Preprocessing pbp 2022-01-11 07:58:46#> > Generating predictions 2022-01-11 07:58:54#> > Summarizing data 2022-01-11 07:59:33#> -- Finished building ep for 2021 season(s)! 2022-01-11 07:59:33 ----------------#> > <ffopportunity predictions>#> > Generated 2022-01-11 07:59:33 with model version latest#> List of 5#> $ ep_weekly : tibble [5,756 x 159] (S3: tbl_df/tbl/data.frame)#> $ ep_pbp_pass: tibble [18,747 x 57] (S3: tbl_df/tbl/data.table/data.frame)#> $ ep_pbp_rush: tibble [14,038 x 47] (S3: tbl_df/tbl/data.table/data.frame)#> $ ep_version : chr "latest"#> $ timestamp : POSIXct[1:1], format: "2022-01-11 07:59:33"
ffopportunity data is automated with GitHub Actions and can be manuallydownloaded in RDS, parquet, and csv formats from thereleasespage.
The best places to get help on this package are:
- thenflverse discord (forboth this package as well as anything R/NFL related)
- openinganissue
Many hands make light work! Here are some ways you can contribute tothis project:
You canopen anissueif you’d like to request specific data or report a bug/error.
If you’d like to contribute code, please check outthe contributionguidelines.
The R code for this package is released as open source under theGPL v3License. The models andexpected points data included within this package’s are licensed underCreative Commons Attribution-ShareAlike 4.0 InternationalLicense
Please note that the ffopportunity project is released with aContributor Code ofConduct.By contributing to this project, you agree to abide by its terms.
About
Models for Fantasy Football Expected Points