0

I am trying to run a neural network on a bike sharing dataset using the neuralnet library in R. The code I am trying to run is:

nn <- neuralnet(Bike_Count~., data=train, hidden=2, act.fct = "tanh", linear.output = FALSE)

However, when I run this, I get the following error:

Error in neurons[[i]] %*% weights[[i]] : requires numeric/complex matrix/vector arguments

The structure of my data is:

'data.frame':   7008 obs. of  5 variables:
 $ Bike_Count     : Factor w/ 2 levels "0","1": 2 2 1 2 2 2 1 2 2 2 ...
 $ Holiday        : Factor w/ 2 levels "0","1": 2 1 1 1 1 1 1 1 1 1 ...
 $ Hour           : Factor w/ 24 levels "0","1","2","3",..: 13 13 3 20 21 24 1 23 1 11 ...
 $ Temperature..C.: num  22.1 32.6 13.1 19.2 33.9 4.1 24.7 25.1 16.7 25.5 ...
 $ Humidity       : num  67 51 73 55 58 46 94 73 50 33 ...

A reproducible sample of my data is shared below:

   structure(list(Bike_Count = structure(c(2L, 2L, 1L, 2L, 2L, 2L, 1L, 2L, 2L, 2L), .Label = c("0", "1"), class = "factor"), Holiday = structure(c(2L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("0", "1"), class = "factor"), 
    Hour = structure(c(13L, 13L, 3L, 20L, 21L, 24L, 1L, 23L, 
    1L, 11L), .Label = c("0", "1", "2", "3", "4", "5", "6", "7", 
    "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", 
    "18", "19", "20", "21", "22", "23"), class = "factor"), Temperature..C. = c(22.1, 
    32.6, 13.1, 19.2, 33.9, 4.1, 24.7, 25.1, 16.7, 25.5), Humidity = c(67, 
    51, 73, 55, 58, 46, 94, 73, 50, 33)), row.names = c(3637L, 
5557L, 3843L, 3140L, 5877L, 8448L, 6529L, 5183L, 7201L, 4403L
), class = "data.frame")

PS. I tried running the model with only numeric variables and it runs fine, but I want to include the features "Hour" and "Holiday" in there, too.

Your help is much appreciated!

  • Does this answer your question? [Working with neuralnet in R for the first time: get "requires numeric/complex matrix/vector arguments"](https://stackoverflow.com/questions/17457028/working-with-neuralnet-in-r-for-the-first-time-get-requires-numeric-complex-ma) – Tou Mou Oct 21 '20 at 21:43
  • I think your question is a duplicate ; https://stackoverflow.com/questions/17457028/working-with-neuralnet-in-r-for-the-first-time-get-requires-numeric-complex-ma – Tou Mou Oct 21 '20 at 21:43

0 Answers0