<?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 Damian Cummins on Medium]]></title>
        <description><![CDATA[Stories by Damian Cummins on Medium]]></description>
        <link>https://medium.com/@DamianC_?source=rss-2d0f85b1dc6d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*6mvbpQLK9G2nu3xGe-Ndfg.jpeg</url>
            <title>Stories by Damian Cummins on Medium</title>
            <link>https://medium.com/@DamianC_?source=rss-2d0f85b1dc6d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 07:48:21 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@DamianC_/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[Explaining a Chatbot Assistant at runtime with IBM Watson OpenScale — An end-to-end example]]></title>
            <link>https://medium.com/swlh/explaining-a-chatbot-assistant-at-runtime-with-ibm-watson-openscale-an-end-to-end-example-ebbf49e74948?source=rss-2d0f85b1dc6d------2</link>
            <guid isPermaLink="false">https://medium.com/p/ebbf49e74948</guid>
            <category><![CDATA[model-interpretation]]></category>
            <category><![CDATA[chatbots]]></category>
            <category><![CDATA[watson]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[tensorflow]]></category>
            <dc:creator><![CDATA[Damian Cummins]]></dc:creator>
            <pubDate>Sun, 13 Oct 2019 12:51:47 GMT</pubDate>
            <atom:updated>2019-10-13T20:44:17.860Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CGf1N1hKJBlDDEFUto3VaA.png" /></figure><h3>Explaining a Chatbot Assistant at runtime with IBM Watson OpenScale — An end-to-end example</h3><p>The ability to explain <em>why</em> a Chatbot Assistant understood a particular intent from a user can be helpful when you are looking to determine its’ performance in production.</p><p>In this post I’ll walk through an end-to-end example of a Node.js Chatbot Assistant application, complete with React.js UI, Express.js REST APIs, and TensorFlow.js NLP classification model. Then, I’ll demonstrate how to integrate the app with the IBM Watson OpenScale service in order to make use of the powerful Explainability feature, to better understand the predictions of the underlying intent classifier.</p><p>Before we dive in, let’s take a look at how the different parts fit together.</p><h4>The System</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x5tSdbAg1HXdx32Sb5Nkqw.png" /></figure><p>The Node.js app uses Express to serve 3 endpoints that are consumed by the Front End, and by the Watson OpenScale service:</p><ul><li>GET https://&lt;host&gt;/ - The base path exposes the Server-Side Rendered React.js UI.</li><li>GET <a href="https://damian-assistant-app/">https://&lt;host&gt;/</a>v1/deployments - This API is used to discover the deployed assistant’s metadata; things like the message prediction endpoint, what kind of problem type is the underlying model solving (i.e. structured / unstructured, classifier / regression etc.).</li><li>POST <a href="https://damian-assistant-app/">https://&lt;host&gt;/</a>v1/deployments/assistant/message - This API is used to send new messages to the assistant. The response body will include the reply, the predicted intent, and the raw probabilities from the classifier.</li></ul><p>The last two APIs follow the <a href="https://aiopenscale-custom-deployement-spec.mybluemix.net/">Watson OpenScale Custom Serve Engine Specification</a> that must to be adhered to in order for Watson OpenScale to both discover the assistant deployment, and also to be able to send messages to be classified.</p><h4>The Model</h4><p>For the purpose of this example, the ML model being used is a TensorFlow neural network multi-class classifier, trained to classify intents from encoded text using the Bag-of-Words technique. We will see later from the explanations why this approach could be improved.</p><p>For this example, the model has been trained to classify questions about my resume with 9 possible classes:</p><p>[‘education’, ‘experience’, ‘goodbye’, ‘greeting’, ‘hobbies’, ‘options’, ‘projects’, ‘skills’, ‘thanks’]</p><p>The following JSON snippet shows how both message patterns (used for model training and encoding new messages at runtime), and message responses (used by the app at runtime) can be labelled by intent in an easily consumable format:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4fe0196367bff2204d1e77ecb629e7ac/href">https://medium.com/media/4fe0196367bff2204d1e77ecb629e7ac/href</a></iframe><p>The model creation is outside the scope of this post but feel free to take a look at the notebook <a href="https://github.com/DamianCummins/damian-assistant/tree/master/notebook">here</a>.</p><p>The trained model has been saved and <a href="https://www.tensorflow.org/js/tutorials/conversion/import_keras">converted</a> to the appropriate format to be loaded by the TensorFlow.js library.</p><h3>The Application</h3><p>In this section, we will take a look at some of the key parts of the code that make up a single Node.js web application which serves both the React.js chatbot UI, and the intent classification model. The complete code for this example can be found <a href="https://github.com/DamianCummins/damian-assistant">here</a>.</p><h4>Routes</h4><p>First, let’s take a look at the Express routes.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5718244622776bb143e558726105fd8a/href">https://medium.com/media/5718244622776bb143e558726105fd8a/href</a></iframe><p>Here we can see the GET / route that is responsible for sending the rendered &lt;App/&gt; component as part of a text/html response. Take a look <a href="https://www.freecodecamp.org/news/demystifying-reacts-server-side-render-de335d408fe4/">here</a> to learn more about Server Side Rendering with React.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cb31cc79cd813c7aba0df05fa2788c9c/href">https://medium.com/media/cb31cc79cd813c7aba0df05fa2788c9c/href</a></iframe><p>This route handles requests to GET /v1/deployments, responding with the metadata that Watson OpenScale requires to send messages to the underlying classifier.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7d4fb59583036acdccc72ad17f3cd175/href">https://medium.com/media/7d4fb59583036acdccc72ad17f3cd175/href</a></iframe><p>Then, the route that handles requests to POST /v1/deployments/assistant/message will send the incoming payload to the assistantUtil.js module for classification, then send the message, the prediction, the probabilities of each intent, and a unique messageId to Watson OpenScale’s payload logging database.</p><p>We only want to log payloads for requests coming from the Front End of the application, as these are the predictions we are interested in explaining, so the UI will pass a logPayload=true query parameter flag. When explaining a classification, Watson OpenScale will invoke this endpoint with 5000 perturbed messages to be classified. As Watson OpenScale will not be setting the logPayload flag, these requests will not be sent to the payload logging database.</p><p>This application also prints the payload logging request body to the console log so that we can use the scoring_id value to generate explanations later.</p><h4>Making Predictions</h4><p>The key function in the assistantUtil module is the predict function:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d820f17f7a3e5f2ec59b270972b9331b/href">https://medium.com/media/d820f17f7a3e5f2ec59b270972b9331b/href</a></iframe><p>The function creates a Bag-of-Words tensor which is then passed to the model which will return an array of probabilities, one for each possible classification (intent). The reply for the intent with the highest probability is retrieved, and the function returns an array that contains the reply, the predicted intent, and the set of probabilities.</p><h4>Front End</h4><p>This example chatbot UI makes use of the <a href="https://www.npmjs.com/package/@progress/kendo-react-conversational-ui">Progress Kendo React Conversational UI </a>component as a quick way of getting a front end up and running.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/556bbfc82b6ce87efdc67bb595fb7559/href">https://medium.com/media/556bbfc82b6ce87efdc67bb595fb7559/href</a></iframe><p>The Assistant.js component maintains the messages sent from both the user and the bot in its’ state. When a user sends a message, it is added to the messages list, then the getMessage function invokes the intent classifier through thePOST /v1/deployments/assistant/message?logPayload=true API. The reply is then added to the messages list so that it is displayed in the browser.</p><h4>Service Credentials Config</h4><p>The application requires a number of configuration values and credentials to interact with Watson OpenScale.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3c1f5fd9d28168a86011cab2003a2f0e/href">https://medium.com/media/3c1f5fd9d28168a86011cab2003a2f0e/href</a></iframe><p>The openscale.data_mart_id, openscale.subscription_id, openscale.binding_id values will be available once Watson OpenScale has discovered the deployment. The host should match the deployed application’s host name.</p><h3>Integration</h3><p>In this section we will look at configuring the Watson OpenScale service to discover the application.</p><p>The application can be deployed as a Cloud Foundry application to IBM Cloud with the command ibmcloud cf push. A new instance of the Watson OpenScale service can be created from the <a href="https://cloud.ibm.com/catalog/services/watson-openscale">IBM Cloud Catalog</a>.</p><h4>Creating a Custom Machine Learning Provider</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*uLIaUknrhTA_k3Uzw42rtw.gif" /></figure><p>From the Watson OpenScale System Setup page, create a new Machine Learning Provider, selecting the Custom Environment tile and providing the base url of the deployed app. If your API requires basic auth, you can provide the username and password in this form. If not, simply add dummy values and click Save. The service binding_id value can be found in the Provider Summary.</p><h4>Adding a new Model Monitor</h4><p>Navigate to the Dashboard, select the Model Monitors tab, and add a new monitor to the dashboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*fqx3X5lp_ttkqriGo70tgg.gif" /></figure><p>Make sure to select the new Custom Provider and then select the deployment for the assistant application that has been discovered. Clicking <strong>Configure Monitors</strong> at the end of the wizard will display the rest of the details (subscription_id, deployment_id) required for the application to successfully begin logging payloads.</p><p>At this point, update these values in the config.json file and redeploy the application.</p><h4>Configuring Payload Logging and Model Details</h4><p>To complete the Payload Logging configuration, open the deployed application and send a message to the chatbot. The application will then log the payload of the message and the predicted intent.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1NoEetfzdapGw2Z0mcoOow.png" /></figure><p>The <strong>Model Details</strong> tab should then be enabled, where we can tell Watson OpenScale which fields returned by the application should be used as the prediction column, and which should be used as the probabilities column. Once these have been set, the<strong> Explainability</strong> Monitor will be enabled and the configuration is complete.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*pjONUQo04xpXRlAnVpDMDw.gif" /></figure><h3>Explainability</h3><p>Now that some payloads have been logged, lets retrieve the messageId for a particular message from the logs and generate an explanation.</p><pre>$ ibmcloud cf logs damian-assistant-app --recent | grep &quot;scoring_id&quot;<br>   2019-10-10T14:06:02.41+0100 [APP/PROC/WEB/0] OUT   scoring_id: &#39;88ef29f6-28ef-42a0-b587-9383920abb0f&#39;,<br>   2019-10-10T14:06:19.35+0100 [APP/PROC/WEB/0] OUT   scoring_id: &#39;ac2d6e98-bd46-491f-8353-8019326bd37e&#39;,<br>   2019-10-10T14:06:26.60+0100 [APP/PROC/WEB/0] OUT   scoring_id: &#39;963b93d9-2b45-49b6-b498-dbcab02ef235&#39;,<br>   2019-10-10T14:06:32.67+0100 [APP/PROC/WEB/0] OUT   scoring_id: &#39;6939cb56-f916-4fdd-9da3-8e461093c11a&#39;,</pre><p>Copying and pasting one of the Scoring IDs into the Explanation search input kicks off a new Explanation job. Note the added suffix of-1. This is necessary because Watson OpenScale supports logging multiple payloads in a single payload logging request and the suffixes are added to the Scoring ID to uniquely identify each payload.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*TUlhjyG--IsgJBGgbYuADA.gif" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9K4bM_2w2BQulwAUGRof9w.png" /></figure><p>The Explanation shows the confidence the model has that the message is conveying a particular intent (in this case education), and also shows the feature importance. This is in fact a <em>local interpretation </em>of the model, <a href="https://www.oreilly.com/learning/introduction-to-local-interpretable-model-agnostic-explanations-lime">reflecting the behaviour of the classifier “around” the instance being predicted</a>.</p><p>Interestingly, the model appears to be placing more importance on words like a, you, and do, than on words like degree, which may indicate that the model is overfitting on meaningless words from the training data and is therefore less likely to perform well in production. This may be down to the use of the Bag-of-Words approach which could be improved by using a more sophisticated word embedding technique.</p><h3>Conclusion</h3><p>In this post we have covered how a Chatbot Assistant Node.js application can be built around an unstructured text classification model, how to configure Watson OpenScale to discover and monitor the application, and how to generate explanations of individual messages.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ebbf49e74948" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/explaining-a-chatbot-assistant-at-runtime-with-ibm-watson-openscale-an-end-to-end-example-ebbf49e74948">Explaining a Chatbot Assistant at runtime with IBM Watson OpenScale — An end-to-end example</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating a Football Heat Map React Component with Recharts]]></title>
            <link>https://medium.com/swlh/creating-a-football-heat-map-react-component-with-recharts-ff310162cee0?source=rss-2d0f85b1dc6d------2</link>
            <guid isPermaLink="false">https://medium.com/p/ff310162cee0</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[recharts]]></category>
            <category><![CDATA[heatmap]]></category>
            <category><![CDATA[football]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Damian Cummins]]></dc:creator>
            <pubDate>Wed, 18 Sep 2019 14:50:14 GMT</pubDate>
            <atom:updated>2019-11-06T20:22:08.224Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ESL_D8XUqI4aUzxwA2JilA.png" /><figcaption><a href="https://damiancummins.github.io/FAWSL-dashboard/">https://damiancummins.github.io/FAWSL-dashboard/</a></figcaption></figure><p>Heat maps are a great visualisation to start with when exploring sports event data that includes coordinates, allowing viewers to immediately focus on areas of the field that matter most.</p><p>In this post I’ll walk through how we can build a React.js component that can display a football player’s pitch coverage across particular zones for a given match using the charting library <a href="https://recharts.org/">Recharts</a>. I’ve decided to work with the Recharts library for this example because they do not actually have a heat map component, but this post will demonstrate that it is a very intuitive and extensible library.</p><h3>The event data</h3><p>The <a href="https://raw.githubusercontent.com/statsbomb/open-data/master/data/events/19714.json">event data</a> used in this example is taken from a FA Women’s Super League match (Chelsea FCW (0) vs Manchester City WFC (0) ) from the 2018/19 season. The sports analytics organisation <a href="https://statsbomb.com/">StatsBomb</a>, have made a number of their <a href="https://github.com/statsbomb/open-data">datasets freely available for learning purposes</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nnB-VA9BcB3_M6NZ.png" /></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0e5bfe9cebe11906dd192d0f4a1ef3fe/href">https://medium.com/media/0e5bfe9cebe11906dd192d0f4a1ef3fe/href</a></iframe><p>The JSON data is an array of different events which include many attributes, but the ones we are interested in are:</p><p>&quot;player&quot;: {&quot;id&quot;: 10395, “name&quot;: “Maren Naevdal Mjelde&quot;}</p><p>&quot;location&quot;: [53.0, 10.0]</p><p>We will need to filter for events that match the player name and also contain location data in order to plot the heat map.</p><h3>Shaping the data</h3><p>Before we look at what the heat map component will render, first we need to transform the events data so that it can be visualised by the Recharts Scatter Chart component.</p><p>Here we define a function that will retrieve a list of all locations in the match dataset for a given player:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8792fc77acb7dfeb1f9f3b6a543f783b/href">https://medium.com/media/8792fc77acb7dfeb1f9f3b6a543f783b/href</a></iframe><p>This returns an array of objects containing the location coordinates:</p><pre>[<br>   { x: 10, y: 10},<br>   ...<br>]</pre><p>Then we need a way of dividing the pitch into a grid and counting the number of events that are present in each cell. This will be the data used to plot our heat map.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c4dc7454e550aaaabd56c91c304c612b/href">https://medium.com/media/c4dc7454e550aaaabd56c91c304c612b/href</a></iframe><p>The getHeatmapSectors function accepts our array of coordinates, along with the number of columns and rows that we want to divide the pitch into for the heat map.</p><p>It then iterates over each sector in the pitch, counting the coordinate objects that fall within that sector, resulting in an array that looks like this:</p><pre>[<br>   {<br>      count: 10,<br>      x1: 0,<br>      x2: 30,<br>      y1: 0,<br>      y2: 20<br>   },<br>   ...<br>]</pre><p>In the above example, the bottom left sector of the pitch contains 10 events.</p><h3>Building the chart</h3><p>Install the Recharts library with npm install recharts to use the latest stable version.</p><p>We can then import the following components required to build a Scatter chart:</p><pre>import {<br>   ReferenceDot,<br>   ReferenceLine,<br>   ReferenceArea,<br>   ScatterChart,<br>   Scatter,<br>   CartesianGrid,<br>   Tooltip,<br>   XAxis,<br>   YAxis<br>} from &quot;recharts&quot;;</pre><p>The bulk of JSX to be rendered by this component is going to be the Reference shapes that are drawn onto the Scatter chart to depict the football pitch layout:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/575e39244176e37577c4a1c20040b3ab/href">https://medium.com/media/575e39244176e37577c4a1c20040b3ab/href</a></iframe><p>The above function accepts an array of locations, an array of sectors, and a scale value. The components are drawn on top of one another based on their order within the &lt;ScatterChart&gt; component, which is why the heat sectors are rendered on top of some shapes, but behind some others, as we do not want the opacity of the sectors to obscure any important features of the pitch.</p><p>These are the main parts of the heat map component. Once they have been tied together in a React component, it can be rendered like so:</p><pre>&lt;Heatmap</pre><pre>   data={matchData}</pre><pre>   playerName=&quot;Ramona Bachmann&quot;</pre><pre>/&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*dsNzm4NMDSKVnGF8kzo5RA.png" /><figcaption>Ramona Bachmann — Chelsea FCW (0) vs Manchester City WFC (0) Date: 2018–09–09</figcaption></figure><h3>Summary</h3><p>In this post we have looked at an example of a football event data point, manipulating events into locations for a particular player, as well as aggregating events for different sectors of the pitch.</p><p>We then plotted both the locations onto a Scatter Chart and overlaid the outline of a football pitch onto the chart as well as visualising the sectors with the most coverage using the Recharts library.</p><p>The complete Heatmap component code can be found <a href="https://github.com/DamianCummins/FAWSL-dashboard/tree/dev/src/components/common/Heatmap">here</a> and can be seen in action on <a href="https://github.com/DamianCummins/FAWSL-dashboard">this FAWSL Dashboard</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ff310162cee0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/creating-a-football-heat-map-react-component-with-recharts-ff310162cee0">Creating a Football Heat Map React Component with Recharts</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Football Data Visualisation: Women’s World Cup 2019]]></title>
            <link>https://medium.com/@DamianC_/football-data-visualisation-womens-world-cup-2019-f025c1009805?source=rss-2d0f85b1dc6d------2</link>
            <guid isPermaLink="false">https://medium.com/p/f025c1009805</guid>
            <category><![CDATA[matplotlib]]></category>
            <category><![CDATA[womens-world-cup]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[football]]></category>
            <dc:creator><![CDATA[Damian Cummins]]></dc:creator>
            <pubDate>Mon, 15 Jul 2019 12:01:46 GMT</pubDate>
            <atom:updated>2019-11-06T20:23:31.419Z</atom:updated>
            <content:encoded><![CDATA[<p>The football analytics organisation <a href="https://statsbomb.com/">StatsBomb</a> have released a comprehensive <a href="https://github.com/statsbomb/open-data">dataset</a> of the in-game events for each match of the Women’s World Cup, and in this post I’m going to look at how to create one particular visualisation often used in sports analytics to compare several performance statistics at once — the Radar chart.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iR1L7pV38dktAH6bnyV7yw.png" /></figure><p>The above example shows 6 different statistics relating to player performance for a given game, with the values of 3 players plotted for comparison. The events used in this post are from the following game:</p><p><strong>FIFA Women’s World Cup — Quarter-Final, Norway Women [0] vs England Women [3], Thursday 27th June, Stade Oceane.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fIjnUoscUWWWR-nB.png" /></figure><h3>Performance Statistics</h3><p>To start with, we’ll read in the data as a Pandas DataFrame, then define a function to calculate these 6 performance statistics for a given player name.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c0acc31b05ba4227cb8b604f388e0920/href">https://medium.com/media/c0acc31b05ba4227cb8b604f388e0920/href</a></iframe><h3>Creating the Complex Radar Chart</h3><p>Now that we have calculated our values, we want to be able to visualise them on a Polar plot, with appropriate ranges for each value we are providing. For example, we need to be able to plot a pass_percentage value of 0.83 on one spoke, with a shots value of 4 on another spoke. Our values will need to be scaled and labelled appropriately for our visualisation to be easily understood.</p><p>To do this, we will create a new class called ComplexRadar.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c73b87944c436f4f47f5a8b1904a210c/href">https://medium.com/media/c73b87944c436f4f47f5a8b1904a210c/href</a></iframe><p>An instance of the ComplexRadar class will be initialised with the matplotlib figure, a list of variables (which we will use to label the spokes), and a list of tuples representing the lower and upper boundaries for each value.</p><p>On instantiation, the class will:</p><ul><li>create a PolarAxes for each variable with the angle and label for each spoke</li><li>set the label font size, weight and position</li><li>calculate the intermediate values for each range and set the radius grid labels</li><li>store the radian values of each angle</li></ul><p>The ComplexRadar class also has three functions plot, fill, and scale_data.</p><p>The scale_data function will scale all the values based on the range of the first value. plot and fill will call this function to draw the scaled values and fill the plotted area respectively.</p><h3>Plotting the Values</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f50db1a55137a132c3e84821f20c2f37/href">https://medium.com/media/f50db1a55137a132c3e84821f20c2f37/href</a></iframe><p>Finally, we want to choose some players to compare. In this case, we have Right-winger <strong>Nikita Parris</strong>, Right-back <strong>Lucy Bronze</strong>, and playmaker <strong>Fran Kirby</strong>.</p><p>We also define the ranges for each value. Notice that the range for pass_percentage is (0.5, 1.0). It is likely that at professional level passing percentage is going to be at least better than 50%, in which case we will limit the axis to ≥ 50% to make our visualisation clearer.</p><p>We create a figure with an appropriate size and instantiate the radar, then for each of our players, we calculate the statistics and plot them on our radar.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iR1L7pV38dktAH6bnyV7yw.png" /></figure><p>In this post, we have covered reading in open data from StatsBomb in JSON format, calculating various performance statistics for a given player, then plotting the values on a Radar chart with appropriate ranges.</p><p>The complete code for this post can be found in Jupyter Notebook format <a href="https://github.com/DamianCummins/statsbomb-football-event-visualisations/blob/master/Statsbomb%20Womens%20World%20Cup%202019%20visualisation.ipynb">here</a>.</p><h3>Acknowledgements</h3><ul><li>StatsBomb Open Data: <a href="https://github.com/statsbomb/open-data">https://github.com/statsbomb/open-data</a></li><li>Complex Radar Charts: <a href="https://datascience.stackexchange.com/questions/6084/how-do-i-create-a-complex-radar-chart">https://datascience.stackexchange.com/questions/6084/how-do-i-create-a-complex-radar-chart</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f025c1009805" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Serverless Data Flow Sequencing with Watson Data API and IBM Cloud Functions]]></title>
            <link>https://medium.com/ibm-watson/serverless-data-flow-sequencing-with-watson-data-api-and-ibm-cloud-functions-a54d17d53710?source=rss-2d0f85b1dc6d------2</link>
            <guid isPermaLink="false">https://medium.com/p/a54d17d53710</guid>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[watson-studio]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[cloud]]></category>
            <dc:creator><![CDATA[Damian Cummins]]></dc:creator>
            <pubDate>Mon, 09 Apr 2018 17:19:50 GMT</pubDate>
            <atom:updated>2018-05-01T19:32:10.791Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D6iE-Mpuvf51PGxt1mMREg.jpeg" /></figure><p><em>The complete code for this tutorial and other Watson Data API Data Flow samples can be found </em><a href="https://github.com/WatsonDataFlows/samples/tree/master/javascript/data-flow-run-sequence-function"><em>here</em></a><em>.</em></p><p>In a <a href="https://medium.com/ibm-watson/using-shell-scripts-to-control-data-flows-created-in-watson-applications-f7de2e265f1f">previous tutorial</a>, you saw how data flows could be run one after another by polling using a simple shell script. This tutorial demonstrates how to deploy the same functionality as a serverless action. <strong>IBM Cloud Functions </strong>enable you to deploy a simple, repeatable function and run it periodically by using the alarm package.</p><p>Again, a data flow can read data from a large variety of sources, process that data in a runtime engine using pre-defined operations or custom code, and then write it to one or more targets.</p><p>For example, if you have two data flows (data_flow_1 and data_flow_2) and you always want to run data_flow_2 after data_flow_1 run completes, you can write an IBM Cloud Function to check the status of the latest data_flow_1 run. If the status is completed, then the function should start a run of data_flow_2.</p><h3>Creating a Node.js function</h3><p>First, <a href="https://github.com/WatsonDataFlows/samples/tree/master/javascript/data-flow-run-sequence-function">clone this repository</a> and run npm install to install the dependencies. Once this completes, be sure to include your project ID and the IDs of the two data flows you want to monitor and run in index.js, for example:</p><pre>// Parameters<br>const projectId = &#39;c2254fed-404d-4905-9b8c-5102f195cc0d&#39;;<br>const dataFlowId1 = &#39;37bd30f0-dd3f-4052-988d-69c8fb2bf40a&#39;; // Data Flow Ref to check status of latest run<br>const dataFlowId2 = &#39;d31116c7-854f-404c-9e7a-de274a8bb2d6&#39;; // Data Flow Ref to trigger run for</pre><blockquote>The project ID can be retrieved from the browser URI between /projects/ and /assets in Watson Studio or Watson Knowledge Catalog when viewing the project:</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bcu5ffSZGsD6M7KvWkOsmA.png" /></figure><blockquote>Similarly, the data flow ID can be retrieved from the browser URI between /refinery/ and /details in Watson Studio or Watson Knowledge Catalog when viewing the data flow:</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cWIk65XK0kb3X7oZN6uvKA.png" /></figure><p>The main function is the one that will be called each time the action is invoked. The function creates a new authentication token, retrieves the latest run for dataFlowId1, and then either creates a new dataFlowId2 run or simply returns, depending on the state and completed_date.</p><p>The function is configured to run every 20 seconds so we will <em>only</em> start a new run for dataFlowId2 if the latest run for dataFlowId1 completed in the last 20 seconds. This is to avoid starting dataFlowId2 every time we retrieve the latest finished run for dataFlowId1.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/84d9f9cdf58f20cbacfd5f33e9973351/href">https://medium.com/media/84d9f9cdf58f20cbacfd5f33e9973351/href</a></iframe><p>To deploy this node.js function with IBM Cloud using the <strong>IBM Cloud Functions CLI</strong>, package it as a .zip archive, including the node_modules, index.js and package.json files.</p><h3>Getting started with IBM Cloud Functions CLI</h3><p>First, follow the instructions <a href="https://console.bluemix.net/openwhisk/learn/cli">here</a> to install the IBM Cloud Functions CLI.</p><p>In a terminal window, upload the .zip file containing the node.js action as a Cloud Function by using the following command: bx wsk action create packageAction --kind nodejs:default action.zip.</p><p>You can test the action you have just created manually by using the following command: bx wsk action invoke --blocking --result packageAction.</p><h3>Trigger: every-20-seconds</h3><p>You can include a trigger that uses the built-in alarm package feed to fire events every 20 seconds. This is specified through cron syntax in the cron parameter.</p><p><em>[Optional] The maxTriggers parameter ensures that it only fires for five minutes (15 times), rather than indefinitely.</em></p><p>Create the trigger with the following command: bx wsk trigger create every-20-seconds --feed /whisk.system/alarms/alarm --param cron &quot;*/20 * * * * *&quot; --param maxTriggers 15.</p><h3>Rule: invoke-periodically</h3><p>This rule shows how the every-20-seconds trigger can be declaratively mapped to the packageAction.</p><p>Create the rule with the following command: bx wsk rule create invoke-periodically every-20-seconds packageAction</p><p>Next, open a terminal window to start polling the activation log. The console.log statements in the action will be logged here. You can stream them with the following command: bx wsk activation poll</p><h3>Monitoring logs</h3><p>Before running your data flow, you should see entries similar to the following ones:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d1cfb8f2a0a00d578252644725af8888/href">https://medium.com/media/d1cfb8f2a0a00d578252644725af8888/href</a></iframe><p>The first entry shows the IAM Authorization token being obtained, retrieving the data flow run, and then returning because the entity.summary.completed_date is earlier than the lookback date.</p><p>At this point, run dataFlowId1 from either Watson Studio or Watson Knowledge Catalog. You can do this using the Refine action for the data flow in the project assets page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YqpvZisokv1tJxlfBUH-lg.png" /></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/440489571f5be84a0abe60fc811dd20c/href">https://medium.com/media/440489571f5be84a0abe60fc811dd20c/href</a></iframe><p>This entry is very similar but in this case, the entity.state is running so the function returns again.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/870886665ca829e261c0a133dd4e7c28/href">https://medium.com/media/870886665ca829e261c0a133dd4e7c28/href</a></iframe><p>In this entry, you can see that the run for the data flow with an ID of 37bd30f0-dd3f-4052-988d-69c8fb2bf40a finished so the data flow with an ID of d31116c7-854f-404c-9e7a-de274a8bb2d6 starts.</p><h4>To Summarize…</h4><p>In summary, we have created a serverless action that polls the status of a data flow’s most recent run and, on completion, runs another data flow. This demonstrates the ability to chain or sequence the running of data flows using Watson Data APIs in the IBM Cloud.</p><p><strong>Damian Cummins</strong> is a Cloud Application Developer with the Data Refinery and IBM Watson teams at IBM.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a54d17d53710" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ibm-watson/serverless-data-flow-sequencing-with-watson-data-api-and-ibm-cloud-functions-a54d17d53710">Serverless Data Flow Sequencing with Watson Data API and IBM Cloud Functions</a> was originally published in <a href="https://medium.com/ibm-watson">IBM watsonx Assistant</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Working with data flows using  Watson Data APIs]]></title>
            <link>https://medium.com/ibm-watson/working-with-data-flows-using-watson-data-apis-7a6c8bda6a22?source=rss-2d0f85b1dc6d------2</link>
            <guid isPermaLink="false">https://medium.com/p/7a6c8bda6a22</guid>
            <category><![CDATA[watson-studio]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[ibm-watson]]></category>
            <dc:creator><![CDATA[Damian Cummins]]></dc:creator>
            <pubDate>Tue, 20 Mar 2018 14:05:58 GMT</pubDate>
            <atom:updated>2018-04-18T19:30:23.636Z</atom:updated>
            <content:encoded><![CDATA[<h3>Working with Data Flows Using Watson Data APIs</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zXVfaQt2uHOjx84jGjqlrg.jpeg" /><figcaption><a href="http://ibm.biz/wdp-api">Watson Data API</a></figcaption></figure><p>IBM Watson offers a collection of REST APIs for creating, running, managing, and troubleshooting data flows to allow your applications to easily integrate with <strong>Data Refinery</strong>.</p><p>A flow can read data from a large variety of sources, process that data in a runtime engine using pre-defined operations or custom code, and then write it to one or more targets. The runtime engine can handle large amounts of data so it’s ideally suited for reading, processing, and writing data at volume.</p><p>The APIs are supported by a growing set of resources, including documentation and tutorials.</p><h4>API Documentation</h4><p>The data flows API specification can be found in the <a href="http://ibm.biz/wdp-api">Watson Data API documentation</a> under Documentation &gt; Data flows.</p><h4>Tutorials and Notebooks</h4><p>The <a href="https://dataplatform.ibm.com/community?context=analytics">Watson Studio Community</a> is a hub of useful blogs, notebooks, tutorials and data sets to get you started.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1017/1*R9ZtkAClQaxUc1cl3NTTWA.jpeg" /></figure><p>The <a href="https://dataplatform.ibm.com/exchange/public/entry/view/76deece1cf6f6f4bc3789678be94616d">Create and run a data flow using Watson Data APIs</a> notebook introduces you to the data flow model and shows you how to define a flow with a data source, refining operations, and a target data set. It also covers data flow run creation, status monitoring, and log retrieval for troubleshooting.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1016/1*gbqrkkDcA3z1B9ORnlo6nQ.jpeg" /></figure><p>The <a href="https://dataplatform.ibm.com/exchange/public/entry/view/bfbfd911c99a4fa2f6e72d50417ddce6">Monitor data flow usage using Watson Data APIs </a>notebook demonstrates how run metrics can be visualized over time and shows how lists of runs can be filtered using query parameters.</p><p>You can find more information about Data Refinery in the announcement blog post: <a href="https://medium.com/ibm-data-science-experience/self-service-data-preparation-with-ibm-data-refinery-5166d581014e">Self-service data preparation with Data Refinery</a></p><p><strong>Try out Data Refinery today from either Watson Studio or Watson Knowledge Catalog.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7a6c8bda6a22" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ibm-watson/working-with-data-flows-using-watson-data-apis-7a6c8bda6a22">Working with data flows using  Watson Data APIs</a> was originally published in <a href="https://medium.com/ibm-watson">IBM watsonx Assistant</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a chat bot with speech recognition: Naming, Logging, Monitoring & Repetition]]></title>
            <link>https://medium.com/@DamianC_/building-a-chat-bot-with-speech-recognition-naming-logging-monitoring-repetition-ef44a9af173f?source=rss-2d0f85b1dc6d------2</link>
            <guid isPermaLink="false">https://medium.com/p/ef44a9af173f</guid>
            <category><![CDATA[ibm-watson]]></category>
            <category><![CDATA[chatbots]]></category>
            <category><![CDATA[speech-recognition]]></category>
            <dc:creator><![CDATA[Damian Cummins]]></dc:creator>
            <pubDate>Tue, 04 Apr 2017 09:17:10 GMT</pubDate>
            <atom:updated>2017-04-04T09:17:10.307Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nAQBoQan32pC_7rff_bXng.jpeg" /><figcaption><a href="http://www.instructables.com/id/Build-a-Talking-Robot-With-Watson-and-Raspberry-Pi/">Build your own TJ Bot</a></figcaption></figure><blockquote><strong>Me:</strong> Hi Buddy, it’s me<br>… *moves slightly closer* …<br><strong>Me:</strong> <strong>Hi Buddy. It’s. Me.</strong><br><strong>Buddy:</strong> Hi Damian, what can I do for you?</blockquote><p>Meet Buddy. Buddy is my incarnation of <a href="http://research.ibm.com/tjbot/">IBM’s TJ Bot</a>. He’s an example of “embodied cognition” and is a cute physical interface to IBM’s Watson.</p><p><em>Disclaimer: This post is </em><strong><em>not</em></strong><em> a walk through of how to build TJ Bot (there are already some excellent </em><a href="http://www.instructables.com/id/Build-a-Talking-Robot-With-Watson-and-Raspberry-Pi/"><em>Instructable</em></a><em> steps for that which are clear and concise!). The aim of this post is to highlight some interesting problems I encountered along the way and the overall experience of building my first talking (and listening) robot!</em></p><p><em>The source code for this project is available </em><a href="https://github.com/DamianCummins/tell_the_time/"><em>here</em></a><em>.</em></p><p>So, firstly, having followed the <a href="http://www.instructables.com/id/Build-a-Talking-Robot-With-Watson-and-Raspberry-Pi/">Instructable</a> steps to get TJ Bot up and running, I wanted to give it a name.</p><p><strong>Problem 1: Appropriate Naming</strong></p><p>TJ Bot answers to “Watson” by default. However, if you’ve bought a £2 usb microphone and listened back to recorded audio on a Raspberry Pi (<a href="http://www.g7smy.co.uk/2013/08/recording-sound-on-the-raspberry-pi/">see useful link here</a>) then you might forgive the Speech-to-Text service for translating it as <em>“Whats on”</em>, <em>“What son”</em>, <em>“Washing”</em> etc. At this point it’s definitely worth playing around with the gain settings &amp; even placing TJ Bot away from anything that might hum or buzz (TV speakers for example).</p><p>I probably spent an hour or so experimenting with different attention words (names) including “TJ Bot” (sometimes translated as “PJ Bot”, “TeeJay Bot”) and “Buddy” (“Body”, “but they”, “but he”). Eventually I stuck with “Buddy” as this combination of plosives and vowels (along with unfortunate constants such as the tone/accent of my voice etc.) seemed to have the most success.</p><p>In an attempt to increase the recognition hit rate even more, I added a list of homophones to the TJBot config:</p><pre>// set up TJBot&#39;s configuration<br>var tjConfig = {<br>   verboseLogging: true,<br>   robot: {<br>      name: &#39;Buddy&#39;,<br>      homophones: [&#39;Buddy&#39;,&#39;Body&#39;,&#39;but they&#39;,&#39;but he&#39;, &#39;but the&#39;],<br>      gender: &#39;male&#39;<br>   }<br>};</pre><p>Then added this list to the attention word check:</p><pre>// listen for utterances with our<br>// attentionWord and send the <br>// result to the Conversation <br>// service<br>tj.listen(function(msg){<br>   // check to see if they are<br>   // talking to TJBot<br>   if(tj.configuration.robot.homophones.some(<br>      function(v) {<br>         return msg.toLowerCase().indexOf(v.toLowerCase()) &gt;= 0; <br>      })) {<br>      //do something<br>   }<br>});</pre><p>More often than not, Buddy now responds to his own name!</p><p><strong>Problem 2: Buddy? Did you get that? Buddy?!</strong></p><p>Problem 2 was very quickly discovered during Problem 1. It’s all very well including logging such as console.log(&quot;Understood&quot;); in the code, but why not make use of the fact your program can speak?</p><p>Getting Buddy to notify me that he had recognised his own name proved to be a much better user experience than squinting at the logs I was printing to the console.</p><p>Playing a simple tone to let me know I didn’t have to repeat myself was all it needed:</p><pre>var understood = function() {<br>   var create_audio = exec(&#39;aplay &#39;+audioDir+&#39;understood.wav&#39;,<br>      function (error, stdout, stderr) {<br>         if (error !== null) {<br>            console.log(&#39;exec error: &#39; + error);<br>         }<br>      });<br>};</pre><p>This also made me think further about ways of representing state change in a conversational manner. If possible, I wanted Buddy to audibly inform me of as many state changes as he could outside of the Watson Conversation flow:</p><ul><li>Start listening: Speak</li><li>Heard attention word: Emit Tone</li><li>Didn’t hear attention word: Emit Tone</li><li>Exit due to internal error: Speak</li><li>Stop listening due to user request: Speak</li></ul><p><strong>Problem 3: User Interface</strong></p><p>So by this point Buddy could say “Hello” and I’d added a Speaker entity to Watson Conversation so that he would respond with various comments if particular people introduced themselves.</p><p>However, I really wanted to avoid starting Buddy up manually, so I added the node startup command to /etc/rc.local so that it would run when the Pi boots up.</p><p>I also wanted others to be able to easily see if Buddy was listening, or to stop / restart Buddy, without having to touch any plug switches / know what connecting via ssh means.</p><p>I wrote a simple node express app which exposed the following endpoints:<br>GET /tjbot/status<br> POST /tjbot/pause <br>POST /tjbot/resume <br>as well as serving up a simple HTML/Javascript dashboard to call these endpoints. This application effectively served as a wrapper for the bot module.</p><p>Using another device on the same network as the Pi, one could now monitor &amp; control Buddy from http://raspberrypi:3000/tjbot</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/356/1*7HEW2MdQ1L5d_iA7wSY-Kg.gif" /></figure><p>With these problems addressed, I wanted to teach my new robot to do something useful, but also something relatively simple. A great <a href="https://medium.com/p/the-bots-are-coming-b0fa71475381?source=user_popover">post</a> by <a href="https://medium.com/u/b597e098b1fe">Simon Burns</a> makes the point that a bot should at least “Do one thing well”.</p><p>I decided on telling the time (reading stringified Javascript Date objects, although getting TJ Bot to ‘find’ an analogue clock in a room and read the hands sounds like an interesting image recognition project!). This has since been extended to tell the time in a given city.</p><p>Feel free to take a look at the source and import the Watson Conversation workspace JSON available <a href="https://github.com/DamianCummins/tell_the_time/">here</a>.</p><p>Hopefully this post is of use to anyone building their own TJ Bot!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ef44a9af173f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>