Modeling and evaluating data in Tableau

Neural networks are often difficult to understand. When the data is loaded into Tableau, we can visually understand the distinctions made by the underlying model. Since we can easily load data into Tableau, we can do this on an ongoing basis.

In this example, we will use Tableau as part of the testing process. We will present the model with data, and see how well the R model can distinguish between the three types of iris. Once we have set up the Tableau workbook, we can load more data into the workbook, using the connect to data facility. This would help us to see if the model continues to distinguish between the model types, and we could continue to test the model on an ongoing basis.

Using Tableau to evaluate data

Let's load more data into Tableau. For our testing purposes, we will reuse the iris data that we used in the earlier example. However, if this was real life, this would not be the best practice for testing purposes. Here, we are reusing the data so we can be certain that our results in Tableau match our results in R. Then, in real life, we would move forward by using new test data.

To load in the iris dataset, refer to the UCI Machine Learning website. Here is the URL for reference: http://mlr.cs.umass.edu/ml/datasets.html.

Once the data is downloaded and imported into Tableau, you will see the headers appear. Here is an example:

Using Tableau to evaluate data

After the data is imported, let's write a small script that will access the neural network in R. Here is the code:

SCRIPT_REAL(
'library(neuralnet); predict <- compute(nn,data.frame(.arg1,.arg2,.arg3,.arg4));predict$net.result[1,]',
SUM([Petal.Length]), SUM([Petal.Width]),SUM([Sepal.Length]),SUM([Sepal.Width]))

Let's break the script down.

Initially, the code calls the neuralnet library, so that the rest of the script will run. The predict variable is used to hold the results of the compute format. It needs four arguments to run, and those are the columns in the Tableau notation at the end.

To put the script into Tableau, go to the Measures option and right-click to get the menu for Calculated Fields. We will put the script into a Calculated Field. In our example, we will give it a name: Predicted Output. When we put it into Tableau, it appears as follows:

Using Tableau to evaluate data

Once the formula is in place, we can look at producing visualizations to show the differences in the cluster. Here, we will start with the end result, and then step back so we can see how it was done:

Using Tableau to evaluate data

In this example, we can see that the predicted output for each iris type is clear, and it's distinct in terms of the actual number, and the actual color.

To create this workbook, we have simply dragged over the Species and the Predicted Output pills onto the canvas, and used Predicted Output for the color. It's great to have visualizations empowered with R, which we can use easily in Tableau.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset