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 `gam' method can generate grid of length 1. #1308

Merged
merged 3 commits into from
Mar 21, 2023

Conversation

carloscinelli
Copy link
Contributor

@carloscinelli carloscinelli commented Sep 4, 2022

Currently, the `gam' method 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 = "gam", trControl = trainControl(method = "none"))
# Error: Only one model should be specified in tuneGrid with no resampling

Note that the default behavior of trainControl(method = "none") is to set tuneLength = 1 and thus create a grid of length 1.

However, here the minimal grid it was creating always had length 2, as it was passing both TRUE and FALSE to the parameter `select,' which does not make sense if we want a grid of length 1.

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

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

Currently, the `gam' method 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 = "gam", trControl = trainControl(method = "none"))
# Error: Only one model should be specified in tuneGrid with no resampling

Note that the default behavior of `trainControl(method = "none")` is to create a grid of length 1.

However, here the minimal grid it was creating always had length 2, as it was passing both TRUE and FALSE to the parameter `select,' which does not make sense if we want a grid of length 1.

The proposed change makes sure expand.grid will always have length 1, if len = 1.
@carloscinelli carloscinelli changed the title Make sure `gam' method can generate grid of length 1. Makes sure `gam' method can generate grid of length 1. Sep 4, 2022
@topepo
Copy link
Owner

topepo commented Mar 21, 2023

@carloscinelli thanks for these

@topepo topepo merged commit ffcf5ce 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