TransWikia.com

How to tackle a multilabel classification problem

Data Science Asked by grvkgp on January 3, 2021

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.

2 Answers

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.

Answered by Alexis Pister on January 3, 2021

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.

Answered by zachdj on January 3, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP