Multi-Label Classification: Overview & How to Build A Model

Multi-label classification is an AI text analysis technique that automatically labels (or tags) text to classify it by topic. This differs from multi-class classification because multi-label can apply more than one classification tag to a single text.

Text classification uses machine learning to analyze text (news articles, emails, social media, etc.) and classify it with predetermined tags, usually topics, like customer service, pricing, etc. It can be a massive time-saver, when analyzing huge amounts of text for your business.

Text classification can be used to search for your brand on social media and classify comments by product or subject. It can be helpful for assigning topics to emails or customer service tickets, in order to route them to the appropriate department. However, not every ticket you receive will fall into just one category. This is where multi-label classification comes in.

You can try MonkeyLearn’s NPS Feedback Analyzer to get an idea of how text classification works. 

Multi-class vs Multi-label Classifiers

Multi-class classifiers are designed to give each piece of text only one category (or class) tag. For example, if you are classifying “Kinds of Entertainment,” class tags could be: Books, Movies, TV Shows, etc. 

In this example, the tag for “When Harry Met Sally” would be: Movie.

Multi-label classifiers, on the other hand, are able to output several tags at the same time. You could be tagging “Movies” by genre: Comedy, Drama, Romance, Horror, etc.

In this case, “When Harry Met Sally” could be tagged (or multi-labeled) both Comedy and Romance.

Multi-label classifiers are great for customer service, for example, because they can tag a customer ticket with more than one label, so that it could be brought to the attention of multiple departments. Say you are labeling tickets with tags like, Shipping, UX, Speed, Functionality, etc. 

Sample Email

My software arrived a few days late. I was able to install it right away, but now I can’t figure out how to log out.

The above could be tagged as both: Shipping and UX, for example.

MonkeyLearn offers easy-to-use text analysis tools that can help you get the most out of text data, like online reviews, customer surveys, social media posts, and more. In addition to classifiers, you can try out MonkeyLearn’s sentiment analyzer and keyword extractor for free.

Or follow along to learn how to create your own multi-label classifier.

How to Build a Multi-label Classifier

Now you’re ready to train a classifier built for your specific needs.

1. Create a New Classifier

Sign up for a free MonkeyLearn account.

Go to the MonkeyLearn dashboard, click ‘Create a Model,’ then choose ‘Classifier’:

The option to choose an extractor or classifier in MonkeyLearn’s model builder.

2. Select ‘Topic Classification’:

The option to choose from three classifiers: topic, sentiment and intent.

3. Upload Your Training Data

You can upload a CSV or Excel file with social media data, user reviews, support tickets, etc. Or import data directly from third-party apps like Zendesk, Twitter, Gmail, and more.

If you don’t have a file readily available, click ‘Data Library’ to download a sample dataset.

A selection of apps and sources you can click on to connect and upload your data.

4. Define the Labels/Tags for your Model

Create the set of labels you want your texts to be classified as. Use labels that are most appropriate for your business. It’s best to keep the total number of labels to just a few (definitely less than 10), at least in the beginning. Machine learning can be trained for extremely complex tasks, but it will learn more quickly if given clearly determined tasks at the beginning. 

If you aren’t sure that there will be enough pieces of text for each tag, wait to create that tag until later. And avoid situations where one tag could be confused with another.

Click ‘+’ when you’ve added each, then ‘Continue’ when you’re finished:

Tags entered into a text field, and added to a classifier for training

5. Train your Multi-label Classifier

Tag each example with the appropriate label(s). Note the example below that’s tagged with two labels:

Text being tagged and classified by clicking on relevant tags.

6. Test Your Classification Model

Now it’s time to test your model. Choose the ‘Run’ tab. 

You can enter text directly in the box by choosing ‘Demo’ in the upper left. Or, click ‘Batch’ and upload a whole new file. 

The model will assign a tag and show you the confidence score. The more you train your model, the more accurate it will become.

New text being entered to test a multi-label classifier.

From here, you can also change your “tagging strategy.” This isn’t necessary because the default is “Autodetect.” But if you’d like to change to “Multi-Tag,” go to the settings of the model and change ‘Tagging Strategy’ to ‘Multi-Tag.’

select multi tag

Click ‘Stats’ to see how well your model is performing. Here you can also see a word cloud for each label to visualize the most used words for each tag.

The "Stats" menu showing number of texts, Accuracy, F1 Score, and a word cloud to show which words are used most.

If your accuracy isn’t quite up to snuff, you can keep training in the ‘Train’ tab, or retag incorrect labels.

7. Put Your Classifier to Work!

Now that you have a classifier trained to your needs, you can integrate it with apps you already use, like Google Sheets, Zendesk, Excel, SurveyMonkey, and more. Check out the integrations page to learn how. Or integrate your model with MonkeyLearn APIs in the programming language of your choice.

Wrap Up

It’s clear that multi-label classification can be an extremely helpful tool to save time and get the most out of your text data. Machine learning technology can organize hundreds of pages of text in just a few minutes to get powerful insights.

Take a look at this article on customer ticket classification to learn more about a common use case for multi-label classification.

MonkeyLearn’s suite of text analysis tools will help you get the most out of your data. Sign up for free and give them a try.

Rachel Wolff

June 8th, 2020