Help in Multi Label Classification

Hello everyone ,
I have to solve a problem where an Image is provided with multiple labels ,
There are a total 13 labels , of which each Image can be assigned to 1 or more labels .
could anyone please tell me solution for it ?
and how could I interpret loss and accuracy for such problem statement !

Really Thanks for your time !! :slight_smile:

I think you could change the sparse label into one-hot format, then considering it as a ‘binary classification problem’.

@MariosOreo one-hot won’t help, as “each Image can be assigned to 1 or more labels”.

This is not only multi-label classification, but also multi-class, which is harder. Benchmarks which aim at solving this type of classification are for example Microsoft COCO, Open Images, PASCAL VOC, and many others.

I think you can use cross entropy as loss, to be verified.

For metrics you should check precision and recall as well as F1-score, which is the harmonic average of P and R for more stability than just taking the mean.

Thank you for responding :slight_smile:

one-hot can help, for example:
one image raw label is [1, 3, 5]; then transform to one-hot form as [1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0 , 0, 0],
outputs shape is (n, 13), then use BCEWithLogitsLoss as loss function, I think @MariosOreo’s solution is right.

I agree with most of what you say. But your example is actually “three-hot” :wink:

haha, you are right. I don’t know how to call that format, similar like one-hot format.

One more thing, I think mAP is a good metrics for this problem.

That also works, but IMHO it’s a worse indicator when facing imbalanced datasets or imbalanced “hardness” of the classes. For example if you have a very easy class and a very hard class, you’ll get a high AP for the first and low AP for the second, which average to a “meh” AP overall. The worst case is you have many very easy classes and few very hard classes, the average will hide the very low performance on the hard classes, but maybe that hard class is very important to you and you don’t know it unless you show the AP for every class…