Prediction model in Shiny App

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Prediction model in Shiny App

R help mailing list-2
Hi everyone,

I'm new in trying Shiny app in R and for the following question I need your help. I have a Random Forest model built with Caret Package on iris data set and then with Shiny I need a UI which I can upload a .csv file as the test set and give it to the trained model and then see what is the prediction on the test set in UI. Here is the model:


     > library(caret)
     > library(shiny)
     > data("iris")
     >model <- train(Species~., data=iris, trControl=train_control, method="nb")

and the code for ui and server

     > ui = fluidPage(
     titlePanel("Prediction with Random Forest"),
     sidebarLayout(position = "right",
     sidebarPanel(fileInput('datafile', 'Choose CSV file',
     accept=c('text/csv', 'text/comma-separated-values,text/plain'))),
     textOutput(outputId = 'Pred')


     >  server = function (input,output) {

     mydata <- reactive({

     inFile <- input$datafile

      if (is.null(inFile))

      tbl <- read.csv(inFile$datapath, header=input$header, sep=input$sep,  dec = input$dec)


    output$Pred <- renderPrint(pred())

   >     shinyApp(ui=ui,server=server)

so I want to read the .csv file, give it to the model and then show the class of the test set in UI.
Thanks for any help.


[hidden email] mailing list -- To UNSUBSCRIBE and more, see
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.