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

Makes sure ranger method can generate grid of length 1. #1307

Merged
merged 4 commits into from
Mar 21, 2023

Conversation

carloscinelli
Copy link
Contributor

@carloscinelli carloscinelli commented Sep 4, 2022

Currently, ranger gives an error if passed with trainControl(method = "none"). You can see the error here:

rm( list = ls())
n <- 1e3
x <- cbind(x = rnorm(n))
y <- c(x + rnorm(n))
train(x, y, method = "ranger", trControl = trainControl(method = "none"))
# Error: Only one model should be specified in tuneGrid with no resampling

This was happening because the minimal grid it was creating has length 2, as it was passing both srule and "extratrees" to expand.grid regardless of the argument len.

The proposed change makes sure expand.grid will have length 1, if len = 1.

(and this does not affect the behavior of anything else whenever len > 1)

Currently, ranger gives an error if passed with `trainControl(method = "none")`. You can see the error here:

```
rm( list = ls())
n <- 1e3
x <- cbind(x = rnorm(n))
y <- c(x + rnorm(n))
train(x, y, method = "ranger", trControl = trainControl(method = "none"))
```

This was happening because the minimal grid was a length 2, as it was passing both `srule` and "extratrees" to expand.grid regardless of the argument `len`. 

The proposed change makes sure expand.grid will have length 1, if `len = 1`.
@carloscinelli carloscinelli changed the title Update ranger.R Make sure ranger method can generate grid of length 1. Sep 4, 2022
@carloscinelli carloscinelli changed the title Make sure ranger method can generate grid of length 1. Makes sure ranger method can generate grid of length 1. Sep 4, 2022
@topepo topepo merged commit 94ce7db into topepo:master Mar 21, 2023
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

Successfully merging this pull request may close these issues.

None yet

2 participants