Reputation: 841
Consider i have a classifier like A
and the result of its classification gives me the following table:
TP TN FP FN
A 225 100 175 100
TP is True Positive
TN is True Negative
FP is False Postive
FN is False Negative
How i can draw a plot curve of ROC?
I know, i can define a variable, and try to predict it based on A, and then make a dataframe which exactly simulate the above values, and finally, i can use this code. But i think there should be an easier way?
Upvotes: 4
Views: 16086
Reputation: 2408
This is impossible, because you only have a confusion matrix for a certain (unknown) threshold of your classifier. A ROC-Curve contains information about all possible thresholds.
The Confusion matrix corresponds to a single point on your ROC Curve:
Sensitivity = TP / (TP + FN)
1 - Specificy = TN / (TN + FP) .
Upvotes: 5
Reputation: 173
I don't understand why you'd simulate a new variable. You're basically asking to plot a curve from a single point, which is impossible. Instead, you should just use the dependent variable in the training or test data that you used to train the model. This will allow you to find a cutoff point that you consider optimal.
The pROC package allows us to plot ROC curves easily. Assuming we have a data frame named test and a model named mymodel, we could use something like this:
library('pROC')
plot(roc(test$y, predict(mymodel, test, type = "prob"))
Upvotes: 0