KeyError: 'micro' on creating multi class ROC curve plot

I am receiving this error:

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-125-d9abb4d5479a> in <module>
     16 plt.figure()
     17 plt.plot(
---> 18     fpr["micro"],
     19     tpr["micro"],
     20     label="micro-average ROC curve (area = {0:0.2f})".format(roc_auc["micro"]),

KeyError: 'micro'

<Figure size 432x288 with 0 Axes>

using this script:

all_fpr = np.unique(np.concatenate([fpr[i] for i in range(len(n_classes))]))
lw = 5
# Then interpolate all ROC curves at this points
mean_tpr = np.zeros_like(all_fpr)
for i in range(len(n_classes)):
    mean_tpr += np.interp(all_fpr, fpr[i], tpr[i])

# Finally average it and compute AUC
mean_tpr /= n_classes

fpr["macro"] = all_fpr
tpr["macro"] = mean_tpr
roc_auc["macro"] = auc(fpr["macro"], tpr["macro"])

# Plot all ROC curves
plt.figure()
plt.plot(
    fpr["micro"],
    tpr["micro"],
    label="micro-average ROC curve (area = {0:0.2f})".format(roc_auc["micro"]),
    color="deeppink",
    linestyle=":",
    linewidth=4,
)

plt.plot(
    fpr["macro"],
    tpr["macro"],
    label="macro-average ROC curve (area = {0:0.2f})".format(roc_auc["macro"]),
    color="navy",
    linestyle=":",
    linewidth=4,
)

colors = cycle(["aqua", "darkorange", "cornflowerblue"])
for i, color in zip(range(len(n_classes)), colors):
    plt.plot(
        fpr[i],
        tpr[i],
        color=color,
        lw=lw,
        label="ROC curve of class {0} (area = {1:0.2f})".format(i, roc_auc[i]),
    )

plt.plot([0, 1], [0, 1], "k--", lw=lw)
plt.xlim([0.0, 1.0])
plt.ylim([0.0, 1.05])
plt.xlabel("False Positive Rate")
plt.ylabel("True Positive Rate")
plt.title("Some extension of Receiver operating characteristic to multiclass")
plt.legend(loc="lower right")
plt.show()

if I comment the micro part of the script, the plot shows only class 0, not class 1 and 2 of target y. I would like to relabel those classes as well to show the class labels of the iris dataset which is what this is using.

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum