Categories: r, neural-network

neural net - undefined column selected

1 answer

Data Partition

I have several factor variables so I decided to use dummy variables instead for ANN.

set.seed(222) m <- model.matrix( ~price+month+year+area+larea+otype+cid+rid+did+renovation+nrooms+nbeds+nbaths+nbalcs+wfloor+status, data = data) ind <- sample(2, nrow(m), replace = TRUE, prob = c(0.8, 0.2)) training <- m[ind==1,] testing <- m[ind==2,] 

neural net

n <- neuralnet(price~.,                 data = training,                 hidden = 1,                 err.fct = "sse",                 linear.output = FALSE) 

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

I use dot because I have 94 explanatory variables. when I run price on two explanatory variables to see what the problem was it worked. There is some problem with dot, is it only used for linear regression and I got it wrong? how can I solve this problem?

All answers to this question, which has the identifier 61239006

The best answer:

The model.matrix is a matrix and not a data.frame. According to ?neuralnet

data - a data frame containing the variables specified in formula.

So, we may need to convert to data.frame with as this works correctly with data.frame input

library(neuralnet) data(iris) nn <- neuralnet(Species~ ., iris,          linear.output = FALSE, hidden = 1, err.fct = "sse") nn$weights #[[1]] #[[1]][[1]] #           [,1] #[1,]  -9.900398 #[2,]  -1.527258 #[3,] -13.201669 #[4,]  11.624309 #[5,]  17.896367  #[[1]][[2]] #          [,1]      [,2]      [,3] #[1,]  32.51005 -4.014045 -4.303671 #[2,] -65.72300  4.013259  4.304652 

In the OP's code, the issue is that model.matrix creates column names with nonstandard names. It can be converted to standard names with make.unique

names(training) <- make.names(names(training)) n <- neuralnet(price ~ .,              data = training,             hidden = 1,             err.fct = "sse",        linear.output = FALSE)    n$weights #[[1]] #[[1]][[1]] #              [,1] # [1,]  -0.62625018 # [2,]   1.39124245 # [3,]  -2.59472834 # [4,]   0.27773897 # [5,]   7.15830865 # [6,]  -2.93583230 # ... 

Last questions

how do i remove the switch on my home screen?
how to edit the JS date and time to update atuomatically?
How to utilize data stored in a multidimensional array
Powermockito not mocking URL constructor in URI.toURL() method
Android Bluetooth LE Scanner only scans when phone's Location is turned on in some devices
docker wordpress container can't connect to mysql container
How can I declare a number in java that is more than 64-bits? [duplicate]
Optaplanner solutionClass entityCollectionProperty should never return null error when simple JSON object passed to controller
Anylogic, get the time a pedestrain is in a queue
How do I fix this syntax issue with my .flex file?
Optimizing query in PHP
How to find the highest number of a column and print two columns of that row in R?
Ideas on “Error: Type is referenced as an interface from”?
JCIFS SmbFile.exists() and SmbFile.isDirectory() return false when it exists and I can listFiles()
PHP total order
Laravel booking system design
neural net - undefined column selected
How to indicate y axis does not start from 0 in ggplot?
Fragments in backStack
Spinner how to change the data