DataGuy
DataGuy

Reputation: 1725

Tuning parameters with caret

Im using the caret package in R to build a regression model using a Cubist model tree, which has two tuning parameters:

Tuning Parameters: committees (#Committees), neighbors (#Instances)

I think I am trying to implement the tuning parameters incorrectly and need some help to fix the issue. Following the examples on the caret site I have built a grid for my tuning parameters as follows:

cubistGrid <- expand.grid(committees = 30, neighbors = 10)

then Im calling the grid using the train function as follows:

LMFit1 <- train(Total~., data = training, method = "cubist", trControl = fitControl, tuneGrid = cubistGrid)

Im getting the following error:

Something is wrong; all the RMSE metric values are missing:

I dont have any issues with my dataframe as Ive run many models on it to date; this is the first time Ive used the tuning parameters.

Thanks,

Ben

Upvotes: 3

Views: 1899

Answers (1)

phiver
phiver

Reputation: 23608

First of all, not a reproducible example, but if you check the warnings you will see the following:

predictions failed for Resample1: committees=30, neighbors=10 Error in predict.cubist(modelFit, newdata, neighbors = modelFit$tuneValue$neighbors) : 'neighbors' must be less than 10

Set the neighbors to a value less than 10. That should take care of the empty rmse metrics.

Upvotes: 4

Related Questions