trnnick / nnfor

31 stars 15 forks source link

Error in if (ncol.matrix < rep) { : argument is of length zero #8

Open b-rodrigues opened 5 years ago

b-rodrigues commented 5 years ago

I get the error message from the title when running the following code:

library(tidyverse)
library(nnfor)
library(cranlogs)

rdieharder <- cran_downloads("RDieHarder", from = "2017-01-01")

train_data <- rdieharder %>%
  filter(date < as.Date("2019-01-01")) %>%
  pull(count) %>%
  ts()

# I replace this value, because this is just for testing purposes, and this value is unusually high
train_data[train_data==373] <- 3

test_data <- rdieharder %>%
  filter(date >= as.Date("2019-01-01"))

croston_model <- crost(train_data, h = 365)

nn_model <- mlp(train_data, hd.auto.type = "cv")

Same if I replace "cv" by "valid", but no issue if I add "reps = 1", or reps = "2". Any ideas?

b-rodrigues commented 5 years ago

by the way, I wrote a blog post on intermittent demand that uses your packages :)

https://www.brodrigues.co/blog/2019-06-12-intermittent/

laurajludwig commented 4 years ago

I am getting a similar issue. When I run the code below, I get the error mentioned in title of this thread. When I tried changing to using "reps=1", I get a failure to converge error, and I get this same error when I try "reps=2".

etrain = read.csv('etrain.csv', stringsAsFactors = FALSE)
etraints = ts(etrain[,3])
library(nnfor)
fit3 = mlp(etraints)

Ultimately, I need to run the mlp function using xreg, but that was giving errors to start with, so I started simplifying to see if I could get anything to run, and nothing has worked so far. It's a time-consuming trial-and-error at this point. I can't tell from a traceback where this error is coming from to try to troubleshoot further. Any guidance or suggestion would be greatly appreciated.

J08nY commented 4 years ago

This was an issue in the neuralnet package, and was fixed in https://github.com/bips-hb/neuralnet/pull/21, updating to the neuralnet package version in current master should fix it.

moxSedai commented 2 years ago

This issue is still present in a freshly updated package.

DiegoJArg commented 2 years ago

I am having this issue too. I guess randomly, sometimes just works. NN<-neuralnet( (Species == "versicolor") ~ . , iris, hidden=c(4,4), rep=5 ) %>% plot( rep="best" )