When I am running this code, I am getting this error "Error in newdata[, object$model.list$variables] : subscript out of bounds" I am not getting how to solve it.
install.packages("boot")
install.packages("plyr")
library(boot)
library(plyr)
set.seed(50)
k=10
RMSE.NN=NULL
List=list( )
for(j in 10:65){
for(i in 1:k){
index=sample(1:nrow(data2),j)
trainNN=d2[index,]
testNN=d1[-index,]
dataset=data2[-index,]
NN=neuralnet(quality~.,d2,hidden=10,linear.output = T)
predict_testNN=compute(NN,d1[,c(1:5)])
predict_testNN=(predict_testNN$net.result*(max(data2$quality)-min(data2$quality)))+min(data2$quality)
RMSE.NN[i]<-(sum((data2$quality-predict_testNN)^2)/nrow(dataset))^0.5
}
List[[j]]=RMSE.NN
}
(matrixRMSE=do.call(cbind, List))
matrixRMSE
The wine data you shared has variable names with spaces in them.
R can get confused when variables have spaces in them; such names require quoting with backticks etc to refer to
# i.e. my_num would be simple but `my num` would be needed to maintain the space.
Easiest thing for you to do is use library(janitor) and clean_names on the dataset you want to work with.