这个数据是关于农民风险态度的。利用人工神经网络模型中的风险干旱模型,对风险态度进行分类。
x=data.frame(x$Riskdrought, x$RiskAtt)
colnames(x)=c("Riskdrought", "RiskAtt")
head(x)
#Split the data set x into training and test
s=sample(nrow(x), floor(0.8*nrow(x)))
x.train=x[s, ]
head(x.train)
x.test=x[-s, -2]## does not contain classifier
head(x.test)
x.test.y=x[-s, 2] ## contain the classifier
head(x.test.y)
nn=neuralnet(RiskAtt~Riskdrought, data =x.train, hidden = 1,
act.fct = "logistic", linear.output = FALSE)
plot(nn)
##Compute the error rate using test dataset
pr.test=compute(nn, x.test)当我想使用测试数据集计算错误率时,它给出了长度为零的误差。虽然我检查了我的x.test,它是好的。
发布于 2022-04-22 16:16:26
由于从x.test-s-2中排除了一个列,所以它不再是一个dataframe,一个选项是在dataframe中使用3个变量。
https://stackoverflow.com/questions/71881360
复制相似问题