0

I'm getting the following on running the neuralnet function:

Error in `[.data.frame`(data, , model.list$variables) : 
  undefined columns selected

The code I used is as shown below:

 #creating training and test dataset
it_trainann<-norm_it_1h[1:1748, ]
it_testann<-norm_it_1h[1749:2185, ]
sum(is.na(it_trainann))
[1] 0
sum(is.na(it_testann))
[1] 0
#prediction using ANN
library(neuralnet)
it_model<-neuralnet(Unit.Price~., data=it_trainann, hidden=3)

norm_it_1h is a data frame composed of normalised numerical variables. I could neither find NA values nor non-numeric variables. On tracing back, I got the following result:

6: stop("undefined columns selected")
5: `[.data.frame`(data, , model.list$variables)
4: data[, model.list$variables]
3: as.matrix(data[, model.list$variables])
2: cbind(intercept = 1, as.matrix(data[, model.list$variables]))
1: neuralnet(Unit.Price ~ ., data = it_trainann, hidden = 3)

Kindly help me resolve this issue.

Lakshmi
  • 1
  • 1
  • Did you check that the exact name of the variable in it_trainann is `Unit.Price`? – G5W Jun 02 '20 at 14:34
  • @G5W, Yes I did – Lakshmi Jun 02 '20 at 14:53
  • It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. – MrFlick Jun 02 '20 at 15:13

1 Answers1

0

I got the same error while working on big data. I tried some solutions in StackOverflow 1 2 but none of them solved my issue. Then, I printed all variable names that I've used on my model. I noticed that some of my variable names have special strings. In sum, changing col names that seems to problematic fixed my error:

colnames(mydataframe)[which(names(mydataframe) == "A problematic name $½£ _")] <- "NotProblematicName"
AltunE
  • 375
  • 3
  • 10