2

I need to classify a picture that includes two different images inside. Classes are identical for both images. For example, a picture can include a dog and a cat or two dogs or two cats (In reality, I have much more classes, but all classes are identical for both images and there are always exactly two images inside a picture). Order of the images doesn't matter.

I would prefer to avoid multilabel classification. Thus, I thought to use a one-hot matrix instead of one-hot vector as a label. In this matrix rows are a one-hot vector for the first images, and columns are for the second. Thus, there is only one '1' in the matrix, all others are zeros.

My question is is it possible to use this kind of matrix for classification problem and if it is, does somebody know how to implement it in scikit-learn.

Thanks a lot :)

Inna
  • 663
  • 8
  • 12
  • Out of curiosity, why would you "prefer to avoid multilabel classification"? In this case, it sounds like you have a textbook multilabel problem: `cat/dog, dog/dog, cat/cat` is three distinct classes, where `cat, dog` is a classic binary classification problem? – G. Anderson Jun 03 '19 at 17:36
  • For two reasons: (1) I have much more classes that I mentioned in this example, (2) I implement a convolutional network in tensorflow for classification and I am relatively new to it, so I was looking for a method to simplify the problem... But maybe you are right :) If you have a link to a good example for it, I would be happy to look! Thanks :) – Inna Jun 03 '19 at 17:45
  • 2
    I understand the instinct, but you'll likely be making things much, much more complicated trying to shoehorn a binary solution into a mulitlabel problem, instead of using something tried and true like the built-in [multilabel binarizer](https://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.MultiLabelBinarizer.html) to transform your class labels – G. Anderson Jun 03 '19 at 17:52
  • Thanks, I'll try it! – Inna Jun 03 '19 at 17:55

0 Answers0