Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Offense safety fix #153

Merged
merged 10 commits into from
Dec 23, 2020
Merged

Offense safety fix #153

merged 10 commits into from
Dec 23, 2020

Conversation

mrcaseb
Copy link
Member

@mrcaseb mrcaseb commented Dec 22, 2020

This should fix the score calculation for home_team and away_team in case the posteam scores a safety

@mrcaseb mrcaseb linked an issue Dec 22, 2020 that may be closed by this pull request
@mrcaseb
Copy link
Member Author

mrcaseb commented Dec 22, 2020

The following games have got wrong scores in the pbp data compared to Lee's games data.
image

Using the following code with this branch

library(dplyr)
wrong_scores <- c(
  "1999_04_PHI_NYG",
  "2000_03_ATL_CAR",
  "2000_11_OAK_DEN",
  "2000_16_OAK_SEA",
  "2001_14_DAL_SEA",
  "2003_03_NO_TEN",
  "2006_05_STL_GB",
  "2009_08_STL_DET",
  "2009_17_IND_BUF",
  "2011_14_TB_JAX",
  "2013_07_CIN_DET",
  "2015_06_ARI_PIT",
  "2015_09_PHI_DAL",
  "2015_15_KC_BAL",
  "2016_01_MIN_TEN",
  "2016_05_NE_CLE",
  "2017_08_LAC_NE",
  "2017_13_DEN_MIA"
  "2018_14_JAX_TEN",
  "2020_15_KC_NO" 
)

pbp <- fast_scraper(wrong_scores, pp = T)
games <- readRDS(url("https://github.com/leesharpe/nfldata/blob/master/data/games.rds?raw=true"))

scores <- pbp %>% 
  group_by(game_id) %>% 
  summarise(
    # alternatively use max instead of last
    home_score_pbp = last(total_home_score),
    away_score_pbp = last(total_away_score)
  ) %>% 
  left_join(games %>% select(game_id, home_score, away_score), by = "game_id") %>% 
  filter(home_score != home_score_pbp | away_score != away_score_pbp)

we get
image

It looks like the safety on offense problem is solved but there are still 10 problematic games, where the pbp score is much more off than just 2 points. This could be another problem, most likely unrelated to the offensive safeties.

@mrcaseb mrcaseb linked an issue Dec 22, 2020 that may be closed by this pull request
@guga31bb guga31bb merged commit 77ac015 into master Dec 23, 2020
@mrcaseb mrcaseb deleted the off-safety-fix branch January 4, 2021 10:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Broken scores in play-by-play Safety gives points to wrong team on punts
2 participants