<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Prem Piyush Goyal on Medium]]></title>
        <description><![CDATA[Stories by Prem Piyush Goyal on Medium]]></description>
        <link>https://medium.com/@prempiyush?source=rss-30ec920c0364------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*l_f1B7-chrTVMasmDrMxsg.png</url>
            <title>Stories by Prem Piyush Goyal on Medium</title>
            <link>https://medium.com/@prempiyush?source=rss-30ec920c0364------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 18:11:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@prempiyush/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to access your data in S3 from your Spark + Hadoop + Hive cluster]]></title>
            <link>https://medium.com/@prempiyush/how-to-access-your-data-in-s3-from-your-spark-hadoop-hive-cluster-f950e346efb0?source=rss-30ec920c0364------2</link>
            <guid isPermaLink="false">https://medium.com/p/f950e346efb0</guid>
            <category><![CDATA[hadoop]]></category>
            <category><![CDATA[apache-spark]]></category>
            <category><![CDATA[s3]]></category>
            <category><![CDATA[apache-hive]]></category>
            <category><![CDATA[watson-openscale]]></category>
            <dc:creator><![CDATA[Prem Piyush Goyal]]></dc:creator>
            <pubDate>Mon, 22 Nov 2021 05:18:04 GMT</pubDate>
            <atom:updated>2021-11-22T05:29:11.250Z</atom:updated>
            <content:encoded><![CDATA[<h3>Things you will need:</h3><ol><li>AWS Access Key ID</li><li>AWS Secret Access Key</li><li>The uri to the folder that has the data files. It should start with <strong>s3a</strong>. As per Apache Hadoop official docs:</li></ol><blockquote>Apache Hadoop ships with a connector to S3 called “S3A”, with the url prefix “s3a:”; its previous connectors “s3”, and “s3n” are deprecated and/or deleted from recent Hadoop versions.</blockquote><p>4. hadoop-aws-2.10.0.jar: This jar contains the implementation of the S3A connector. The version of this jar should be same as the hadoop version. Any mix and match of the versions of this jar and hadoop might result in an exception. We used the v2.10.0 of this jar as this was our hadoop version as well.</p><p>5. aws-java-sdk-bundle-1.11.271.jar: This jar is a dependency of the above hadoop-aws jar. The correct version to be used can be taken from any jar repository like <a href="https://mvnrepository.com/artifact/org.apache.hadoop/hadoop-aws">mvnrepository</a>. We used the v1.11.271 of this jar as it was listed as the dependency of the hadoop-aws-2.10.0.jar <a href="https://mvnrepository.com/artifact/org.apache.hadoop/hadoop-aws/2.10.0">here</a>.</p><p>Both the above jars usually come with the hadoop bundle. You might want to search for them first in your hadoop home directory before downloading them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0X_OkoPR6ta1fgDiJ-4ZTg.png" /><figcaption>Transferring data to and fro between S3 and Hive</figcaption></figure><p>The following configuration changes are required for you to be able to access your data in the S3 bucket. These need to be done on every node. Some files not be present on all nodes e.g. hive-site.xml</p><h4><strong>1. core-site.xml</strong></h4><pre>&lt;property&gt;<br>   &lt;name&gt;fs.s3a.access.key&lt;/name&gt;<br>   &lt;value&gt;AWS_ACCESS_KEY_ID&lt;/value&gt;<br>&lt;/property&gt;</pre><pre>&lt;property&gt;<br>   &lt;name&gt;fs.s3a.secret.key&lt;/name<br>   &lt;value&gt;AWS_ACCESS_SECRET_KEY&lt;/value&gt;<br>&lt;/property&gt;</pre><pre>&lt;property&gt;<br>    &lt;name&gt;fs.s3a.impl&lt;/name<br>    &lt;value&gt;org.apache.hadoop.fs.s3a.S3AFileSystem&lt;/value&gt;<br>&lt;/property&gt;</pre><h4><strong>2. hdfs-site.xml</strong></h4><pre>&lt;property&gt;<br>    &lt;name&gt;fs.s3a.access.key&lt;/name&gt;<br>    &lt;value&gt;AWS_ACCESS_KEY_ID&lt;/value&gt;<br>&lt;/property&gt;</pre><pre>&lt;property&gt;<br>    &lt;name&gt;fs.s3a.secret.key&lt;/name&gt;<br>    &lt;value&gt;AWS_ACCESS_SECRET_KEY&lt;/value&gt;<br>&lt;/property&gt;</pre><h4><strong>3. mapred-site.xml</strong></h4><pre>&lt;property&gt;<br>    &lt;name&gt;fs.s3a.impl&lt;/name&gt;<br>    &lt;value&gt;org.apache.hadoop.fs.s3a.S3AFileSystem&lt;/value&gt;<br>&lt;/property&gt;</pre><h4><strong>4. hadoov-env.sh</strong></h4><pre>export HADOOP_CLASSPATH=$HADOOP_CLASSPATH:/home/hadoop/hadoop/share/hadoop/tools/lib/hadoop-aws-2.10.0.jar:/home/hadoop/hadoop/share/hadoop/tools/lib/aws-java-sdk-bundle-1.11.271.jar</pre><p><em>Note: Replace the paths to your </em><em>hadoop-aws and </em><em>aws-java-sdk-bundle jars above.</em></p><h4><strong>5. hive-site.xml</strong></h4><pre>&lt;property&gt;<br>    &lt;name&gt;fs.s3a.access.key&lt;/name&gt;<br>    &lt;value&gt;AWS_ACCESS_KEY_ID&lt;/value&gt;<br>&lt;/property&gt;</pre><pre>&lt;property&gt;<br>    &lt;name&gt;fs.s3a.secret.key&lt;/name&gt;<br>    &lt;value&gt;AWS_ACCESS_SECRET_KEY&lt;/value&gt;<br>&lt;/property&gt;</pre><h4><strong>6. hive-env.sh</strong></h4><pre>export HIVE_AUX_JARS_PATH=/home/hadoop/hadoop/share/hadoop/tools/lib/hadoop-aws-2.10.0.jar:/home/hadoop/hadoop/share/hadoop/tools/lib/aws-java-sdk-bundle-1.11.271.jar</pre><p><em>Note: Replace the paths to your </em><em>hadoop-aws and </em><em>aws-java-sdk-bundle jars above.</em></p><h4><strong>7. spark-env.sh</strong></h4><pre>export SPARK_DIST_CLASSPATH=$SPARK_DIST_CLASSPATH:/home/hadoop/hadoop/share/hadoop/tools/lib/hadoop-aws-2.10.0.jar:/home/hadoop/hadoop/share/hadoop/tools/lib/aws-java-sdk-bundle-1.11.271.jar</pre><p><em>Note: Replace the paths to your </em><em>hadoop-aws and </em><em>aws-java-sdk-bundle jars above.</em></p><h3>Restart everything</h3><p>For the above changes to take effect, you need to start the various components on your cluster.</p><ol><li>Restart HDFS from the name node</li><li>Restart YARN from the resource manager node</li><li>Restart the Hive metastore e.g. MySQL</li><li>Restart Hive</li><li>Restart Livy</li></ol><h3>Test if everything is working correctly</h3><h4><strong>1. HDFS</strong></h4><p>To verify if you can access the S3 folder and files from HDFS, first list all the files in the S3 folder and then list the contents of a file in that folder.</p><pre>[hadoop@weka1 ~]$ hdfs dfs -ls s3a://ppg-test-bucket/drug/<br>Found 5 items<br>-rw-rw-rw-   1 hadoop hadoop       5485 2021-11-12 07:30 s3a://ppg-test-bucket/drug/part-00000.csv<br>-rw-rw-rw-   1 hadoop hadoop       5484 2021-11-12 07:30 s3a://ppg-test-bucket/drug/part-00001.csv<br>-rw-rw-rw-   1 hadoop hadoop       5509 2021-11-12 07:30 s3a://ppg-test-bucket/drug/part-00002.csv<br>-rw-rw-rw-   1 hadoop hadoop       5463 2021-11-12 07:30 s3a://ppg-test-bucket/drug/part-00003.csv<br>-rw-rw-rw-   1 hadoop hadoop       5491 2021-11-12 07:30 s3a://ppg-test-bucket/drug/part-00004.csv</pre><pre>[hadoop@weka1 ~]$ hdfs dfs -cat s3a://ppg-test-bucket/drug/part-00000.csv<br>AGE,SEX,BP,CHOLESTEROL,NA,K,DRUG<br>65,F,NORMAL,NORMAL,0.390133,0.02939,drugB<br>58,M,NORMAL,NORMAL,0.64505,0.0302596,drugX<br>49,M,NORMAL,HIGH,0.8365,0.027715,drugA<br>66,F,HIGH,LOW,0.5200,0.0202175,drugA<br>61,M,HIGH,HIGH,0.210987,0.0124347,drugC<br>59,F,HIGH,LOW,0.270076,0.071714,drugA<br>25,F,HIGH,LOW,0.216364,0.046974,drugB<br>37,M,LOW,NORMAL,0.49989,0.047713,drugA</pre><h4><strong>2. Hive</strong></h4><p>We will first create an external table in Hive that will point to the S3 folder as the data location. We can then list out the rows in the table and do a count on it too.</p><pre>hive&gt; CREATE EXTERNAL TABLE IF NOT EXISTS pp.table_drug (`AGE` int, `SEX` string, `BP` string, `CHOLESTEROL` string, `NA` double, `K` double, `DRUG` string) ROW FORMAT DELIMITED FIELDS TERMINATED BY &#39;,&#39; STORED AS TEXTFILE  LOCATION &#39;s3a://ppg-test-bucket/table_drug/&#39; TBLPROPERTIES (&#39;skip.header.line.count&#39;=&#39;1&#39;);</pre><pre>OK<br>Time taken: 4.495 seconds</pre><pre>hive&gt; select * from pp.table_drug limit 5;</pre><pre>OK</pre><pre>65  F   NORMAL  NORMAL  0.390133    0.02939     drugB<br>58  M   NORMAL  NORMAL  0.64505     0.0302596   drugX<br>49  M   NORMAL  HIGH    0.8365      0.027715    drugA<br>66  F   HIGH    LOW.    0.5200      0.0202175   drugA<br>61  M   HIGH    HIGH    0.210987    0.0124347   drugC</pre><pre>Time taken: 0.211 seconds, Fetched: 5 row(s)</pre><pre>hive&gt; select count(*) from pp.table_drug;</pre><pre>Query ID = hadoop_20211121053246_f1191b7e-e094-49b5-9659-1b6c860b5794</pre><pre>Total jobs = 1<br>Launching Job 1 out of 1</pre><pre>Starting Spark Job = b9b1e65a-cc62-4b9b-a814-1c77cc6e6a18<br>Running with YARN Application = application_1637160491126_0030<br>Kill Command = /home/hadoop/hadoop/bin/yarn application -kill application_1637160491126_0030</pre><pre>Query Hive on Spark job[0] stages: [0, 1]<br>Status: Running (Hive on Spark job[0])</pre><pre>Status: Finished successfully in 14.10 seconds<br>OK</pre><pre>1000</pre><pre>Time taken: 31.15 seconds, Fetched: 1 row(s)</pre><h4><strong>3. Spark</strong></h4><p>To verify if everything is working well from Spark, run this simple Spark job. The job first reads the CSV from the S3 folder and does a count on the dataframe. It then reads the Hive table that was configured in above steps and again does a count on the dataframe.</p><pre>from pyspark.sql import SparkSession</pre><pre>spark = None<br>try:<br>    spark = SparkSession.builder.appName(&quot;S3 data check&quot;).enableHiveSupport().getOrCreate()<br>    sc = spark.sparkContext</pre><pre>    print(&quot;========================&quot;)<br>    print(spark.version)</pre><pre>    # Read the csv folder directly from S3<br>    spark_df = spark.read.csv(&quot;s3a://ppg-test-bucket/drug&quot;, header=True, inferSchema=True)<br>    spark_df.printSchema()<br>    print(spark_df.count())</pre><pre>    # Read the Hive table<br>    spark_df = spark.sql(&quot;select * from pp.table_drug&quot;)<br>    spark_df.printSchema()<br>    print(spark_df.count())<br>    print(&quot;========================&quot;)<br>except Exception as ex:<br>    print(str(ex))<br>    raise ex<br>finally:<br>    if spark is not None:<br>        spark.stop()</pre><h3>Conclusion</h3><p>Hopefully, you were able to configure your Spark cluster to access data from your S3 bucket by following the instructions above.</p><p>A few points to note before concluding this post:</p><ol><li>This was tested on a Hive without Kerberos enabled setup. With Kerberos enabled, a few other steps might be involved to get this working.</li><li>Hadoop also has an in-built jar for Azure. So, in theory, this exercise can also be done for Azure storage.</li><li>If you are an IBM Watson OpenScale user, and have landed here to find out how ot make your S3 data work with IBM Watson OpenScale, please write to me at <a href="/service/mailto:prempiyush@in.ibm.com">prempiyush@in.ibm.com</a>.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f950e346efb0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Explaining your Watson Assistant chatbot using Watson OpenScale]]></title>
            <link>https://medium.com/ibm-data-ai/explaining-your-watson-assistant-chatbot-using-watson-openscale-9515e90cbdab?source=rss-30ec920c0364------2</link>
            <guid isPermaLink="false">https://medium.com/p/9515e90cbdab</guid>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[explainability]]></category>
            <category><![CDATA[watson-openscale]]></category>
            <category><![CDATA[watson-assistant]]></category>
            <category><![CDATA[ai-trust]]></category>
            <dc:creator><![CDATA[Prem Piyush Goyal]]></dc:creator>
            <pubDate>Fri, 17 Apr 2020 03:11:27 GMT</pubDate>
            <atom:updated>2021-05-24T21:15:25.135Z</atom:updated>
            <content:encoded><![CDATA[<p>A core artefact of Watson Assistant is an <strong>intent </strong>which according to the Watson Assistant documentation — <em>“represents the purpose of a user’s input, such as a question about business locations or a bill payment. You define an intent for each type of user request you want your application to support”. </em>e.g. The intent for the input “I would like to speak to someone” will be “Asking for Supervisor”. Another one, “Send me the location details to your nearest store” could be “Asking for Location”. These user-defined intents in your Watson Assistant application decide, how your chatbot will branch into a conversation.</p><p>The purpose of this post is to help a Watson Assistant user understand why a specific intent was selected by Watson Assistant for the customer input with the help of Explainability feature in Watson OpenScale.</p><p>Before we begin, a few points to note:</p><ol><li>For every transaction that needs to be explained, Watson OpenScale creates 5000 perturbations around that transaction to explain it. In our case, this will mean OpenScale will create 5000 variations of a single customer input, see how Watson Assistant classifies intent on each one of them, and then give out an explanation</li><li>It is recommended that you have a Standard plan or above for Watson Assistant as the Lite and Plus Trial plans have monthly limits on the number of messages that one can send. Based on the number of perturbations, Watson OpenScale does, limited messages plan is not advised.</li><li>If you have an assistant dealing with more than 10 intents, then this post is not for you. Watson Assistant currently sends the confidence score for only the top 10 intents. However, Watson OpenScale needs the underlying application to send confidence/probabilities for all the intents/labels/classes that it is classifying. There are ways to tackle more than 10 intents in an assistant, however, for this post, we will focus on the simpler scenario. Please write me at <a href="/service/mailto:prempiyush@in.ibm.com">prempiyush@in.ibm.com</a> if you want to use Watson OpenScale and have an assistant with more than 10 intents.</li></ol><h3>Dataset Used</h3><p>There is a great dataset on Kaggle — <a href="https://www.kaggle.com/PromptCloudHQ/amazon-reviews-unlocked-mobile-phones">Amazon Reviews: Unlocked Mobile Phones</a>. We are using only two columns of this dataset — Reviews, Ratings. The Reviews will act as the customer input in our training data. Before importing the training examples in Watson Assistant, we did the following transformations:</p><ol><li>The <strong>Ratings</strong> range from 1 to 5 in the dataset. We assigned intents to these Ratings — 1 is <strong>Very_Bad, </strong>4 is <strong>Bad, </strong>3 is <strong>OK, </strong>2 is <strong>Good, </strong>1 is <strong>Very_Good.</strong></li><li>Dropped the duplicates from Reviews column</li><li>Selected Reviews that had at least 15 words to weed out simple reviews like “Good phone.”</li><li>Selected Reviews that are less than 1024 characters as Watson Assistant has that character limit on examples.</li><li>Selected 1000 examples for each of the intents to make it a balanced classifier.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vh180qUJLPi9EUJ0lqu8tA.png" /><figcaption>Imported the intent examples in Watson Assistant</figcaption></figure><h3>Custom Wrapper Application</h3><p>Since Watson OpenScale does not yet support Watson Assistant for monitoring purposes, we will have to write a Custom Wrapper Application that can act as a go-between for us.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3tPZjadpxO02xUX5kOmDvw.png" /><figcaption>Custom Wrapper will act as a go-between Watson Assistant and Watson OpenScale</figcaption></figure><p>This custom wrapper application can be written in any language and framework of your choice and can be deployed anywhere accessible. The only constraints that the custom wrapper needs to adhere to is the input and output formats of the API. These are explained nicely in <a href="https://cloud.ibm.com/docs/services/ai-openscale?topic=ai-openscale-frmwrks-custom#co-works">Watson OpenScale documentation</a>.</p><p>For our work, we chose to write this custom wrapper as a NodeJS+Express service and deploy it to IBM Cloud.</p><h3>What goes in Custom Wrapper Application</h3><p>Besides the usual plumbing of NodeJS+Express routes, there are a couple of things that go in our application. Based on the diagram above, these are:</p><ol><li>A method that converts Watson OpenScale request to Watson Assistant request</li><li>A method that converts Watson Assistant response to Watson OpenScale response.</li></ol><p>Before we dive in, as mentioned before, Watson OpenScale scores 5000 perturbations. However, Watson Assistant does not support classifying intents for multiple inputs in a single request. So, we also added a way to convert these 5000 perturbations that Watson OpenScale sends to 5000 individual requests for Watson Assistant. Since issuing these 5000 individual requests sequentially would have taken a lot of time, we used <a href="https://caolan.github.io/async/v3/docs.html#mapLimit">mapLimit</a> from async to parallelise our requests with a limit of 500 requests at a time. We used ibm-watson npm package to talk to our Watson Assistant instance. The details on how to use it can be found in <a href="https://cloud.ibm.com/apidocs/assistant/assistant-v2?code=node">Watson Assistant documentation</a>.</p><h4>Converting Watson OpenScale Input to Watson Assistant Input</h4><p>Intent classification for individual input with retries.</p><p>The individual_score method is quite simple. We take an utterance and send it to Watson Assistant to get an intent back. The alternate_intents option is set to true so Watson Assistant sends us confidence for all the 5 intents. Without this property, Watson Assistant will only send the confidence for the top intent.</p><p>As a result, this Watson OpenScale input…</p><pre>{<br>   &quot;fields&quot;:[<br>      &quot;Reviews&quot;<br>   ],<br>   &quot;values&quot;:[<br>      [<br>         &quot;Very disappointed. Screen barely responds to touch, Battery is taking forever to charge and dies very fast. Useless device.&quot;<br>      ]<br>   ]<br>}</pre><p>… gets converted to this Watson Assistant input …</p><pre>{<br>   &quot;input&quot;:{<br>      &quot;text&quot;:&quot;Very disappointed. Screen barely responds to touch, Battery is taking forever to charge and dies very fast. Useless device.&quot;,<br>      &quot;options&quot;:{<br>         &quot;alternate_intents&quot;:true<br>      }<br>   }<br>}</pre><h4>Converting Watson Assistant Output to Watson OpenScale Output</h4><p>Converting Watson Assistant Output to Watson OpenScale format</p><p>For every Watson Assistant result, the manipulate method returns an array, containing — the original input, the top intent, and an array of probabilities/confidences for each of the 5 possible intents. These confidences are not the same as the ones returned by Watson Assistant. Watson Assistant returns confidence for each intent in the range [0, 1] , however, Watson OpenScale needs their sum to be in the range [0, 1] . So, our manipulate method returns the L1 norm of these confidences by dividing each confidence by the total sum.</p><p>As a result, this Watson Assistant output …</p><pre>{<br>   &quot;output&quot;:{<br>      &quot;generic&quot;:[<br>         {<br>            &quot;response_type&quot;:&quot;text&quot;,<br>            &quot;text&quot;:&quot;I didn&#39;t understand. You can try rephrasing.&quot;<br>         }<br>      ],<br>      &quot;intents&quot;:[<br>         {<br>            &quot;intent&quot;:&quot;Very_Bad&quot;,<br>            &quot;confidence&quot;:0.9443320274353029<br>         },<br>         {<br>            &quot;intent&quot;:&quot;OK&quot;,<br>            &quot;confidence&quot;:0.23559726774692535<br>         },<br>         {<br>            &quot;intent&quot;:&quot;Bad&quot;,<br>            &quot;confidence&quot;:0.2239454984664917<br>         },<br>         {<br>            &quot;intent&quot;:&quot;Good&quot;,<br>            &quot;confidence&quot;:0.21402768790721893<br>         },<br>         {<br>            &quot;intent&quot;:&quot;Very_Good&quot;,<br>            &quot;confidence&quot;:0.20079457936808467<br>         }<br>      ],<br>      &quot;entities&quot;:[</pre><pre>]<br>   }<br>}</pre><p>… finally gets converted to this Watson OpenScale output …</p><pre>{<br>   &quot;fields&quot;:[<br>      &quot;Reviews&quot;,<br>      &quot;top_intent&quot;,<br>      &quot;confidence&quot;<br>   ],<br>   &quot;values&quot;:[<br>      [<br>         &quot;Very disappointed. Screen barely responds to touch, Battery is taking forever to charge and dies very fast. Useless device.&quot;,<br>         &quot;Very_Bad&quot;,<br>         [<br>            0.12313512969153419,<br>            0.11768187924517681,<br>            0.12954178725467652,<br>            0.519235472319682,<br>            0.11040573148893042<br>         ]<br>      ]<br>   ]<br>}</pre><h3>Configuring Custom Wrapper Application with Watson OpenScale</h3><p>The Watson OpenScale <a href="https://cloud.ibm.com/docs/services/ai-openscale?topic=ai-openscale-frmwrks-custom#co-config">documentation</a> describes two ways to configure your custom application. We opted to do it via the individual scoring endpoint (the endpoint that your custom application exposes for scoring) as there is only a single deployment in our application. For larger applications or applications with multiple such assistants, you will have to provide another endpoint to return a list of such deployments.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zyPv0jJ1nM_YvzbUMwGXrA.png" /><figcaption>Provide your basic auth details to connect to Custom Application.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8F17IvZZnBeVb4Hgc6Fwag.png" /><figcaption>Adding the custom deployment using scoring endpoint from the Insights Dashboard</figcaption></figure><p>After adding the custom deployment, we need to score some sample text and add the request-response to the Payload Records of OpenScale. This step is needed so that Watson OpenScale can know more information about the custom application model outputs. This can be done via the REST API or the language of your choice. A sample notebook has been provided in the GitHub repository to do this task.</p><p>Now, we need to add more information about the input-output of the application in Watson OpenScale.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PhS_h4_L0_RNPuxOygiFEw.png" /><figcaption>Adding the model input type and algorithm</figcaption></figure><p>In our case, the data type is Unstructured text and the algorithm type is Multi-class classification as there are 5 intents.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4Pp3OHcbDRjNd_ZO3WNQ8w.png" /><figcaption>Specifying the model output details.</figcaption></figure><p>As you may remember from above, our custom application output, had &quot;Reviews&quot;, &quot;top_intent&quot;, &quot;confidence&quot; as the fields. We mark top_intent as the model prediction and confidence as the model probability output.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tnpwKDuhtja3-yIu1Yn6ag.png" /><figcaption>After the model configuration is successful</figcaption></figure><h3>Generating Explanations!!!</h3><p>Now, for the dessert, let’s generate explanations for a couple of user inputs. The sample notebook has already scored these transactions and given scoring_id for each one of these. We will use them for generating explanations.</p><p>The first input is:</p><blockquote>Great phone available at an affordable price. Amazing performance and battery life make it an excellent choice.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dx_KKs02RkFSaZa9sMoMgA.png" /><figcaption>A Watson OpenScale Explanation for a Very_Good intent</figcaption></figure><p>Watson OpenScale has generated an explanation stating.. that the topmost factors — <em>Amazing (26.15%), affordable (16.81%), excellent (13.44%), Great (11.71%) etc. — </em>are contributing the most towards the Very_Good intent for this input. The other two factors are contributing to the other intents.</p><p>The second input is:</p><blockquote>Very disappointed. Screen barely responds to touch, Battery is taking forever to charge and dies very fast. Useless device.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EFPnd2NkacgS1Y2HAL5r5w.png" /><figcaption>A Watson OpenScale Explanation for a Very_Bad intent</figcaption></figure><p>In this case, Watson OpenScale explanation justifies the Very_Bad intent given to this user input, by listing the top factors as — <em>Useless (21.77%), disappointed (14.65%), touch (8.16%), dies (8.12%) etc.</em> The factor — <em>barely (15.09%) — </em>is contributing towards the other 4 intents.</p><p>That’s all, folks!</p><p>PS: All the code for the custom application, the sample notebooks and training examples for Watson Assistant are in this GitHub repository: <a href="https://github.com/prempiyush/custom-wa-wrapper">prempiyush/custom-wa-wrapper</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9515e90cbdab" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ibm-data-ai/explaining-your-watson-assistant-chatbot-using-watson-openscale-9515e90cbdab">Explaining your Watson Assistant chatbot using Watson OpenScale</a> was originally published in <a href="https://medium.com/ibm-data-ai">IBM Data Science in Practice</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>