Network Aplication
library(neuralnet)
iris.net <- neuralnet(setosa+versicolor+virginica ~
Sepal.Length + Sepal.Width + Petal.Length + Petal.Width,
data=iris.train, hidden=c(10,10), rep = 5, err.fct = "ce",
linear.output = F, lifesign = "minimal", stepmax = 1000000,
threshold = 0.001)
hidden: 10, 10 thresh: 0.001 rep: 1/5 steps: 1315 error: 0.00014 time: 0.28 secs
hidden: 10, 10 thresh: 0.001 rep: 2/5 steps: 631 error: 0.00014 time: 0.1 secs
hidden: 10, 10 thresh: 0.001 rep: 3/5 steps: 2748 error: 6e-05 time: 0.46 secs
hidden: 10, 10 thresh: 0.001 rep: 4/5 steps: 665 error: 0.00011 time: 0.12 secs
hidden: 10, 10 thresh: 0.001 rep: 5/5 steps: 820 error: 0.00011 time: 0.15 secs
Predicting Result
iris.prediction <- compute(iris.net, iris.valid[-5:-8])
idx <- apply(iris.prediction$net.result, 1, which.max)
predicted <- c('setosa', 'versicolor', 'virginica')[idx]
table(predicted, iris.valid$Species)
predicted setosa versicolor virginica
setosa 29 0 0
versicolor 0 25 5
virginica 0 1 15