library(caret) set.seed(1) x <- data.frame(runif(10),runif(10)) y <- rnorm(10) rfeModel <- rfe(x,y,rfeControl = rfeControl(functions = lmFuncs))
returns:
Error in { : task 1 failed – "undefined columns selected"
While this code:
data(BloodBrain) x <- scale(bbbDescr[,-nearZeroVar(bbbDescr)]) x <- x[, -findCorrelation(cor(x), .8)] x <- as.data.frame(x) lmProfile <- rfe(x, logBBB,rfeControl = rfeControl(functions = lmFuncs))
Works fine. What am I doing wrong in the 1st example? (I get the same error in R 2.14.0 and 2.13.2)
Best Answer
You have to specify the sizes
argument ($leq 2$ in your example). The default value in rfe
is sizes=2^(2:4)
, but you only have two features.
?rfe
Arguments
- …
sizes
a numeric vector of integers corresponding to the number of features that should be retained
Similar Posts:
- Solved – Odd error with caret function rfe
- Solved – Odd error with caret function rfe
- Solved – How to get lmFuncs functions of the rfe function in caret to do a logistic regression
- Solved – Find variables selected for each subset using caret feature selection
- Solved – Caret feature selection with customized random forest classifier