If you’re reading this then you’ve most likely heard all the buzz around chatbots. In fact, you may have come up with a few scenarios where it would be really helpful for you to use one.
Most people consider chatbots to be in the realm of what only programmers can create, out of reach of business users who would otherwise have a need for them.
Thankfully, IBM provides the Watson Conversation service on their IBM Cloud platform which, combined with our WordPress plugin, solves that.
The plugin provides you with an easy way to deploy chatbots you create with IBM Watson Conversation to WordPress sites. In fact, you may have noticed a floating chatbot icon at the bottom of this page. Click on it to see the plugin in action.
What is Watson Conversation?
Watson Conversation is IBM’s chatbot service. Its intuitive interface allows chatbot creators to build their chatbot and have it ready to deploy in short time. You can sign up for a free IBM Cloud Lite account to get started.
Building your chatbot won’t be covered in this article but we have a great Chatbot course that guides you through this process and doesn’t require any coding expertise.
How do I add a chatbot to my website?
This is where the Watson Conversation WordPress plugin saves you time and money. If you have a website built using WordPress, deploying your chatbot to your website takes about 5 minutes and no code at all (as opposed to having to build your own application just to deploy a chatbot on the web.)
You can install it like any other WordPress plugin from your Admin page, that is, the first page you see after signing in.
Just search for Watson Conversation in the “Add New” section of the Plugins page and click “Install Now”.
Now you can find a page for “Watson” in your Settings. This is where you’ll find all the settings and customization to do with the plugin. When you first open it, you’ll see several tabs along the top.
For now, the only one you have to worry about is “Main Setup”.
You can find the credentials for the three required fields on the Deploy page of your Watson Conversation workspace.
Now just click save changes and you’re done. Browse your website and see your chatbot in action!
If you’re not quite satisfied with the appearance, you can customize this in the “Appearance” tab of the settings page.
You can also choose which pages to display the chat box on from the “Behaviour” tab. However, that’s not all you can do.
If you want to make the options clear to the user, you can create predefined responses to the chatbot messages for the users to select. The VOIP feature can connect users to your phone line over the internet from directly within the plugin.
In this brief article, we focused on how to deploy Watson Conversation chatbots to WordPress. Stay tuned for future articles on how to customize and use these exciting advanced features!
Dealing with multiple dimensions is difficult, this can be compounded when working with data. This blog post acts as a guide to help you understand the relationship between different dimensions, Python lists, and Numpy arrays as well as some hints and tricks to interpret data in multiple dimensions. We provide an overview of Python lists and Numpy arrays, clarify some of the terminologies and give some helpful analogies when dealing with higher dimensional data.
Introduction
Before you create a Deep Neural network in TensorFlow, Build a regression model, Predict the price of a car or visualize terabytes of data you’re going to have to learn Python and deal with multidimensional data. So this blog post is expanded from our introductory course on Python for Data Science and help you deal with nesting lists in python and give you some ideas about numpy arrays.
Nesting involves placing one or multiple Python lists into another Python list, you can apply it to other data structures in Python, but we will just stick to lists. Nesting is a useful feature in Python, but sometimes the indexing conventions can get a little confusing so let’s clarify the process expanding from our courses on Applied Data Science with Python We will review concepts of nesting lists to create 1, 2, 3 and 4-dimensional lists, then we will convert them to numpy arrays.
Lists and 1-D Numpy Arrays
Lists are a useful datatype in Python; lists can be written as comma separated values. You can change the size of a Python list after you create it and lists can contain an integer, string, float, Python function and Much more. Indexing for a one-dimensional (1-D) list in Python is straightforward; each index corresponds to an individual element of the Python list. Python’s list convention is shown in figure 1 where each item is accessed using the name of the list followed by a square Bracket. For example, the first index is obtained by A[0]:”0″; the means that the zeroth element of the List contains the string 0. Similarly, the value of A[4] is an integer 4. For the rest of this blog, we are going to stick with integer values and lists of uniform size as you may see in many data science applications.
Figure 1: Indexing Conventions for a list “A”
Lists are useful but for numerical operations such as the ones you will use in data science, Python has many useful libraries one of the most commonly used is numpy.
From Lists to 1-D Numpy Arrays
Numpy is a fast Python library for performing mathematical operations. The numpy class is the “ndarray” is key to this framework; we will refer to objects from this class as a numpy array. Some key differences between lists include, numpy arrays are of fixed sizes, they are homogenous I,e you can only contain, floats or strings, you can easily convert a list to a numpy array, For example, if you would like to perform vector operations you can cast a list to a numpy array. In example 1 we import numpy then cast the two list to numpy arrays:
import nunpy as np
u=np.array([1,0])
v=np.array([0,1])
Example 1: casting list [1,0] and [0,1] to a numpy array u and v.
If you check the type of u or v (type(v) ) you will get a “numpy.ndarray”. Although u and v points in a 2 D space there dimension is one, you can verify this using the data attribute “ndim”. For example, v.ndim will output a one. In numpy dimension or axis are better understood in the context of nesting, this will be discussed in the next section. It should be noted the sometimes the data attribute shape is referred to as the dimension of the numpy array.
The numpy array has many useful properties for example vector addition, we can add the two arrays as follows:
z=u+v
z:array([1,1])
Example 2: add numpy arrays u and v to form a new numpy array z.
Where the term “z:array([1,1])” means the variable z contains an array. The actual vector operation is shown in figure 2, where each component of the vector has a different color.
Figure 2: Example of vector addition
Numpy arrays also follow similar conventions for vector scalar multiplication, for example, if you multiply a numpy array by an integer or float:
y=np.array([1,2])
y=2*z
y:array([2,4])
Example 3.1: multiplying numpy arrays y by a scaler 2.
The equivalent vector operation is shown in figure 3:
Figure 3: Vector addition is shown in code segment 2
Like list you can access the elements accordingly, for example, you can access the first element of the numpy array as follows u[0]:1. Many of the operations of numpy arrays are different from vectors, for example in numpy multiplication does not correspond to dot product or matrix multiplication but element-wise multiplication like Hadamard product, we can multiply two numpy arrays as follows:
Figure 4: multiplication of two numpy arrays expressed as a Hadamard product.
Nesting lists and two 2-D numpy arrays
Nesting two lists are where things get interesting, and a little confusing; this 2-D representation is important as tables in databases, Matrices, and grayscale images follow this convention. When each of the nested lists is the same size, we can view it as a 2-D rectangular table as shown in figure 5. The Python list “A” has three lists nested within it, each Python list is represented as a different color. Each list is a different row in the rectangular table, and each column represents a separate element in the list. In this case, we set the elements of the list corresponding to row and column numbers respectively.
Figure 5: List “A” two Nested lists represented as a table
In Python to access a list with a second nested list, we use two brackets, the first bracket corresponds to the row number and the second index corresponds to the column. This indexing convention to access each element of the list is shown in figure 6, the top part of the figure corresponds to the nested list, and the bottom part corresponds to the rectangular representation.
Figure 6: Index conventions for list “A” also represented as a table
Let’s see some examples in figure 4, Example 1 shows the syntax to access element A[0][0], example 2 shows the syntax to access element A[1][2] and example 3 shows how to access element A[2][0].
Figure 7: Example of indexing elements of a list.
We can also view the nesting as a tree as we did in Python for Data Science as shown in figure 5 The first index corresponds to a first level of the tree, the second index corresponds to the second level.
Figure 8: An example of matrix addition
2-D numpy arrays
Turns out we can cast two nested lists into a 2-D array, with the same index conventions. For example, we can convert the following nested list into a 2-D array:
V=np.array([[1, 0, 0],[0,1, 0],[0,0,1]])
Example 4: creating a 2-D array or array with two access
The convention for indexing is the exact same, we can represent the array using the table form like in figure 5. In numpy the dimension of this array is 2, this may be confusing as each column contains linearly independent vectors. In numpy, the dimension can be seen as the number of nested lists. The 2-D arrays share similar properties to matrices like scaler multiplication and addition. For example, adding two 2-D numpy arrays corresponds to matrix addition.
Example 5.2: the result of multiplying numpy arrays
Or Hadamard product:
Figure 10: An example of Hadamar product.
To perform standard matrix multiplication you world use np.dot(X,Y). In the next section, we will review some strategies to help you navigate your way through arrays in higher dimensions.
Nesting List within a List within a List and 3-D Numpy Arrays
We can nest three lists, each of these lists intern have nested lists that have there own nested lists as shown in figure 11. List “A” contains three nested lists, each color-coded. You can access the first, second and third list using A[0], A[1] and A[2] respectively. Each of these lists contains a list of three nested lists. We can represent these nested lists as a rectangular table as shown in figure 11. The indexing conventions apply to these lists as well we just add a third bracket, this is also demonstrated in the bottom of figure 6 where the three rectangular tables contain the syntax to access the values shown in the table above.
Figure 11: List with three nested, each nested list has three nested lists.
Figure 12 shows an example to access elements at index A[0][2][1] which contains a value of 132. The first index A[0] contains a list that contains three lists, which can be represented as a rectangular table. We use the second index i.e A[0][2] to access the last list contained in A[0]. In the table representation, this corresponds to the last row of the table. The list A[0][2] corresponds to the list [131,132,133]. As we are interested in accessing the second element we simply append the index [1]; Therefore the final result is A[0][2][1].
Figure 12: Visualization of obtaining A[0][2][1]
A helpful analogy is if you think of finding a room in an apartment building on the street as shown in Figure 13. The first index of the list represents the address on the road, in Figure 8 this is shown as depth. The second index of the list represents the floor where the room is situated, depicted by the vertical direction in Figure 13. To keep consistent with our table representation the lower levels have a larger index. Finally, the last index of the list corresponds to the room number on a particular floor, represented by the horizontal arrow.
Figure 13: Street analogy for list indexing
For example, in figure 9 the element in the list A[2][2][1]: corresponds to building 2 on the first floor the room is in the middle, the actual element is 332.
Figure 14: Example of List indexing Street analogy for list indexing
3D Numpy Arrays
The mathematical operations for 3D numpy arrays follow similar conventions i.e element-wise addition and multiplication as shown in figure 15 and figure 16. In the figures, X, Y first index or dimension corresponds an element in the square brackets but instead of a number, we have a rectangular array. When the add or multiply X and Y together each element is added or multiplied together independently. More precisely each 2D arrays represented as tables is X are added or multiplied with the corresponding arrays Y as shown on the left; within those arrays, the same conventions of 2D numpy addition is followed.
Figure 15: Add two 3D numpy arrays X and Y.
Figure 16: Multiplying two 3D numpy arrays X and Y.
Beyond 3D Lists
Adding another layer of nesting gets a little confusing, you cant really visualize it as it can be seen as a 4-dimensional problem but let’s try to wrap our heads around it. Examining, figure 17 we see list “A” has three lists, each list contains two lists, which intern contain two lists nested in them. Let’s go through the process of accessing the element that contains 3122. The third element A[2] contains 2 lists; this list contains two lists in figure 10 we use the depth to distinguish them. We can access the second list using the second index as follows A[2][1]. This can be viewed as a table, from this point we follow the table conventions for the previous example as illustrated in figure 17.
Figure 17: Example of an element in a list, with a list, within a list nested in list “A”
We can also use the apartment analogy as shown in figure 18 this time the new list index will be represented by the street name of 1st street and 2nd street. As before the second list index represents the address, the third list index represents the floor number and the fourth index represents the apartment number. The analogy is summarized in Figure 11. For example directions to element A[2][1][0][0] would be 2nd Street , Building 1, Floor 0 room 0.
Figure 18: Street analogy for figure 11
We see that you can store multiple dimensions of data as a Python list. Similarly, a Numpy array is a more widely used method to store and process data. In both cases, you can access each element of the list using square brackets. Although Numpy arrays behave like vectors and matrices, there are some subtle differences in many of the operations and terminology. Finally, when navigating your way through higher dimensions it’s helpful to use analogies.
Big Data 101 – What Is Big Data? Take Our Free Big Data Course to Find Out.
Predictive Modeling Fundamentals I – Take this free course and learn the different mathematical algorithms used to detect patterns hidden in data.
Using R with Databases – Learn how to unleash the power of R when working with relational databases in our newest free course.
Deep Learning with TensorFlow – Take this free TensorFlow course and learn how to use Google’s library to apply deep learning to different data types in order to solve real world problems.
Big Data 101 – What Is Big Data? Take Our Free Big Data Course to Find Out.
Predictive Modeling Fundamentals I – Take this free course and learn the different mathematical algorithms used to detect patterns hidden in data.
Using R with Databases – Learn how to unleash the power of R when working with relational databases in our newest free course.
Deep Learning with TensorFlow – Take this free TensorFlow course and learn how to use Google’s library to apply deep learning to different data types in order to solve real world problems.
Big Data 101 – What Is Big Data? Take Our Free Big Data Course to Find Out.
Predictive Modeling Fundamentals I – Take this free course and learn the different mathematical algorithms used to detect patterns hidden in data.
Using R with Databases – Learn how to unleash the power of R when working with relational databases in our newest free course.
Deep Learning with TensorFlow – Take this free TensorFlow course and learn how to use Google’s library to apply deep learning to different data types in order to solve real world problems.