Проблема с использованием кнопки Отправить от R Shiny - PullRequest
1 голос
/ 20 сентября 2019

Я пытаюсь создать Shiny Dashboard, чтобы показать, как работает SWM.

Вот фрагмент кода: 1

Я хочу получить поле с вопросомгиперпараметры SVM, и когда я нажимаю кнопку отправки, SVM выполняется.Однако я не знаю, как сделать эту кнопку отправки.На данный момент, когда я изменяю один гиперпараметр, SVM запускается сразу после.

Кто-нибудь знает, как заставить приборную панель ждать, пока пользователь не выберет каждый отдельный гиперпараметр и нажать кнопку подтверждения до * 1010?* выполнение SVM?

Код моего тела.R:

tabItem(
      tabName = "svm",

      fluidRow(  

        box( title = "Spécification du SVM",
             status = "primary",
             solidHeader = TRUE,
             height = "420px",
             width = 12,


                selectInput("kernel",
                             "Choose the type of kernel: ",
                             choices=c(Linear = "linear",Polynomial = "polynomial",Radial = "radial"),
                             selected = "linear"),

                # Only show this panel if the kernel is linear
                conditionalPanel(
                  condition = "input.kernel == 'linear'",
                 selectInput("classweights", "Do you want to put class weights in? :", choices=c("Yes, please", "No thanks"), selected = "No thanks"),
                 selectInput("cross", "How many k-fold? :", choices=c(1,3,5), selected = 3)
                ),
                # Only show this panel if the kernel is polynomial
                conditionalPanel(
                  condition = "input.kernel == 'polynomial'",
                  selectInput("poly", "How many degree? :", choices=c(3,4,5), selected = 3),
                  selectInput("classweights", "Do you want to put class weights in? :", choices=c("Yes, please", "No thanks"), selected = "No thanks"),
                  pickerInput("cross", "How many k-fold? :", choices=c(1,3,5), selected = 3)
                  ),
                # Only show this panel if the kernel is polynomial
                conditionalPanel(
                  condition = "input.kernel == 'radial'",
                  selectInput("classweights", "Do you want to put class weights in? :", choices=c("Yes, please", "No thanks"), selected = "No thanks"),
                  pickerInput("cross", "How many k-fold? :", choices=c(1,3,5), selected = 3)
                ),
                actionButton("go", "RUN",icon("paper-plane"), 
                             style="color: #fff; background-color: #337ab7; border-color: #2e6da4") )
      ),
      fluidRow(

        box(title = "Spécification du SVM",
            status = "primary",
            solidHeader = TRUE,
            height = "420px",
            width = 12,
            verbatimTextOutput("svm") ) ) 
      )

и код моего сервера.R:

  output$svm <- renderPrint({

    costs <- table(data$Class)
    costs[1] <- 1 
    costs[2] <- 1e5 #a class -1 mismatch has a terrible cost

    if (input$classweights == "Yes, please"){

    classifier = svm(formula = Class ~ ., 
                     credit.card.data = training_set, 
                     type = 'C-classification', 
                     kernel = input$kernel,
                     probability = TRUE,
                     cross = input$cross,
                     class.weights = costs) 
    print(summary(classifier))

    }else{
      classifier = svm(formula = Class ~ ., 
                       credit.card.data = training_set, 
                       type = 'C-classification', 
                       kernel = input$kernel,
                       probability = TRUE,
                       cross = input$cross) 
      print(summary(classifier))

    }
  })
...