# NOT RUN {
# Create a dataset
dataset <- iris
dataset$Petal.Length <- NULL
dataset$Petal.Width <- NULL
dataset <- dataset[dataset$Species != "versicolor",]
dataset$Code <- as.integer(dataset$Species == "virginica")
dataset <- dataset[sample(20),]
# Create the network
net <- neuralNet(2, perceptronLayer(1))
# Train the network, takes a while
net$train(dataset[,c(1,2), drop=FALSE], dataset[,'Code', drop=FALSE], epochs = 10)
# Check the output
net$compute(c(1,2))
# See accuracy
net$validationScore(dataset[,c(1,2), drop=FALSE], dataset[,'Code', drop=FALSE])
# }
Run the code above in your browser using DataLab