Skip to content

Commit

Permalink
Improve Pythagorean wins
Browse files Browse the repository at this point in the history
  • Loading branch information
topfunky committed Jul 16, 2022
1 parent de403da commit a298b62
Showing 1 changed file with 32 additions and 5 deletions.
37 changes: 32 additions & 5 deletions nfl_expected_wins.R
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,12 @@ plot_wins <- function(data, start_year, end_year, title) {
size = 4,
alpha = 0.1
) +
# Predicted wins
geom_line(aes(x = Year, y = PredictedW), color = vividchalk_cyan) +
# Pythagorean wins
geom_line(aes(x = Year, y = PythagoreanW), color = vividchalk_orange) +
# DVOA predicted wins
geom_line(aes(x = Year, y = DVOAW), color = vividchalk_yellow) +
# Pythagorean wins
geom_line(aes(x = Year, y = PythagoreanW), color = vividchalk_orange) +
# Predicted wins
geom_line(aes(x = Year, y = PredictedW), color = vividchalk_cyan) +
# Actual
geom_line(color = "white", size = 1) + geom_point(color = "white") +
# Styling
Expand Down Expand Up @@ -353,6 +353,33 @@ run_report <- function() {
width = 6,
height = 4
)

return(data)
}

run_report()
result = run_report()


require(rpart)
require(rpart.plot)
binary.model <- rpart(
W ~ ZDefPassYardsPerAttempt +
ZDefRunYardsPerAttempt +
ZDefIntRate +
ZDefFumbleRate +
ZOffPassYardsPerAttempt +
ZOffRunYardsPerAttempt +
ZOffPenYardsPerPlay +
ZOffIntRate +
ZOffFumbleRate,
data = result #,
# cp = 0.02
)

binary.model |> rpart.plot(
main = "Expected Wins",
roundint = FALSE,
cex = 0.8,
fallen.leaves = TRUE,
extra = 101
)

0 comments on commit a298b62

Please sign in to comment.