-
Notifications
You must be signed in to change notification settings - Fork 634
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
RFE crashes when it gets down to one variable #543
Comments
Hello Scott, I cannot reproduce the error you are getting. Which version of Pantelis |
It is a bug in the > mod1 <- glm(diabetes ~ pregnant + glucose, data = PimaIndiansDiabetes,
+ family = binomial())
> mod2 <- glm(diabetes ~ glucose, data = PimaIndiansDiabetes,
+ family = binomial())
> varImp(mod1)
Overall
pregnant 4.817846
glucose 11.321631
> varImp(mod2)
Overall
1 11.64695 Damn you I'll fix the method, but in the meantime, you can use: lrFuncs2 <- lrFuncs
lrFuncs2$rank <- function (object, x, y)
{
values <- summary(object)$coef
varImps <- abs(values[-1, grep("value$", colnames(values)), drop = FALSE])
vimp <- data.frame(varImps)
colnames(vimp) <- "Overall"
if(!is.null(names(varImps))) rownames(vimp) <- names(varImps)
vimp <- vimp[order(vimp$Overall, decreasing = TRUE), , drop = FALSE]
vimp$var <- rownames(vimp)
vimp
}
ctrl <- rfeControl(
functions = lrFuncs2,
method = 'boot',
number = 5,
rerank = TRUE,
verbose = TRUE
)
varSeq <- c(1:4)
set.seed(721)
lrRFE <- rfe(PimaIndiansDiabetes[,-9],
PimaIndiansDiabetes[,9],
sizes = varSeq,
metric = "ROC",
rfeControl = ctrl)
lrRFE |
Thank you both and sorry for the late reply! |
Hi Max
If I run the below, it works.
But if I reduce the lowest number in sizes, ie varSeq, to 1, it crashes causing the error:
"Error in { : task 1 failed - "replacement has 1 row, data has 0"
In addition: Warning message:
In rfe.default(PimaIndiansDiabetes[, -9], PimaIndiansDiabetes[, :
Metric 'ROC' is not created by the summary function; 'Accuracy' will be used instead"
I've identified that the use of rerank = TRUE is causing the error. If I remove that, it works. But I sort of want rerank on all the other combos of variables, so I'd like to be able to run it with rerank = TRUE. Any ideas? Have I missed something?
Thanks for caret!
Scott
The text was updated successfully, but these errors were encountered: