我按照下面的示例代码在我自己的数据集中使用RFE:
# ensure the results are repeatable
set.seed(7)
# load the library
library(mlbench)
library(caret)
# load the data
data(PimaIndiansDiabetes)
# define the control using a random forest selection function
control <- rfeControl(functions=rfFuncs, method="cv", number=10)
# run the RFE algorithm
results <- rfe(PimaIndiansDiabetes[,1:8], PimaIndiansDiabetes[,9], sizes=c(1:8), rfeControl=control)
# summarize the results
print(results)
# list the chosen features
predictors(results)
# plot the results
plot(results, type=c("g", "o"))我可以让RFE部分按需要工作,并根据需要绘制所有的图,但我不清楚我如何看待这个模型,并使用它对新数据进行预测。我可以很容易地获得RFE结果的RMSE,但是该度量只来自经过训练的模型;现在我需要将它应用到测试集中,然后根据将RFE应用到测试集来获得结果的RMSE。
如果我弄错了这个过程,请帮助我理解。
发布于 2016-04-07 20:56:41
newpredictions<-predict(results,PimaIndiansDiabetes_Test[,1:8])( PimaIndiansDiabetes_Test是您的测试集)
https://stackoverflow.com/questions/36486927
复制相似问题