在对一组分子进行logistic回归模型后,我有以下预测,我们假设这是肿瘤和正常人的预测。
Predicted class
T N
T 29 5
Actual class
N 993 912 我有一个分数列表,从预测<0 (负数)到预测>0 (正数)。然后,我的data.frame中有另一列,它表示从模型中预测的标签(1==、肿瘤和0==normals)。我试图以以下方式使用library(ROC)计算ROC:
pred = prediction(prediction, labels)
roc = performance(pred, "tpr", "fpr")
plot(roc, lwd=2, colorize=TRUE) 使用:
roc_full_data <- roc(labels, prediction)
rounded_scores <- round(prediction, digits=1)
roc_rounded <- roc(labels, prediction)呼叫:
roc.default(response = labels, predictor = prediction)
Data: prediction in 917 controls (category 0) < 1022 cases (category1).
Area under the curve: 1AUC等于1,我不确定我是否所有的运行都是正确的,或者我可能在解释我的结果时做错了什么,因为AUC等于1是非常罕见的。
发布于 2017-03-23 07:08:21
您的x.measure中有一个错误,应该抛出一个错误。你有"for“而不是"fpr”。试试下面的代码。
performance(pred, measure = "tpr", x.measure = "fpr")
plot(perf)
# add a reference line to the graph
abline(a = 0, b = 1, lwd = 2, lty = 2)
# calculate AUC
perf.auc <- performance(pred, measure = "auc")
str(perf.auc)
as.numeric(perf.auc@y.values)https://stackoverflow.com/questions/42961395
复制相似问题