尝试使用"树"获得CART决策树的ROC曲线和AUC。封装
> str(pruned.tree7)
这是我树的结构
' data.frame':13 obs。 6个变量:
$ var:因子w / 15级"","年龄",..:15 10 1 11 11 5 1 1 15 1 ...
$ n:num 383 158 29 129 110 38 20 18 72 7 ...
$ dev:num 461.1 218.6 29.6 174 141.8 ...
$ yval:因子w / 2级"否定","肯定":2 2 1 2 2 1 2 1 2 1 ...
$ splits:chr [1:13,1:2]"< 19.5" "< 81.5" "" "< 65" ...
..- attr(*," dimnames")= 2的列表
.. .. $:NULL
.. .. $:chr" cutleft" "卡特赖特"
$ yprob:num [1:13,1:2] 0.29 0.475 0.793 0.403 0.345 ...
..- attr(*," dimnames")= 2的列表
.. .. $:NULL
.. .. $:chr"否定" "正"
参考上述结构,我编写了以下代码(许多变体):
> preds <- prediction(pruned.tree7$frame$yprob, dimnames(pruned.tree7$frame$yprob))
预测错误(pruned.tree7 $ frame $ yprob,dimnames(pruned.tree7 $ frame $ yprob)): 每次运行中的预测数量必须等于每次运行的标签数量。
> preds <- prediction(pruned.tree7$frame$yprob, dimnames)
预测错误(pruned.tree7 $ frame $ yprob,dimnames): 标签格式无效。
> preds <- prediction(pruned.tree7$frame$yprob, "dimnames")
预测错误(pruned.tree7 $ frame $ yprob,&#34; dimnames&#34;): 预测和标签的交叉验证运行次数必须相等。
> preds <- prediction(pruned.tree7$frame$yprob, names(yprob))
is.data.frame(标签)出错:object&#39; yprob&#39;找不到
> preds <- prediction(pruned.tree7$frame$yprob, names(pruned.tree7$frame$yprob))
预测错误(pruned.tree7 $ frame $ yprob,names(pruned.tree7 $ frame $ yprob)): 标签格式无效。
> preds <- prediction(pruned.tree7$frame$yprob, dimnames(pruned.tree7$frame$yprob))
预测错误(pruned.tree7 $ frame $ yprob,dimnames(pruned.tree7 $ frame $ yprob)): 每次运行中的预测数量必须等于每次运行的标签数量。
我搜索过并找到了这个链接:ROCR Package Documentation 它提到了交叉验证的主题。但是,这对我没有意义。
提前谢谢!!