【发布时间】:2018-12-01 12:49:49
【问题描述】:
我有一个数据集,我正在尝试使用 R on 中 caret 包中的 rfe()。
x 是我要预测的价格。
y 是我用来进行预测的变量。
我无法让 rfe 停止给出以下错误消息:
> lmProfile2 <- rfe(x1,y1,
+ sizes = subsets,
+ rfeControl = ctrl)
Error in rfe.default(x1, y1, sizes = subsets, rfeControl = ctrl) :
there should be the same number of samples in x and y
这里有一些信息:
> class(x1)
[1] "data.frame"
> class(y1)
[1] "data.frame"
> nrow(x1)
[1] 500
> nrow(y1)
[1] 500
> ncol(x1)
[1] 68
> ncol(y1)
[1] 1
还有:
> y1 <- data.frame(y = tiny4[,2])
> x1 <- data.frame(tiny4[,-c(1,2)])
> subsets <- c(5,10)
>
> ctrl <- rfeControl(functions = lmFuncs,
+ method = "cv",
+ verbose = FALSE,
+ returnResamp = "final")
>
知道为什么我会收到这条消息吗?
【问题讨论】:
标签: r