lydias
lydias

Reputation: 841

R Error with neural network caret parameter tuning

I'm working on tuning parameters for a neural network exercise on the Boston dataset. I have been getting a persistent error:

Error: The tuning parameter grid should have columns size, decay

The following is the set up of my Caret tuning:

caret_control <- trainControl(method = "repeatedcv",
                       number = 10,
                       repeats = 3)

caret_grid <- expand.grid(batch_size=seq(60,120,20),
                      dropout=0.5,
                      size=100,
                      decay = 0,
                      lr=2e-6,
                      activation = "relu")

caret_t <- train(medv ~ ., data = chasRad, 
             method = "nnet", 
             metric="RMSE",
             trControl = caret_control, 
             tuneGrid = caret_grid,
             verbose = FALSE)

Here chasRad is a 12x506 matrix. Could anyone help on fixing the error that seems triggered by the expanded grid?

Upvotes: 1

Views: 906

Answers (1)

Keith Mertan
Keith Mertan

Reputation: 136

The error you're getting should be interpreted as:

"The tuning parameter grid should ONLY have columns size, decay".

You're passing in four additional parameters that nnet can't tune in caret. For a full list of parameters that are tunable, run modelLookup(model = 'nnet').

To tune only size and decay, replace your caret_grid with:

caret_grid <- expand.grid(size=seq(from = 1, to = 10, by = 1),
                      decay = seq(from = 0.1, to = 0.5, by = 0.1))

and your code will run.

Upvotes: 1

Related Questions