Reputation: 85
I am classifying certain objects into 5 classes with labels [0,1,2,3,4], by human.
A set of true labels: true_label = [3, 4, 2, 1, 0, 2 ............, 3]
A set of predicted labels: predictions = [3, 4, 2, 2, 0, 2, ........., 3]
How do I plot a ROC curve with such hard class predictions?
Plotting ROC curve (with sklearn API), seems to require predictions in terms of probabilities, but there are no such probabilities with categorical prediction by human. A human cannot give a 'probability' for certain prediction, he/she just thinks the object is 2
, but not 2 with 93% probability
.
How do I plot ROC curve with the numpy list true_label
and predictions
above?
Upvotes: 0
Views: 947
Reputation: 6333
You cannot plot a ROC curve using predicted labels.
As with any ROC curve function, sklearn's roc_curve()
is designed to receive an array of true labels and an array of probabilities.
You can find more detailed answers in this question, but in essence, the function uses each predicted probability as a threshold to yield one array of predicted labels. In turn, each threshold yields a true positive rate and a false positive rate. Repeating this process for each element in the array of predicted probabilities results in a ROC curve.
If you only have the predicted labels, I suggest you measure the accuracy, true positive rate, false positive rate, etc.
from sklearn.metrics import confusion_matrix
confusion_matrix(y_true=true_label, y_pred=predictions)
Upvotes: 3