r - r中神经网络分类器中的未定义列
问题描述
我正在使用 r 程序为具有 100 个观察值和 3 个属性(x、y 和 z)的随机标准随机变量拟合神经网络分类器。当隐藏节点设置为 1 时,我需要在数据中有两个类并计算测试错误。
我写了下面的代码:
nObs <- 100
x <- matrix (rnorm (nObs), ncol =2)
y <- matrix (rnorm (nObs), ncol =2)
z <- matrix (rnorm (nObs), ncol =2)
xtest <- matrix (rnorm (2*nObs*2) , ncol =2)
ytest <- sample (c(-1,1) , 2*nObs, rep=TRUE)
ztest <- sample (c(-1,1) , 1.5*nObs, rep=TRUE)
xtest[ytest ==1,] <- xtest[ytest ==1,] + 1
xtest[ztest ==2,] <- xtest[ztest ==2,] + 2
testdat <- data.frame(x=xtest, y=as.factor(ytest))
data = data.frame(nObs)
y = factor(c(xtest,ytest,ztest))
library(neuralnet)
nnRes <- neuralnet(y~xtest+ytest+ztest,data=data,hidden=4,err.fct = "sse", linear.output = FALSE)
plot(nnRes)
我收到以下错误:
[.data.frame
(data, , model.list$variables)中的错误:选择了未定义的列
为具有 3 个数据集的神经网络查找测试错误的正确方法是什么?
解决方案
推荐阅读
- excel - RSQ 函数公式中的多个范围
- android - Android 特定部分中的 Kotlin/Native 访问设备传感器
- javascript - 在 v-for 循环中仅检索一个元素的索引
- python - 从 bytearray python 中取一个字节
- c - flex 无法识别字符范围
- python - 在 python 中使用 callproc 调用包含记录集合的存储过程
- php - 为什么 amp-img 文件在 php 包含文件中不能按预期工作?
- smartcontracts - 如何使用 java 脚本从 web3.js 调用智能合约方法
- duplicates - opencart 重复运输方式
- java - 如何在 jsr352 中配置可重试/可跳过的异常