shinypenguins / app.R
jameshwade's picture
update shiny app
5b39c6e
library(shiny)
library(bslib)
library(vetiver)
endpoint <-
vetiver_endpoint("https://jameshwade-penguins-model.hf.space/predict")
ui <- bslib::page_sidebar(
sidebar = sidebar(
selectInput("species", "Select Species",
choices = c("Adelie", "Chinstrap", "Gentoo")),
sliderInput("bill_length_mm", "Enter Bill Length (mm):",
min = 30, max = 60, step = 0.5, value = 45),
sliderInput("bill_depth_mm", "Enter Bill Depth (mm):",
min = 10, max = 22, step = 0.5, value = 15),
sliderInput("flipper_length_mm", "Enter Flipper Length (mm):",
min = 170, max = 235, step = 0.5, value = 200),
sliderInput("body_mass_g", "Enter Body Mass (g):",
min = 2700, max = 6300, step = 10, value = 3500),
actionButton("predict", "Predict"),
open = TRUE
),
verbatimTextOutput("info")
)
server <- function(input, output, session) {
observe({
new_data <- data.frame(
species = input$species,
bill_length_mm = input$bill_length_mm,
bill_depth_mm = input$bill_depth_mm,
flipper_length_mm = input$flipper_length_mm,
body_mass_g = input$body_mass_g
)
prediction <- predict(endpoint, new_data)
output$info <- renderPrint(prediction)
}) |> bindEvent(input$predict)
}
shinyApp(ui, server)