I’m using fastai to for a text classification problem. I have 45 different classes and at first look, fastai seems to be quite good after only 10 epochs achieving 84.99% accuracy.
First question, I’m using the Precision() metric offered by the metrics module. Tried both micro and macro and both give nan. Any ideas why that is? It’s not too important because for the purpose of this specific task (single label, no threshold), the precision will always be the same as accuracy, but I’m curious why this happens.
My bigger question is that if I run the following :
preds, y = learn.get_preds(ds_type=DatasetType.Valid, ordered=True) y = torch.argmax(preds, dim=1)
and I then use scikitlearn to get the predictions with:
I get an accuracy of 0.54127 which is very far from the fastai one.
This problem has been bugging me for a while now and I can’t seem to find an explanation.
Morever, if I analyse the results given by fastai further, I get results that should match the 84.9% accuracy.
interp = TextClassificationInterpretation.from_learner(learn) x = interp.most_confused() s = 0 for i in x: s += i print("Total number of wrong classifications:", s) acc = 1 - 1413/len(valid) print("Accuracy based on this:", acc)
Total number of wrong classifications: 1413 Accuracy based on this: 0.8498884521406566
Any insights would be appreciated!