1

在 RFE 插入符号包中选择特征后,是否可以为最佳模型绘制 ROC 曲线?

我的代码如下:

set.seed(12)
rfFuncs$summary <- twoClassSummary
rfeControl = rfeControl(rfFuncs)
trainctrl <- trainControl(classProbs= TRUE, summaryFunction = 
twoClassSummary, savePredictions = TRUE)
control <- rfeControl(functions=rfFuncs, method="LOOCV", 
returnResamp="final")
feat.sel <- rfe(bd_ud[, c(1:10)], bd_ud$diagnosis, 
sizes=c(1:10), rfeControl=control, method="svmLinear", metric = 
"ROC",     trControl=trainctrl)
print(feat.sel)
predictors(feat.sel)
plot(feat.sel, type=c("g", "o"))

结果:

Resampling performance over subset size:

Variables    ROC   Sens   Spec Selected
     1 0.5101 0.6481 0.5185         
     2 0.6337 0.5000 0.5926         
     3 0.6980 0.6296 0.6667        *
     4 0.6373 0.5741 0.6111         
     5 0.6349 0.5741 0.6111         
     6 0.6727 0.6296 0.5926         
     7 0.6406 0.5741 0.5926         
     8 0.6307 0.5926 0.5556         
     9 0.6557 0.5926 0.6111         
    10 0.6044 0.5741 0.5926  

如何绘制选择 3 个变量(AUC=0.6980)的模型的 ROC 曲线?

4

1 回答 1

0

我想看到每个模型的多条 roc 曲线,为了清楚起见,将此作为示例,使用最少的格式。

plot(0:1, 0:1, type = "n")  # setting up coord. system
lines(c(0, 1-0.5926, 1), c(0, 0.5000, 1), lty = 2) # 2 vars ROC
lines(c(0, 1-0.6667, 1), c(0, 0.6296, 1), lty = 1) # 3 vars ROC
legend("top", legend = c("3 vars", "2 vars"), lty = 1:2)

在此处输入图像描述

于 2018-11-08T11:34:56.663 回答