Loading Package and treating the data
data(iris)
iris$setosa <- iris$Species=="setosa"
iris$virginica <- iris$Species == "virginica"
iris$versicolor <- iris$Species == "versicolor"
iris.train.idx <- sample(x = nrow(iris), size = nrow(iris)*0.5)
iris.train <- iris[iris.train.idx,]
iris.valid <- iris[-iris.train.idx,]
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: 1058 error: 0.00016 time: 0.41 secs
## hidden: 10, 10 thresh: 0.001 rep: 2/5 steps: 481 error: 0.00015 time: 0.27 secs
## hidden: 10, 10 thresh: 0.001 rep: 3/5 steps: 912 error: 0.00012 time: 0.31 secs
## hidden: 10, 10 thresh: 0.001 rep: 4/5 steps: 668 error: 0.00025 time: 0.24 secs
## hidden: 10, 10 thresh: 0.001 rep: 5/5 steps: 1017 error: 0.00016 time: 0.39 secs
plot(iris.net, rep="best")

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 26 0 0
## versicolor 0 22 1
## virginica 0 1 25