Get startedGet started for free

Alternative rule plots

1. Alternative rule plots

In this last lesson, we will have a closer look at other types of plots that can be useful to explore the set of rules. Finally, we will wrap-up all types of plot by using a shiny app that includes all of the plots we have seen so far. Let's get started!

2. Group-based matrix visualizations

In order to illustrate the different plots from the "arulesViz" package, let us extract new rules using the "apriori" function. In this case, we lower the minimum support such that we are able to extract more rules than we did in the previous chapter (supp was previously set to 3/7, now we set it to 1/7). We use the "plot" function with the key word "grouped" as a method. In this matrix looking plots antecedents or items on the left hand side are grouped using clustering techniques. Groups are represented by the most interesting item in the group. The most interesting means that it has the highest ratio of support in the group to support in all rules. Balloons in the matrix are used to represent with which consequent the antecedents are connected.

3. Group-based matrix visualizations

Similarly to other plots, you can fiddle around with the different measures of interest. Let's for instance use the "lift" as measure (here represented as the bubble size) and the confidence as color coding. The plot looks now different than the previous one.

4. Parallel coordinate plots

The last type of plot we will look at is the parallel coordinate plot. On the left hand side, we see the inspection of the rules, there are 15 rules in total. In general, parallel coordinates plots are designed to visualize multidimensional data where each dimension is displayed separately on the x-axis and the y-axis is shared. Each data point is represented by a line connecting the values for each dimension. In the context of Market Basket Analysis, parallel plots display the items on the y-axis and the x-axis represents the positions in a rule, so, first item, second item, etc. Instead of displaying a simple line, an arrow is used where the head points to the consequent item. Arrows only span enough positions on the x-axis to represent all the items in the rule, i.e., rules with less items are shorter arrows. The width of the arrows represents "support" and the intensity of the color represent "confidence". For instance, from this plot, we can see that many rules have as consequent "Butter" and "Wine" - and that these rules have a large confidence.

5. ruleExplorer: the Swiss Army knife

In the past lessons, we've learned a big range of techniques to visualize the rules. This can be tiresome to repeat manually. Luckily, the "aruleviz" package allows us to see all of these visualizations within a shiny app with just one line of code! Neat right? By using the "ruleexplorer" function, a shiny web app opens up with all of the visualization techniques we've learned previously. On the sidebar of the app, you can even choose the parameters of the apriori function, such as minimum support or confidence. On the main panel of the app, you can choose the type of output, from data tables, to scatter plots, matrices, and graphs. You will play around with shiny apps.

6. More on Shiny

Learning shiny is not a part of this course - however if you want to learn how to build such robust web apps with R - make sure you take the "Shiny Fundamentals with R" track on DataCamp.

7. Let's ruleExplore!

It is your turn to test the different rule plots and try out the Shiny app "ruleExplorer" on the Online Retail dataset.

Create Your Free Account

or

By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.