Confusion matrix for multicategory not working as expected

I am following the course about multi category labels:
fastbook/06_multicat.ipynb at master · fastai/fastbook (github.com)

Rather naively, I wanted to get a feel for how good the classifier worked. I started to copy some code from chapter 2 in order to apply it on chapter 6. I injected all code below after line:

learn = cnn_learner(dls, resnet50, metrics=partial(accuracy_multi, thresh=0.2))
learn.fine_tune(3, base_lr=3e-3, freeze_epochs=4)

The first thing I tried to do was to generate the confusion matrix with the following code:

interp = ClassificationInterpretation.from_learner(learn)
interp.plot_confusion_matrix(figsize=(10,10))

This indicated that all information is just under two labels:

What am I doing wrong and how could I make this confusion matrix work for multicategory classifiers? Or is it actually working and is there something wrong with the underlying learning code?

1 Like

I don’t think I have ever got it to work for multi-classification

Code is here if you want to take a look
https://github.com/fastai/fastai/blob/master/fastai/interpret.py#L51

1 Like