Please i need help on the development of a binary classification predictive model with shiny, i have some input that after it has been inserted i expect shiny to display a result either ebola or lassa using support vector machine. Below is my code
library(shiny)
library(e1071)
library(caret)
mydata<-read.csv("C:/Users/PC/Documents/lasebo1.csv")
mymodel<-svm(Target~., data=mydata, kernel="radial")
ui = fluidPage(
# this is an input object
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="Abdminal 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 = function (input,output) {
data <- reactive({
req(input$gender)
data.frame(age=input$mydata$age,
gender=input$mydata$gender,
Fever=input$mydata$Fever,
Headache=input$mydata$Headache,
Abnormal_heart_rhythm=input$mydata$Abnormal_heart_rhythm,
Pain=input$mydata$Pain,
diarrhea=input$mydata$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)