Wednesday, December 3, 2014

[R] Caret training error


When I was training a neural network with R using 'nnet' method, I got the following error:
Error in model.frame.default(Terms, newdata, na.action = na.omit, xlev = object$xlevels) : 
  invalid type (list) for variable 'x'


It turns out, predict.train function in the {caret} package uses the model.frame function in {stats} package to extract the formula from the trained network.

This error is received when you are trying to train a single-input network (1-n-k network).


Unfortunately, I haven't found way to train single-input networks using caret and nnet. You CAN, however, use 'nnet' by itself to train your network. If you wanted to optimize your network, you would have to iteratively change the desired hyperparameters (such as weight decay, size of hidden layer, etc).

I will post an update if it is fixed in the future.

No comments:

Post a Comment