Multi label Classification Evaluation Problem

Hello Pytorch Community ,

I’m a machine learning student recently involved into PyTorch and i have a question regarding multi-label classification
I have trained my neural network based on BCEWithLogitsLoss for a 27-classes classification problem . However , as soon as I started trying to evaluate my model , i struggled …
For the sake of clarity let s limit our example to 6 classes
I’m using One hot encoding … so as a result for instance :
for a sample Xi i ll get
y_true = [ 0 , 1 , 0 , 1 , 0 , 0 ]
y_pred = [ 0 , 1 , 0 , 0 , 0 , 1 ]

how to evaluate my test_dataset using pytorch ? i was thinking about F1 measure ?
What about the predicted zeros ? are there significant in our sparse Y to evaluate our model ?Screenshot%20from%202019-04-16%2001-35-10

You could create a confusion matrix and calculate the per-class metrics as described in this post with an example. Would that work for you?

It’s not exactly the same because I’m using one hot enconding : for my 27 classes
I think i found a solution here :
https://scikit-learn.org/dev/modules/generated/sklearn.metrics.multilabel_confusion_matrix.html