I am have created a shiny app that shows how a random forest model works.
I want to use inputs from Shiny app's interface to make a classification.
This are examples of inputs
tabItem(tabName = "randomForest",
fluidRow(
h1("Select Parameters for Decision Tree")
),
fluidRow(
box(plotOutput(outputId = 'randomForest',
height = "700px", width = "500px")),
box(
title = "Fixed Acidity",
sliderInput("fixed", "TBD",
min = 0, max = 2, value = 1)),
box(
title = "Volatile Acidity",
sliderInput("vol", "Gaseous acids that contribute to the smell and taste of vinegar in wine.",
min = 0, max = 2, value = 1)),
box(
title = "Citric Acidity",
sliderInput("citric", "TBD",
min = 0, max = 1, value = 0.5)),
box(
title = "Residual Sugar",
sliderInput("resugar", "TBD",
min = 0, max = 16, value = 8)),
I have built a random forest model already and want to use predict.randomforest to make classifications. But I am not sure how to use predict.randomforest together with inputs from the Shiny app.
The random forest code
Random forest model "randomForest"
set.seed(234)
train.index=createDataPartition(data$quality,p=0.7,list=FALSE)
train=wine[train.index,]
test=wine[-train.index,]
wine.rf <- randomForest(quality~.,data=train,
# mtry=4,importance=input$importance,
#ntree=input$ntree)
pred.rf=predict(wine.rf,newdata=test[,-ncol(test)])
mean(pred.rf==test[,ncol(test)])
detach(package:rattle)
importance(wine.rf)
Thank you