So I\'ve read a paper that had used neural networks to model out a dataset which is similar to a dataset I\'m currently using. I have 160 descriptor variables that I want to
I think for beginners it's not obvious at all that the layer specification cannot be passed directly into the train function.
One must read the documentation very carefully to understand the following passage for ...
:
Errors will occur if values for tuning parameters are passed here.
So first, you must realize that the hidden
parameter of the neuralnet::neuralnet
is defined as a tuning parameter and therefore may not be passed directly to the train function (by ...
). You find the tuning parameter definitions by:
getModelInfo("neuralnet")$neuralnet$parameters
parameter class label
1 layer1 numeric #Hidden Units in Layer 1
2 layer2 numeric #Hidden Units in Layer 2
3 layer3 numeric #Hidden Units in Layer 3
Instead, you must pass the hidden layer definition by the tuneGrid
parameter - not obvious at all because that is normally reserved for tuning the parameters, not passing them.
So you can define the hidden
layers as follows:
tune.grid.neuralnet <- expand.grid(
layer1 = 10,
layer2 = 10,
layer3 = 10
)
and then pass that to the caret::train
function call as:
model.neuralnet.caret <- caret::train(
formula.nps,
data = training.set,
method = "neuralnet",
linear.output = TRUE,
tuneGrid = tune.grid.neuralnet, # cannot pass parameter hidden directly!!
metric = "RMSE",
trControl = trainControl(method = "none", seeds = seed)
train
sets hidden
for you (based on the values given by layer
-layer3
. You are trying to specify that argument twice, hence:
formal argument "hidden" matched by multiple actual arguments
HTH,
Max