Bfu38 Bfu38 -4 years ago 71
R Question

AUC unexpected value

I have the following predictions after running a logistic regression model on a set of molecules we suppose that are predictive of tumors versus normals.

Predicted class
T 29 5
Actual class
N 993 912

I have a list of scores that range from predictions <0 (negative numbers) to predictions >0 (positive numbers). Then I have another column in my
that indicated the labels (1== tumours and 0==normals) as predicted from the model. I tried to calculate the ROC using the
in the following way:

pred = prediction(prediction, labels)
roc = performance(pred, "tpr", "for")
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: 1

The AUC is equal to 1. I'm not sure that I run all correctly or probably I'm doing something wrong in the interpretation of my results because it is quite rare that the AUC is equal to 1.

Can anyone help me please?


Answer Source

I use pROC to calculate AUC:

pred = runif(100)
y = factor(sample(0:1, 100, TRUE))
auc = as.numeric(roc(response = y, predictor = pred)$auc)
print(auc) # 0.5430757


auc = AUC::auc(AUC::roc(pred, y))
print(auc) # 0.4569243

I can't explain why the results are different.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download