So, my goal here is to create an Shiny application which takes user's input, changes it into a matrix, then uses a pre-saved Keras model (basically saved weights) to predict a certain variable of his (and prints it). I am new to Keras and Shiny, so I'd appreciate any help. My program shows the user input correctly, but it is evaluating and printing the output where the problems begin. Any help will be appreciated! Code is below:
server <- function(input, output) {
hisdata <- matrix(cbind(input$VK_001, input$VK_002, input$VK_003, input$VK_004,input$VK_005,input$VK_006,input$VK_006, input$VK_007, input$VK_008, input$VK_009,input$VK_010,input$VK_011, input$VK_012, input$VK_013,input$VK_015, input$VK_017, input$VK_018, input$VK_021, input$VK_022, input$VK_024, input$VK_025, input$VK_027, input$VK_028, input$VK_030, input$VK_031, input$VK_033, input$VK_034, input$VK_036, input$VK_037, input$VK_039, input$VK_040, input$VK_041))
test_data <- hisdata
model <- load_model_hdf5("my_model_bft_003.h5")
test_predictions <- model %>% predict(test_data)
output$oid1 <- renderPrint({x <- test_predictions[ , 1]
print(x)
})
}
ui <- fluidPage(
# App title ----
titlePanel("Shiny + KEras!"),
# Sidebar layout with input and output definitions ----
sidebarLayout(
# Sidebar panel for inputs ----
sidebarPanel(
# Input: numeric----
numericInput("VK_001", "Value:", 10, min = 1),
numericInput("VK_002", "Value:", 10, min = 1),
numericInput("VK_003", "Value:", 10, min = 1),
numericInput("VK_004", "Value:", 10, min = 1),
numericInput("VK_005", "Value:", 10, min = 1),
numericInput("VK_006", "Value:", 10, min = 1),
numericInput("VK_007", "Value:", 10, min = 1),
numericInput("VK_008", "Value:", 10, min = 1),
numericInput("VK_009", "Value:", 10, min = 1),
numericInput("VK_010", "Value:", 10, min = 1),
numericInput("VK_011", "Value:", 10, min = 1),
numericInput("VK_012", "Value:", 10, min = 1),
numericInput("VK_013", "Value:", 10, min = 1),
numericInput("VK_015", "Value:", 10, min = 1),
numericInput("VK_017", "Value:", 10, min = 1),
numericInput("VK_018", "Value:", 10, min = 1),
numericInput("VK_021", "Value:", 10, min = 1),
numericInput("VK_022", "Value:", 10, min = 1),
numericInput("VK_024", "Value:", 10, min = 1),
numericInput("VK_025", "Value:", 10, min = 1),
numericInput("VK_027", "Value:", 10, min = 1),
numericInput("VK_028", "Value:", 10, min = 1),
numericInput("VK_030", "Value:", 10, min = 1),
numericInput("VK_031", "Value:", 10, min = 1),
numericInput("VK_033", "Value:", 10, min = 1),
numericInput("VK_034", "Value:", 10, min = 1),
numericInput("VK_036", "Value:", 10, min = 1),
numericInput("VK_037", "Value:", 10, min = 1),
numericInput("VK_039", "Value:", 10, min = 1),
numericInput("VK_040", "Value:", 10, min = 1),
numericInput("VK_041", "Value:", 10, min = 1)
),
# Main panel for displaying outputs ----
mainPanel(
h4('Predicted values'),
verbatimTextOutput("oid1"))
)
)
shinyApp(ui = ui, server = server)
The desired output is a 1x1 vector of values (predicted value). An input consists of 1x32 (1 row, 32 columns) matrix of numeric values (integers) from 1 to 10.