Title: | Models for Fantasy Football Expected Points |
---|---|
Description: | Downloads expected fantasy points data from 'ffverse' repositories if available, and otherwise builds up expected points data by applying models to 'nflverse' play-by-play data. |
Authors: | Joe Sydlowski [aut, cre, cph],
Tan Ho [aut] |
Maintainer: | Joe Sydlowski <[email protected]> |
License: | GPL (>= 3) |
Version: | 0.1.0.07 |
Built: | 2024-08-09 04:17:23 UTC |
Source: | https://github.com/ffverse/ffopportunity |
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.
ep_build(season = nflreadr::most_recent_season(), version = "latest")
ep_build(season = nflreadr::most_recent_season(), version = "latest")
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) |
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.
Other main:
ep_load()
try({ # prevents cran-related errors ep_build(season = 2021) })
try({ # prevents cran-related errors ep_build(season = 2021) })
This function checks the cache for a previously downloaded model and then (optionally) tries to download the model from GitHub release.
ep_cache_models( version = c("latest", "v1.0.0"), force = FALSE, ask = interactive() )
ep_cache_models( version = c("latest", "v1.0.0"), force = FALSE, ask = interactive() )
version |
one of "latest" or "v1.0.0" - currently these refer to the same thing |
force |
TRUE or FALSE - forces download regardless of currently existing |
ask |
TRUE or FALSE - ask before downloading - |
a status message after attempting to download the model.
This function downloads precomputed expected points data from the ffopportunity automated releases.
ep_load( season = nflreadr::most_recent_season(), type = c("weekly", "pbp_pass", "pbp_rush"), version = c("latest", "v1.0.0") )
ep_load( season = nflreadr::most_recent_season(), type = c("weekly", "pbp_pass", "pbp_rush"), version = c("latest", "v1.0.0") )
season |
A numeric vector of four digit years associated with given NFL seasons - defaults to latest season. |
type |
Data type - one of |
version |
EP model version: one of "latest" (default) or "v1.0.0" - these are currently identical. |
a dataframe identical to what would be returned by ffopportunity::ep_build()
for a given season.
Other main:
ep_build()
try({ ep_load() %>% head(10) ep_load(2020:2021) %>% head(10) ep_load(2021, type = "pbp_pass") %>% head(10) ep_load(2006, type = "pbp_rush", version = "v1.0.0") %>% head(10) })
try({ ep_load() %>% head(10) ep_load(2020:2021) %>% head(10) ep_load(2021, type = "pbp_pass") %>% head(10) ep_load(2006, type = "pbp_rush", version = "v1.0.0") %>% head(10) })
This function runs the prediction functions over preprocessed data.
ep_predict(preprocessed_pbp, version = c("latest", "v1.0.0"))
ep_predict(preprocessed_pbp, version = c("latest", "v1.0.0"))
preprocessed_pbp |
list with dataframes created by |
version |
ep model version - available is |
a dataframe with the expected fields added
try({ preprocessed <- readRDS(system.file("ep_preprocessed.rds",package = "ffopportunity")) # this file is equivalent to nflreadr::load_pbp(2021) %>% head(1000) %>% ep_preprocess() ep_predict(preprocessed) })
try({ preprocessed <- readRDS(system.file("ep_preprocessed.rds",package = "ffopportunity")) # this file is equivalent to nflreadr::load_pbp(2021) %>% head(1000) %>% ep_preprocess() ep_predict(preprocessed) })
This function performs pre-processing steps to make
expected points predictions on nflreadr
data
ep_preprocess(pbp)
ep_preprocess(pbp)
pbp |
pbp dataframe from |
a list of two dataframes (one for passes and one for rushes) of nflreadr data with the expectedpoints columns transformed for prediction
vignette("basic")
for example usage
try({ # catch failures for CRAN purposes pbp_download <- readRDS(system.file("pbp_download.rds",package = "ffopportunity")) # this file is equivalent to nflreadr::load_pbp(2021) %>% head(1000) ep_preprocess(pbp_download) })
try({ # catch failures for CRAN purposes pbp_download <- readRDS(system.file("pbp_download.rds",package = "ffopportunity")) # this file is equivalent to nflreadr::load_pbp(2021) %>% head(1000) ep_preprocess(pbp_download) })
This function summarizes the EP data up to the game level
ep_summarize( predicted_pbp, stat_type = c("all", "expected_points", "team_stats") )
ep_summarize( predicted_pbp, stat_type = c("all", "expected_points", "team_stats") )
predicted_pbp |
list with dataframes created by |
stat_type |
options to limit the columns returned by |
a dataframe with the expected points fields added
vignette("basic")
for example usage
try({ predicted <- readRDS(system.file("ep_predicted.rds",package = "ffopportunity")) # equivalent to nflreadr::load_pbp(2021) %>% head(100) %>% ep_preprocess() %>% ep_predict() ep_summarize(predicted) })
try({ predicted <- readRDS(system.file("ep_predicted.rds",package = "ffopportunity")) # equivalent to nflreadr::load_pbp(2021) %>% head(100) %>% ep_preprocess() %>% ep_predict() ep_summarize(predicted) })