Hello ,
I have trained recently an RNN classifier and it gave me an Overall Accuracy of 80% , Now I want to know the F-score for each class ? is this possible in pytorch ?
and Thank you
I do not believe there is any binding to directly compute it with pytorch. But considering that you computed the OA, I assume you have the confusion matrix. From there, it is pretty straightforward to compute the F-scores per class.
F1Score = np.zeros(len(classes))
for cls in range(len(classes)):
try:
F1Score[cls] = 2.*confusion[cls, cls]/(np.sum(confusion[cls, :])+np.sum(confusion[:, cls]))
except:
pass
print("F1Score: ")
for cls, score in enumerate(F1Score):
print("{}: {:.2f}".format(classes[cls], score))
Hope that helps.