Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用ggplot2中带有概率的geom_roc()_R_Ggplot2_Roc - Fatal编程技术网

如何使用ggplot2中带有概率的geom_roc()

如何使用ggplot2中带有概率的geom_roc(),r,ggplot2,roc,R,Ggplot2,Roc,我使用了下面的代码来生成ROC图 library(plotROC) library(ggplot2) library(e1071) library(mlbench) data(BreastCancer) BreastCancer$Class <- ifelse(BreastCancer$Class == "malignant",1,0) bound <- floor((nrow(BreastCancer)/4)*3) df <- BreastCancer[

我使用了下面的代码来生成ROC图

library(plotROC)
library(ggplot2)
library(e1071)
library(mlbench)

data(BreastCancer)
BreastCancer$Class <- ifelse(BreastCancer$Class == "malignant",1,0)

bound <- floor((nrow(BreastCancer)/4)*3)         
df <- BreastCancer[sample(nrow(BreastCancer)), ]        
training <- df[1:bound,-1]    
testing <- df[(bound+1):nrow(df), -1] 

nb_mod <- naiveBayes(formula = Class ~ ., data = training)

prob_nb <- predict(nb_mod,testing,type="raw")
df <- data.frame(Class = testing$Class,Prob = prob_nb )

basicplot <- ggplot(df, aes(d = Class, m = Prob.1)) + geom_roc()    
库(plotROC)
图书馆(GG2)
图书馆(e1071)
图书馆(mlbench)
数据(乳腺癌)

BreastCancer$Class将
d
转换为数字,然后它就可以工作了

as.numeric(D)

有一整篇关于那个图书馆的论文,我想你会在那里找到你的答案:()谢谢你的快速回答。不,在那篇论文中,他实际上使用了相同的例子。他谈到标记(M1,M2)。但这些都不是概率。
as.numeric(D)