AUC ROC in IRIS dataset

Dear all, i am using the tutorial_variatonal_classifier/

I am working on IRIS dataset and i was wondering how i can sketch a AUC ROC curve graph. If there is an easy way please let me know.

Thanks in advance


I actually solved it, here is the code for confusion matrix and AUC ROC:

from sklearn.metrics import confusion_matrix
from sklearn import svm, datasets
from sklearn.metrics import roc_curve, auc
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import label_binarize
from sklearn.multiclass import OneVsRestClassifier
from scipy import interp
from sklearn.metrics import roc_auc_score

conf_mat = confusion_matrix(y_test, y_score) 

fpr = dict()
tpr = dict()
roc_auc = dict()

for i in range(len(y_test)):
    fpr[i], tpr[i], _ = roc_curve(y_test, y_score)
    roc_auc[i] = auc(fpr[i], tpr[i])

fpr["micro"], tpr["micro"], _ = roc_curve(y_test.ravel(), y_score.ravel())
roc_auc["micro"] = auc(fpr["micro"], tpr["micro"])

lw = 2
plt.plot(fpr[2], tpr[2], color='darkorange',
         lw=lw, label='ROC curve (area = %0.2f)' % roc_auc[2])
plt.plot([0, 1], [0, 1], color='navy', lw=lw, linestyle='--')
plt.xlim([0.0, 1.0])
plt.ylim([0.0, 1.05])
plt.xlabel('False Positive Rate')
plt.ylabel('True Positive Rate')
plt.title('Receiver operating characteristic example Ν=15 steps')
plt.legend(loc="lower right")

Glad to hear it’s now working @NikSchet, and thanks for posting your solution! That will be really helpful to anyone else having the same problem.

Let us know if you have any other questions :slightly_smiling_face: