The mlp
method in package caret
calls the mlp
function in RSNNS
. In the RSNNS
package, I can set up as many hidden layers in the neural net as I like by setting the size parameter, e.g.
data(iris)
#shuffle the vector
iris <- iris[sample(1:nrow(iris),length(1:nrow(iris))),1:ncol(iris)]
irisValues <- iris[,1:4]
irisTargets <- decodeClassLabels(iris[,5])
#irisTargets <- decodeClassLabels(iris[,5], valTrue=0.9, valFalse=0.1)
iris <- splitForTrainingAndTest(irisValues, irisTargets, ratio=0.15)
iris <- normTrainingAndTestSet(iris)
model <- mlp(iris$inputsTrain, iris$targetsTrain, size=c(5,7), learnFuncParams=c(0.1),
maxit=50, inputsTest=iris$inputsTest, targetsTest=iris$targetsTest)
Will set up a neural net with two hidden layers of 5 and 7 nodes respectively. I want to use the caret
package because it has functionality for doing parameter/model searches, as well as parallel implementations for a cluster. In caret
, when I look up the method, it can only be tuned with one parameter, size
, e.g.
data(iris)
mlpGrid <- data.frame(.size=3)
model2<-caret::train(Species~. , iris, method='mlp', tuneGrid=mlpGrid)
Sets up a neural net with a 3-node single hidden layer.
I've tried adding other columns to mlpGrid
and such, but caret
doesn't seem to allow for adding a second (or more) hidden layer.