Skip to contents

This function builds Expected Fantasy Points predictions by downloading the xgboost models and play-by-play data, applying the model, and summarizing to player level.

Usage

ep_build(season = nflreadr::most_recent_season(), version = "latest")

Arguments

season

a numeric vector of seasons that defaults to most recent season. Must be later than 2006.

version

an EP model version - one of "latest" (default) or "v1.0.0" (these are currently identical)

Value

a list containing three dataframes: ep_weekly provides a game-level summary by player, ep_pbp_pass provides EP data on pass plays, and ep_pbp_rush provides EP data on rush plays.

See also

Other main: ep_load()

Examples

# \donttest{
try({ # prevents cran-related errors
  ep_build(season = 2021)
})
#> ── Starting ep build for 2021 season(s)! 2024-08-09 03:32:30.984746 ────────────
#> → Downloading EP models, if required 2024-08-09 03:32:30.98874
#>  Could not find ep model version "latest" in cache directory: 
#> ~/.cache/ffopportunity 
#>  Attempting download
#>  Successfully downloaded ep model version "latest" to cache!
#> → Loading pbp 2024-08-09 03:32:32.886529
#> → Preprocessing pbp 2024-08-09 03:32:36.562289
#> → Generating predictions 2024-08-09 03:32:46.821714
#> → Summarizing data 2024-08-09 03:32:47.576926
#> ── Finished building ep for 2021 season(s)! 2024-08-09 03:32:47.579757 ─────────
#> → <ffopportunity predictions>
#> → Generated 2024-08-09 03:32:47.58329 with model version latest
#> List of 5
#>  $ ep_weekly  : tibble [6,065 × 159] (S3: tbl_df/tbl/data.frame)
#>  $ ep_pbp_pass: nflvrs_d [19,769 × 57] (S3: nflverse_data/tbl_df/tbl/data.table/data.frame)
#>  $ ep_pbp_rush: nflvrs_d [15,164 × 50] (S3: nflverse_data/tbl_df/tbl/data.table/data.frame)
#>  $ ep_version : chr "latest"
#>  $ timestamp  : POSIXct[1:1], format: "2024-08-09 03:32:47"
# }