Spaces:
Sleeping
Sleeping
Commit
·
5b39c6e
1
Parent(s):
839ae03
update shiny app
Browse files
app.R
CHANGED
@@ -1,51 +1,40 @@
|
|
1 |
library(shiny)
|
2 |
library(bslib)
|
3 |
-
library(
|
4 |
-
library(ggplot2)
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
df_num <- df |> select(where(is.numeric), -Year)
|
9 |
|
10 |
-
ui <-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
),
|
23 |
-
|
24 |
-
)
|
|
|
25 |
)
|
26 |
|
27 |
server <- function(input, output, session) {
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
theme(legend.position = "bottom"),
|
36 |
-
if (input$by_species) aes(color=Species),
|
37 |
-
geom_point(),
|
38 |
-
if (input$smooth) geom_smooth()
|
39 |
)
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
p <- p |> ggExtra::ggMarginal(type = margin_type, margins = "both",
|
44 |
-
size = 8, groupColour = input$by_species, groupFill = input$by_species)
|
45 |
-
}
|
46 |
-
|
47 |
-
p
|
48 |
-
}, res = 100)
|
49 |
}
|
50 |
|
51 |
-
shinyApp(ui, server)
|
|
|
1 |
library(shiny)
|
2 |
library(bslib)
|
3 |
+
library(vetiver)
|
|
|
4 |
|
5 |
+
endpoint <-
|
6 |
+
vetiver_endpoint("https://jameshwade-penguins-model.hf.space/predict")
|
|
|
7 |
|
8 |
+
ui <- bslib::page_sidebar(
|
9 |
+
sidebar = sidebar(
|
10 |
+
selectInput("species", "Select Species",
|
11 |
+
choices = c("Adelie", "Chinstrap", "Gentoo")),
|
12 |
+
sliderInput("bill_length_mm", "Enter Bill Length (mm):",
|
13 |
+
min = 30, max = 60, step = 0.5, value = 45),
|
14 |
+
sliderInput("bill_depth_mm", "Enter Bill Depth (mm):",
|
15 |
+
min = 10, max = 22, step = 0.5, value = 15),
|
16 |
+
sliderInput("flipper_length_mm", "Enter Flipper Length (mm):",
|
17 |
+
min = 170, max = 235, step = 0.5, value = 200),
|
18 |
+
sliderInput("body_mass_g", "Enter Body Mass (g):",
|
19 |
+
min = 2700, max = 6300, step = 10, value = 3500),
|
20 |
+
actionButton("predict", "Predict"),
|
21 |
+
open = TRUE
|
22 |
+
),
|
23 |
+
verbatimTextOutput("info")
|
24 |
)
|
25 |
|
26 |
server <- function(input, output, session) {
|
27 |
+
observe({
|
28 |
+
new_data <- data.frame(
|
29 |
+
species = input$species,
|
30 |
+
bill_length_mm = input$bill_length_mm,
|
31 |
+
bill_depth_mm = input$bill_depth_mm,
|
32 |
+
flipper_length_mm = input$flipper_length_mm,
|
33 |
+
body_mass_g = input$body_mass_g
|
|
|
|
|
|
|
|
|
34 |
)
|
35 |
+
prediction <- predict(endpoint, new_data)
|
36 |
+
output$info <- renderPrint(prediction)
|
37 |
+
}) |> bindEvent(input$predict)
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
}
|
39 |
|
40 |
+
shinyApp(ui, server)
|