TimStats commited on
Commit
7391d42
·
verified ·
1 Parent(s): d04982c

Update app.R

Browse files
Files changed (1) hide show
  1. app.R +7 -2
app.R CHANGED
@@ -215,8 +215,9 @@ calculate_timstuff <- function(game) {
215
  is_strike_swinging = ifelse(is_strike_swinging, 1, 0),
216
  Pitch = pitch_name,
217
  ishandL = ifelse(phand == "L",1,0))
 
218
 
219
- feature_vars <- c("ishandL","start_speed", "IVB", "HB", "EAA", "x0", "z0", "spin_rate","SADiff","primary_speed","primary_IVB","primary_HB")
220
  complete_rows <- complete.cases(game[, feature_vars])
221
  game_complete <- game[complete_rows, ]
222
  game_na <- game[!complete_rows,]
@@ -224,7 +225,11 @@ calculate_timstuff <- function(game) {
224
 
225
  rhp <- game_complete
226
 
227
- rhp$TimStuff <- scale_TimStuff(predict(model, as.matrix(cbind(rhp$ishandL,rhp$start_speed, rhp$IVB, rhp$HB, rhp$EAA, rhp$x0, rhp$z0, rhp$spin_rate, rhp$SADiff,rhp$primary_speed,rhp$primary_IVB,rhp$primary_HB))), -0.002491156, 0.0078211)
 
 
 
 
228
 
229
  game_complete <- rbind(rhp,game_na)
230
  return(game_complete)
 
215
  is_strike_swinging = ifelse(is_strike_swinging, 1, 0),
216
  Pitch = pitch_name,
217
  ishandL = ifelse(phand == "L",1,0))
218
+ # game <- calculate_primary(game)
219
 
220
+ feature_vars <- c("ishandL","start_speed", "IVB", "HB", "EAA", "x0", "z0", "spin_rate","SADiff","primvelodiff","primivbdiff","primhbdiff")
221
  complete_rows <- complete.cases(game[, feature_vars])
222
  game_complete <- game[complete_rows, ]
223
  game_na <- game[!complete_rows,]
 
225
 
226
  rhp <- game_complete
227
 
228
+ # rhp <- game_complete[game_complete$ishandL == 0]
229
+ #
230
+ # lhp$TimStuff <- scale_TimStuff(predict(model, as.matrix(cbind(lhp$ishandL,lhp$start_speed, lhp$IVB, lhp$HB, lhp$EAA, lhp$x0, lhp$z0, lhp$spin_rate, lhp$SADiff,lhp$primary_speed,lhp$primary_IVB,lhp$primary_HB))), -0.00249975, 0.007566558)
231
+
232
+ rhp$TimStuff <- scale_TimStuff(predict(model, as.matrix(cbind(rhp$ishandL,rhp$start_speed, rhp$IVB, rhp$HB, rhp$EAA, rhp$x0, rhp$z0, rhp$spin_rate, rhp$SADiff,rhp$primvelodiff,rhp$primivbdiff,rhp$primhbdiff))), -0.002491156, 0.0078211)
233
 
234
  game_complete <- rbind(rhp,game_na)
235
  return(game_complete)