How to Build a Text Classifier Using IBM Watson NLC service

Train a text classifier using Watson Studio without coding

Mohamed Gharibi
Towards Data Science

--

Image by Romain Vignes— Unsplash

Text Classification

Text classification is another task that falls under Data Science and Machine Learning where we assign each document/sentence/tweet one or more classes or categories (labeling nature language text with relevant categories). For example, classifying this sentence “Lionel Messi Named World Player Of The Year In World Soccer Awards” as a “Sport” statement.

Building the model

We will build a classifier that classifies StackOverflow questions to one of the top 20 tags. The data used is available on BigQuery or you can click here to download. This data contains StackOverflow posts with a single tag. 2000 posts for each tag, so 40,000 posts is the total.

First, you need to create a project:

After choosing a project, a similar view should appear. Click on “Add to project” button to start our journey.

There are many different models that you can build using AutoAI. To build a text classifier, click on “Natural Language Classifier”

Training a classifier requires a service. Click “here” to acquire one, if it is your first time.

Choose a plan.

If it is your first time, choose the default setting and click “confirm”

Otherwise, you will be redirected to a page where you can choose one of your services

This is the main page, click “Browse” on the top right corner to upload your file. On the left side, a list of all your tags and posts will appear. That allows you to edit a post, add, delete, rename, etc.

The magic starts when you click “Train Model”.

After the training phase, you should get a notification. Click on “here”

You will be redirected to a new page with three tabs: Overview, Test, Implementation

Click on “Test” to test the model. Write a sentence and click “Classify”. You can change the threshold to obtain the results with a specific probability.

Finally, click on “Implementation” and you will be provided with instructions on how to send inference requests to the model.

Thanks for reading. Please let me know if you have any questions!

Resources

--

--