我有一个数据集,我正在对其执行逐步回归,并进行交叉验证。我最初使用交叉验证执行了多元线性回归,并且能够看到我的测试集的值与每个折叠的训练集的值有多接近(我使用该值绘制了一个图表,在其中我测量了性能)。我也要做同样的事情,但要逐步回归。我在R中执行了以下算法:
test <- CV.SuperLearner(Y,X, V = 10, SL.library = SL.library, verbose = TRUE, method = "method.NNLS")但我看不出我如何能够查看每个折叠的值,以及它们有多接近。有没有办法让我做到这一点?
我试过print和summary,但他们不能提供我想要的信息。
谢谢
发布于 2013-12-08 09:44:38
在?CV.SuperLearner中解释了这一点:结果包含一个AllSL插槽,其中包含所有的折叠。
# Sample data
library(SuperLearner)
example(CV.Superlearner)
str(test$AllSL) # You see a list with V=10 elements
test$AllSL[[1]] # The first fold
predict( test$AllSL[[1]] ) # The predicted values如果要与实际值进行比较,则需要知道文件夹中包含了哪些观测值。
plot(
Y[ test$folds[[1]] ],
predict( test$AllSL[[1]] )$pred,
xlab = "Actual", ylab = "Predicted",
main = "First fold"
) 更一般地,要检查对象的内容,除了使用print、summary或plot之外,还可以使用str和names。
str(test) # Too long to be useful
names(test)
str(test$AllSL)
str(test$AllSL[[1]])
str(test$folds)https://stackoverflow.com/questions/20443578
复制相似问题