我在尝试从rfe对象提取混淆矩阵时遇到错误"重新采样的混淆矩阵不可用"。是插入程序包的confusionMaitrx.rfe函数不起作用,还是我在这里遗漏了什么?
以下是使用模拟数据的示例
http://topepo.github.io/caret/rfe.html
关于函数混淆的文档Matrix.rfe在这里
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**
谢谢!
mlbench.friedman1
是一个回归问题,而不是分类问题。如果您检查数据,您可以看到您的Y变量是连续的。confusionMatrix
在这种情况下没有用处。