Get Explanations For the Classification Results with Watson Categories

Gaurav Kumbhat
IBM Data Science in Practice
2 min readApr 26, 2019

AI and machine learning systems are considered as black box especially when they are being consumed with an API. Users may wonder: how did the system predict a certain output and what contributed to the prediction? IBM Watson Natural Language Understanding now makes it easier to understand the results of the categorization feature, by giving explanations for each predicted label. This explanation is provided in the form of snippets from the input text itself that contributed towards the results.

Categories is a hierarchical classification system that predicts labels up to 5 levels of hierarchy. Now, with a simple toggle `explanation: true`, users will be able to get explanations for the predictions. This feature can also be used with our newly released customization of categories. For those who are using this customization option and looking to improve their model, this explanation can come in handy, as it can point towards the text snippets that cause the system to predict incorrect labels.

How can I use it?

This new feature can be turned on with a simple explanation toggle, example request body:

{
"url": " https://en.wikipedia.org/wiki/IBM",
"features": {
"categories":{
"explanation": true
}
}
}

This will enable the explanation engine and will return output in the following format:

{
"retrieved_url": "https://en.wikipedia.org/wiki/IBM",
"language": "en",
"categories": [
{
"score": 0.950583,
"label": "/technology and computing/hardware/computer",
"explanation": {
"relevant_text": [ {
"text": "personal computer"
},
{
"text": "ibm pc"
},
{
"text": "computing"
},
{
"text": "floppy disk"
},
{
"text": "computer hardware"
},
{
"text": "computer system"
}
]}
}]
}

In the above output, “relevant text” contains key phrases from the input text that contributed towards the prediction of the label. For example, phrases such as “personal computer”, “ibm pc”, “computing” and “floppy disk” played a key role in predicting “/technology and computing/hardware/computer” as the category label for the input text .

Try it out yourself!

Thanks for reading! Checkout these resources to get started.

Watson Natural Language Understanding | IBM Watson API Reference

--

--