2
$\begingroup$

I'm using library(ROCR) and I have a dataset with 4 class and I would like to plot a ROC curve for a multiclass classification. I plotted the graph of each class x every other, turning into binary, but I wanted to plot only one graph, demonstrating the behavior of my variable. I do not know if what I did is correct.

x = data.frame(c(A, B, C, D))
realvec = c(realvecA, realvecB, realvecC, realvecD)

predROC = prediction(x, realvec)
perfROC = performance(predROC, "tpr", "fpr")

#########################    PLOT     ##############################
#plot a ROC comparing with individual values
plot(perfROC, lwd = 3, main = "Comparative between ROC's", col = "black")
plot(perfROCA, lwd = 2, add=TRUE, lty=2, col = "red")
plot(perfROCB, lwd = 2, add=TRUE, lty=2, col = "blue")
plot(perfROCC, lwd = 2, add=TRUE, lty=2, col = "orange")
plot(perfROCD, lwd = 2, add=TRUE, lty=2, col = "green")
legend(0.6, 0.4, legend = c("Multi-class", "A", "B", "C", "D"), 
lty = c(1,1,1), col = c("black", "red", "blue", "orange", "green"))

A, B, C and D are predictions in this format:

A <- c(attributes(predA1)$prob[1,], attributes(predA2)$prob[1,],attributes(predA3)$prob[1,],
attributes(predA4)$prob[1,], attributes(predA5)$prob[1,])

realvecA, B, C and D are the binary tests of a 5k fold cross validation

realvecA <- ifelse(net_testA[15]=="A", 1, 0)

It would be correct to concatenate the results of the predictions for the 4 variables analyzed separately, whose predictions were made in binary, variable 1 x all the others, with the 4 tests that are the results, also made in binary, variable 1 x all others, and after that plot a ROC?

ROC

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.