Classify Natural Language without a Background in Machine Learning

With the Natural Language Classifier Watson service in IBM Bluemix developers can classify natural language so that, for example, you can build a virtual agent application that answers common questions. Below is a simple sample how you can use this service.

Here is a description on the service: “The service enables developers without a background in machine learning or statistical algorithms to create natural language interfaces for their applications. The service interprets the intent behind text and returns a corresponding classification with associated confidence levels. The return value can then be used to trigger a corresponding action, such as redirecting the request or answering a question.”

In order to use the service you need to provide training data that defines the different classes and text samples that fall under certain classes. In the scenario below I have two classes – positive and negative.

really good,positive
really bad,negative

Save this file as cvs file and send it to the Watson service.

curl -i -u "<username>":"<password>" -F training_data=@./data_train.csv -F training_metadata="{\"language\":\"en\",\"name\":\"PosNegClassifier\"}" "

After a couple of minutes the training is done and the Watson service returns a classifier_id that you need to ask the service under which classes specific text falls. Here is a request for the word “awesome” which was not in the initial training data.

curl -G -u "<username>":"<password>" "" --data-urlencode "text=awesome"

The Watson service returns not only one class but up to the top five classes with the highest confidence levels.


To learn more about the service check out the online demo, the engagement gallery sample application, the documentation and the API documentation.

In order to improve the quality of the classifier you need to evaluate the results and update the training data. To simplify the management of the training data and the classifiers there is a toolkit/web application available.


Leave a Reply