Shny中的二进制分类预测

时间:2019-01-16 17:10:17

标签: r

我正在闪亮地设置一个Web应用程序,它需要输入并
    预测二进制输出,但输出未显示且没有     错误正在打印。

           #Load in my dataset
           mydata<-read.csv("C:/~/~/~/lasebo1.csv")
           input value  = fever,headache,pain,abnormal heart rhythm,abdominal pain,gender,age,diarrhea,hemorrhage,deaf,seizure.
       output<-Target(ebola/lassa)
           #support vector model created
           mymodel<-svm(Target~., data=mydata, kernel="radial")


        #Below are my code

       library(shiny)    library(e1071)    library(caret)
       # User Interface in shiny
       ui = fluidPage(  
           titlePanel("Predictive Model"),

           sidebarLayout(position = "left",

           sidebarPanel(textInput("name", "Enter your Name"),    

           numericInput(inputId='mydata$Age', label='Age', value = 5,min = NA, max = NA, step = NA,width = NULL),

           checkboxGroupInput(inputId='mydata$Gender', label='Gender', c('male','female'), selected = NULL, inline =   
FALSE,width = NULL),

           selectInput(inputId="mydata$Fever", label='Fever',
           c("high","normal","no","continous","pyrexia","febrile")),


           selectInput(inputId="mydata$Headache", label='Headache', c("normal","severe","serious","moderate","constant","debilitating")),

           selectInput(inputId="mydata$Abnormal_heart_rhythm", label='Abnoraml_heart_rhythm', c("yes","no")),

           selectInput(inputId="mydata$Pain", label='Pain',c("no","body","back","stomach","joint","muscle")),

           selectInput(inputId="mydata$Diarrhea", label='Diarrhea', c("yes","no")),

           selectInput(inputId="mydata$Abdominal_pain", label="Abdominal pain", c("yes","no")),

           selectInput(inputId="mydata$Hemorrhage", label = "Hemorrhage", c("yes","no")),

           selectInput(inputId="mydata$Deaf", label = "Deaf", c("yes","no")),

           selectInput(inputId="mydata$Seizure", label = "Seizure", c("yes","no"))),

         mainPanel(textOutput("Pred")))
           )
         #Server in shiny
           server = function (input,output) {
             data <- reactive({
               req(input$gender)
               data.frame(age=input$mydata$age,gender=input$gender,

           Fever=input$mydata$Fever,

           Headache=input$mydata$Headache,

           Abnormal_heart_rhythm=input$mydata$Abnormal_heart_rhythm,

           Pain=input$Pain,diarrhea=input$Diarrhea,

           abdominal_pain=input$mydata$Abdominal_pain,

           hemorrhage=input$mydata$Hemorrhae,Deaf=input$mydata$Deaf,

           Seizure=input$mydata$Seizure)
              })

             Pred <- reactive({
               predict(mymodel,data())
             })
             output$Pred <- renderPrint(Pred())
           }

           shinyApp(ui=ui,server=server)`enter code here`


           I expect the ouptput of either ebola or lassa with its accuracy, such as ebola 0.883576 or lassa 0.758974

0 个答案:

没有答案