I am playing around with Adult Dataset https://archive.ics.uci.edu/ml/datasets/adult and R. I am trying to use the neuralnet
package to train a Neural Network with Back propagation. I have cleaned the data. Now I am trying to run this part :
n <- names(cleanTrain)
f <- as.formula(paste("income~", paste(n[!n %in% "income"], collapse = " + ")))
nn <- neuralnet(f, data=cleanTrain, hidden = 10, algorithm = "backprop", learningrate=0.35)
I get this ERROR:
Error in neurons[[i]] %*% weights[[i]] : requires numeric/complex matrix/vector arguments
PS:
income ~ age + workclass + education + education.num + marital.status + occupation + relationship + race +sex + capital.gain + capital.loss + hours.per.week + native.country
Which is the error?
Hello first use a function to clean the Adult database, which you can find at Statistical Consulting Group , then convert all the variables into numeric, if the backpropagation algorithm does not work. You can see an example at neural net in R . Finally apply the algorithm with the following code.
source("http://scg.sdsu.edu/wp-content/uploads/2013/09/dataprep.r")
train = as.data.frame(sapply(data$train, as.numeric))
train$income = train$income-1
library(neuralnet)
n <- names(train)
f <- as.formula(paste("income~", paste(n[!n %in% "income"], collapse = " + ")))
nn <- neuralnet(f,data=train,hidden=10,err.fct="sse",linear.output=FALSE,algorithm="backprop",learningrate=0.35)
nn
I hope it helps you. regards
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.