Iris Prediction on the Web



Iris Prediction on the Web

0 0


devdataprod-016-slidify


On Github s-kumar-edu / devdataprod-016-slidify

Iris Prediction on the Web

devdataprod-016

Random Forest Training

library(shiny)
library(randomForest)
library(caret)
data(iris)
inTrain <- createDataPartition(iris$Species, list = F)
train <- iris[inTrain, ]
test <- iris[-inTrain, ]

fit <- randomForest(Species ~ ., data = iris)

print(fit)
## 
## Call:
##  randomForest(formula = Species ~ ., data = iris) 
##                Type of random forest: classification
##                      Number of trees: 500
## No. of variables tried at each split: 2
## 
##         OOB estimate of  error rate: 4.67%
## Confusion matrix:
##            setosa versicolor virginica class.error
## setosa         50          0         0        0.00
## versicolor      0         47         3        0.06
## virginica       0          4        46        0.08

Random Forest Prediction

predictions <- predict(fit, test)
head(predictions, 10)
##      2      4      5      6      8     14     15     17     19     22 
## setosa setosa setosa setosa setosa setosa setosa setosa setosa setosa 
## Levels: setosa versicolor virginica

Web Application

Questions?