Error when plotting Confusion Matrix in Fastai

I am getting the following error when plotting the confusion matrix.

Can someone suggest what this error implies?
Thanks very much.

How did you build your dataloaders? Are they raw torch loaders? fastai dataloaders?


I have used fastai to build my dataloaders.


Can you show the code you used to make it?

PLease see the code below:

You’re not using the fastai datablock API here, and that’s the issue. I’m not sure it will work here, but you can try. The confusion matrix and interp were designed for full use of the fastai API (to my knowledge), and so it expects certain things to be there. In this case it’s a classification problem, and fastai stores the number of classes in dls.dataset.c

You need to throw on a c attribute to your dataset (ie the number of classes). So just do dl[0].dataset.c = mynumclasses

Thanks so much for the help.