0
votes

I ran into an error "resampled confusion matrices are not available" when trying to extract confusion matrix from a rfe object. is the confusionMaitrx.rfe function of the caret package not working or am I missing something here?

Below is an example using simulated data from

http://topepo.github.io/caret/rfe.html

Documentation on function confusionMatrix.rfe is here

http://www.inside-r.org/packages/cran/caret/docs/confusionMatrix.train

library(caret)
library(mlbench)
library(Hmisc)
library(randomForest)
n <- 100
p <- 40
sigma <- 1
set.seed(1)
sim <- mlbench.friedman1(n, sd = sigma)
colnames(sim$x) <- c(paste("real", 1:5, sep = ""),
                     paste("bogus", 1:5, sep = ""))
bogus <- matrix(rnorm(n * p), nrow = n)
colnames(bogus) <- paste("bogus", 5+(1:ncol(bogus)), sep = "")
x <- cbind(sim$x, bogus)
y <- sim$y
normalization <- preProcess(x)
x <- predict(normalization, x)
x <- as.data.frame(x)
subsets <- c(1:5, 10, 15, 20, 25)
set.seed(10)

ctrl <- rfeControl(functions = lmFuncs,
               method = "repeatedcv",
               repeats = 5,
               verbose = FALSE)

lmProfile <- rfe(x, y,
             sizes = subsets,
             rfeControl = ctrl)

lmProfile
confusionMatrix(lmProfile)
**Error in confusionMatrix.rfe(lmProfile) : 
  resampled confusion matrices are not availible**

Thanks!

1

1 Answers

0
votes

mlbench.friedman1 is a regression problem, not a classification problem. If you check the data, you can see that your Y variable is continuous. confusionMatrix has no use in this case.