Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve clarity of tuneGrid error messages #1243

Open
hlydecker opened this issue Jul 20, 2021 · 1 comment
Open

Improve clarity of tuneGrid error messages #1243

hlydecker opened this issue Jul 20, 2021 · 1 comment

Comments

@hlydecker
Copy link

hlydecker commented Jul 20, 2021

Let's say I want to fit a random forest model.

library(caret)
set.seed(1)
example <- data.frame(replicate(10,sample(0:10,1000,rep=TRUE)))

I then decide to make a tuning grid, without going to read the documentation.

cv <- trainControl(
  method = "repeatedcv",
  number = 10,
  repeats = 5,
  savePredictions = "final"
)

tune_grid <- expand.grid(
  mtry = c(0.5, 1, 1.5, 2),
  min.node.size = c(2, 4, 6),
  splitrule = c("variance", "extratrees"),
  num.trees = c(50, 100, 150, 200),
  max.depth = 1:11
)

model_class <- train(
  X1 ~ ., 
  example, 
  metric='RMSE',
  method = "ranger",
  trControl= cv,
  tuneGrid = tune_grid
)

If you run this, you get this error message:

Error: The tuning parameter grid should have columns mtry, splitrule, min.node.size

Now, if you see this error message, you might think to yourself "wait, don't I have mtry, splitrule, and min.node.size in my tuning parameter grid?". This is confusing. Really we want the user to see something like:

Error: The tuning parameter grid for a 'ranger' model should only have columns mtry, splitrule, min.node.size. 

Or perhaps even something like:

Error: The tuning parameter grid has invalid columns for the specified model type! Please refer to the documentation for your model at https://topepo.github.io/caret/available-models.html
@melody22-ccc
Copy link

I have this question too. Have you solve it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants