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

Unexpected warning produced by safs when differences = TRUE #1247

Closed
gcaligari opened this issue Aug 12, 2021 · 1 comment · Fixed by #1253
Closed

Unexpected warning produced by safs when differences = TRUE #1247

gcaligari opened this issue Aug 12, 2021 · 1 comment · Fixed by #1253

Comments

@gcaligari
Copy link

Hello,

Thanks for your package.

While using the package I noticed that the function safs throws an unexpected warning message about an error occurring when the default value of differences = TRUE is used.
I created a safs object using the example code from the safs help file to demonstrate this, as can be seen by the reproducible code found below.

caret version = 6.0-86
R version = 4.0.4

Thanks,
Giulia

library(caret)
#> Loading required package: lattice
#> Loading required package: ggplot2
set.seed(1)
train_data <- caret::twoClassSim(100, noiseVars = 10)
test_data  <- caret::twoClassSim(10,  noiseVars = 10)

## A short example
ctrl <- caret::safsControl(functions = rfSA,
                    method = "cv",
                    number = 3)

rf_search <- caret::safs(x = train_data[, -ncol(train_data)],
                  y = train_data$Class,
                  iters = 3,
                  safsControl = ctrl)
#> Warning in safs.default(x = train_data[, -ncol(train_data)], y =
#> train_data$Class, : An error occured when computing the variable differences
@topepo
Copy link
Owner

topepo commented Sep 20, 2021

Thanks. I've added some additional code that gives a slightly better warning message.

The main issue was a low number of iterations. It didn't have enough permutations of the predictors to compute the differences. Doing 5+ iterations gives results and no warning.

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 a pull request may close this issue.

2 participants