R 神经网络
R neural Networks
我在玩成人数据集
https://archive.ics.uci.edu/ml/datasets/adult 和 R。我正在尝试使用 neuralnet
包来训练具有反向传播的神经网络。我已经清理了数据。现在我正在尝试 运行 这部分 :
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)
我得到这个错误:
Error in neurons[[i]] %*% weights[[i]] : requires numeric/complex matrix/vector arguments
P.S:
- 我将火车加载为 cleanTrain
- n 获取数据集的所有名称
- f returns
income ~ age + workclass + education + education.num + marital.status + occupation + relationship + race +sex + capital.gain + capital.loss + hours.per.week + native.country
哪个错误?
您好首先使用一个函数来清理成人数据库,您可以在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找到它。最后使用以下代码应用算法。
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
希望对您有所帮助。问候
我在玩成人数据集
https://archive.ics.uci.edu/ml/datasets/adult 和 R。我正在尝试使用 neuralnet
包来训练具有反向传播的神经网络。我已经清理了数据。现在我正在尝试 运行 这部分 :
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)
我得到这个错误:
Error in neurons[[i]] %*% weights[[i]] : requires numeric/complex matrix/vector arguments
P.S:
- 我将火车加载为 cleanTrain
- n 获取数据集的所有名称
- f returns
income ~ age + workclass + education + education.num + marital.status + occupation + relationship + race +sex + capital.gain + capital.loss + hours.per.week + native.country
哪个错误?
您好首先使用一个函数来清理成人数据库,您可以在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找到它。最后使用以下代码应用算法。
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
希望对您有所帮助。问候