Spaces:
Runtime error
Runtime error
Upload 2 files
Browse files
FB.model
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0634ac1f0f8e9b37ea215740d541a0f5ca48cec0c7f048d655ac204de20ea2be
|
| 3 |
+
size 2442683
|
app.R
CHANGED
|
@@ -1,58 +1,88 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
#
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#
|
| 2 |
+
# This is a Shiny web application. You can run the application by clicking
|
| 3 |
+
# the 'Run App' button above.
|
| 4 |
+
#
|
| 5 |
+
# Find out more about building applications with Shiny here:
|
| 6 |
+
#
|
| 7 |
+
# https://shiny.posit.co/
|
| 8 |
+
#
|
| 9 |
+
|
| 10 |
+
library(shiny)
|
| 11 |
+
library(dplyr)
|
| 12 |
+
library(data.table)
|
| 13 |
+
library(xgboost)
|
| 14 |
+
library(caret)
|
| 15 |
+
# Define UI for application that draws a histogram
|
| 16 |
+
ui <- fluidPage(
|
| 17 |
+
|
| 18 |
+
# Application title
|
| 19 |
+
titlePanel("TimStuff Fastball Calculator"),
|
| 20 |
+
|
| 21 |
+
# Sidebar with a slider input for number of bins
|
| 22 |
+
sidebarLayout(
|
| 23 |
+
sidebarPanel(
|
| 24 |
+
selectInput("phand",
|
| 25 |
+
"Hand",
|
| 26 |
+
c("R","L")),
|
| 27 |
+
numericInput("velo",
|
| 28 |
+
"Velocity /mph",90),
|
| 29 |
+
numericInput("ivb",
|
| 30 |
+
"Induced Vertical Break (IVB) /in. (IVB)",16),
|
| 31 |
+
numericInput("hb",
|
| 32 |
+
"Horizontal Break (HB) /in. (Pitcher's Perspective)",6),
|
| 33 |
+
numericInput("spinrate",
|
| 34 |
+
"Spin Rate /rpm",2300),
|
| 35 |
+
numericInput("ext",
|
| 36 |
+
"Extension /ft",6),
|
| 37 |
+
numericInput("spinaxisdiff",
|
| 38 |
+
"Spin Axis Difference (-180 - 180) /degrees",0),
|
| 39 |
+
numericInput("x0","Horizntal Release Point /ft. (Batter's Perspective)",0),
|
| 40 |
+
numericInput("z0","Vertical Release Point /ft. (Batter's Perspective)", 0),
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
),
|
| 44 |
+
|
| 45 |
+
# Show a plot of the generated distribution
|
| 46 |
+
mainPanel(
|
| 47 |
+
textOutput("distPlot")
|
| 48 |
+
)
|
| 49 |
+
)
|
| 50 |
+
)
|
| 51 |
+
|
| 52 |
+
# Define server logic required to draw a histogram
|
| 53 |
+
server <- function(input, output) {
|
| 54 |
+
|
| 55 |
+
output$distPlot <- renderText({
|
| 56 |
+
data <- as.data.frame(5)
|
| 57 |
+
setnames(data,"5","start_speed")
|
| 58 |
+
data$start_speed <- input$velo
|
| 59 |
+
data$IVB <- input$ivb
|
| 60 |
+
if(input$phand == "L"){
|
| 61 |
+
data$HB <- input$hb * -1
|
| 62 |
+
}
|
| 63 |
+
else{
|
| 64 |
+
data$HB <- input$hb
|
| 65 |
+
}
|
| 66 |
+
data$EAA <- input$ext / 6.3
|
| 67 |
+
if(input$phand == "L"){
|
| 68 |
+
data$x0 <- input$x0 * -1
|
| 69 |
+
}
|
| 70 |
+
else{
|
| 71 |
+
data$x0 <- input$x0
|
| 72 |
+
}
|
| 73 |
+
data$z0 <- input$z0
|
| 74 |
+
data$spin_rate <- input$spinrate
|
| 75 |
+
data$SADiff <- input$spinaxisdiff
|
| 76 |
+
|
| 77 |
+
data <- as.matrix(data)
|
| 78 |
+
|
| 79 |
+
prediction <-predict(FBMod,data)
|
| 80 |
+
TimStuff <- (50 - (prediction - -0.0004397118)/ 0.2180433 * 10)
|
| 81 |
+
# FBMod <- xgb.load("FB.model")
|
| 82 |
+
# vip(FBMod)
|
| 83 |
+
return(TimStuff)
|
| 84 |
+
})
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
# Run the application
|
| 88 |
+
shinyApp(ui = ui, server = server)
|