Deep learning Implementation: Multilabel Classifier
No Bullshit: Multi-label Text classification Using Keras
Discusses Implementation details with code
2 min readFeb 8, 2022
The goal of this blog is to dig right into the weeds of implementing a multilabel text classifier using Keras. If you have clicked on this story, I assume you are familiar with the problem formulation and how it differs from a traditional multiclass classifier. So let’s cut right to the chase.
Implementation notes:
- For a multilabel text classifier, for each training example, we have multiple labels. As a result, LabelBinarizer should be replaced by MultiLabelBinarizer.
- ‘‘Sigmoid’’ activation should be used in the final layer instead of “Softmax” activation.
- Each class in a multilabel setup is assumed to be a Bernoulli random variable and hence we shall use
binary_cross_entropy
loss function instead of acategorical_cross_entropy
loss. - Finally, the choice of evaluation metric is pivotal while training a multilabel classifier. Traditional evaluation metrics like accuracy do NOT make sense in the multilabel universe. We shall leverage a custom evaluation metric called α- Evaluation metric introduced by Boutell et. al. in Learning…