0
$\begingroup$

I am trying to build a LSTM model for a multiclass classification problem on textual data. Until now, I have only built a model when one input belongs to one of the categories. What do I do when one input can belong to more than one class (i.e.: one entry of data can belong to 2-3 categories)? Can anyone help me with some blogs or resources to build an intuition for making such a model?

Thanks.

$\endgroup$
  • $\begingroup$ What is the proportion of such entries in your dataset? If it is less, then removing such entries is the best choice. $\endgroup$ – Shubham Panchal Jun 6 '19 at 8:12
  • $\begingroup$ @ShubhamPanchal I have around 9000 data points, the number of training points per class varies from 450 to 1500 out of 9000 data points. $\endgroup$ – grvkgp Jun 7 '19 at 6:51
  • $\begingroup$ course.fast.ai/videos/?lesson=3 thank me later go watch it get a great score sleep soundly have a good day and give some upvotes. $\endgroup$ – khwaja wisal Aug 30 '19 at 21:38
1
$\begingroup$

LSTMs, like any other neural net, implicitly support multi-label classification. You should ensure that your output layer has $n$ neurons, one for each class, and you should use logistic activation rather than softmax activation (which is typically used for the final layer in multi-class problems).

Each neuron $N_i$ in the final layer will output a value between 0 and 1. If the output of $N_i$ is greater than 0.5, then the example is a member of label $i$.

Here's a pretty good article that might help: https://towardsdatascience.com/multi-label-classification-and-class-activation-map-on-fashion-mnist-1454f09f5925

| improve this answer | |
$\endgroup$
0
$\begingroup$

When each object can be classified from 0 to multiple categories, it is a multilabel classification problem. There are several approachs to tackle this, the most known is probably the One-vs-the-Rest strategy : it consists in dividing the problem into a multitude of binary classification tasks, for each possible label.

However, deep neural networks support inherently multilabel classification. Each neuron of the final classification layer can be associated with a label. As you would like to have multiple output neurons with high values if an object has several tags, you should use a sigmoid activation function on the final layer and the binary crossentropy loss function.

There are several tutorials on the web : https://towardsdatascience.com/journey-to-the-center-of-multi-label-classification-384c40229bff

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.