Created
July 5, 2019 22:11
-
-
Save JhonatanHern/69a9738cdf5107f41d3e254fbc03ac2c to your computer and use it in GitHub Desktop.
Neural network used for clasification with the iris dataset
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(neuralnet) | |
library(dplyr) | |
random.iris <- sample_frac(iris,1) | |
miris <- random.iris[1:105,] | |
testd <- random.iris[106:150,] | |
miris <- mutate(miris, | |
setosa = Species == "setosa", | |
versicolor = Species == "versicolor", | |
virginica = Species == "virginica", | |
) | |
nn <- neuralnet( | |
setosa + versicolor + virginica ~ Sepal.Length + Sepal.Width + Petal.Length + Petal.Width, | |
data = miris, | |
hidden = c(10,10), | |
act.fct = "logistic", | |
linear.output = FALSE | |
) | |
plot(nn) | |
Predict=compute(nn,testd) | |
Predict$net.result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment