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)! 2022-10-17 15:10:13 ───────────────────
#> → Downloading EP models, if required 2022-10-17 15:10:13
#> ℹ Could not find ep model version "latest" in cache directory:
#> ~/.cache/ffopportunity
#> ℹ Attempting download
#> ✔ Successfully downloaded ep model version "latest" to cache!
#> → Loading pbp 2022-10-17 15:10:15
#> → Preprocessing pbp 2022-10-17 15:10:20
#> → Generating predictions 2022-10-17 15:10:37
#> → Summarizing data 2022-10-17 15:12:43
#> ── Finished building ep for 2021 season(s)! 2022-10-17 15:12:43 ────────────────
#> → <ffopportunity predictions>
#> → Generated 2022-10-17 15:12:43 with model version latest
#> List of 5
#> $ ep_weekly : tibble [6,018 × 159] (S3: tbl_df/tbl/data.frame)
#> $ ep_pbp_pass: nflverse_data [19,689 × 57] (S3: nflverse_data/tbl_df/tbl/data.table/data.frame)
#> $ ep_pbp_rush: nflverse_data [14,649 × 47] (S3: nflverse_data/tbl_df/tbl/data.table/data.frame)
#> $ ep_version : chr "latest"
#> $ timestamp : POSIXct[1:1], format: "2022-10-17 15:12:43"
# }