R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

#Association Rules - Apriori algorithm #
# Input - Grocery Store Transactions#
# install association rules package

library('arules')
## Loading required package: Matrix
## 
## Attaching package: 'arules'
## The following objects are masked from 'package:base':
## 
##     abbreviate, write
library("knitr")

# install association rules Visualization package

library('arulesViz')
## Loading required package: grid
## Registered S3 method overwritten by 'seriation':
##   method         from 
##   reorder.hclust gclus
data(Groceries)
summary(Groceries)     # indicates 9835 rows
## transactions as itemMatrix in sparse format with
##  9835 rows (elements/itemsets/transactions) and
##  169 columns (items) and a density of 0.02609146 
## 
## most frequent items:
##       whole milk other vegetables       rolls/buns             soda 
##             2513             1903             1809             1715 
##           yogurt          (Other) 
##             1372            34055 
## 
## element (itemset/transaction) length distribution:
## sizes
##    1    2    3    4    5    6    7    8    9   10   11   12   13   14   15 
## 2159 1643 1299 1005  855  645  545  438  350  246  182  117   78   77   55 
##   16   17   18   19   20   21   22   23   24   26   27   28   29   32 
##   46   29   14   14    9   11    4    6    1    1    1    1    3    1 
## 
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   1.000   2.000   3.000   4.409   6.000  32.000 
## 
## includes extended item information - examples:
##        labels  level2           level1
## 1 frankfurter sausage meat and sausage
## 2     sausage sausage meat and sausage
## 3  liver loaf sausage meat and sausage
class(Groceries)
## [1] "transactions"
## attr(,"package")
## [1] "arules"
Groceries@itemInfo[1:20,]
##               labels     level2               level1
## 1        frankfurter    sausage     meat and sausage
## 2            sausage    sausage     meat and sausage
## 3         liver loaf    sausage     meat and sausage
## 4                ham    sausage     meat and sausage
## 5               meat    sausage     meat and sausage
## 6  finished products    sausage     meat and sausage
## 7    organic sausage    sausage     meat and sausage
## 8            chicken    poultry     meat and sausage
## 9             turkey    poultry     meat and sausage
## 10              pork       pork     meat and sausage
## 11              beef       beef     meat and sausage
## 12    hamburger meat       beef     meat and sausage
## 13              fish       fish     meat and sausage
## 14      citrus fruit      fruit fruit and vegetables
## 15    tropical fruit      fruit fruit and vegetables
## 16         pip fruit      fruit fruit and vegetables
## 17            grapes      fruit fruit and vegetables
## 18           berries      fruit fruit and vegetables
## 19       nuts/prunes      fruit fruit and vegetables
## 20   root vegetables vegetables fruit and vegetables
#The following code displays the lOth to 20th transactions of the Groceries dataset.
apply(Groceries@data[,10:20],2,function(r)    paste(Groceries@itemInfo[r,"labels"],collapse=", "))
##  [1] "whole milk, cereals"                                                                         
##  [2] "tropical fruit, other vegetables, white bread, bottled water, chocolate"                     
##  [3] "citrus fruit, tropical fruit, whole milk, butter, curd, yogurt, flour, bottled water, dishes"
##  [4] "beef"                                                                                        
##  [5] "frankfurter, rolls/buns, soda"                                                               
##  [6] "chicken, tropical fruit"                                                                     
##  [7] "butter, sugar, fruit/vegetable juice, newspapers"                                            
##  [8] "fruit/vegetable juice"                                                                       
##  [9] "packaged fruit/vegetables"                                                                   
## [10] "chocolate"                                                                                   
## [11] "specialty bar"
#Apriori algorithm Implementation below

# First, get itemsets of length 1
itemsets<-apriori(Groceries,parameter=list(minlen=1,maxlen=1,support=0.02,target="frequent itemsets"))
## Apriori
## 
## Parameter specification:
##  confidence minval smax arem  aval originalSupport maxtime support minlen
##          NA    0.1    1 none FALSE            TRUE       5    0.02      1
##  maxlen            target   ext
##       1 frequent itemsets FALSE
## 
## Algorithmic control:
##  filter tree heap memopt load sort verbose
##     0.1 TRUE TRUE  FALSE TRUE    2    TRUE
## 
## Absolute minimum support count: 196 
## 
## set item appearances ...[0 item(s)] done [0.00s].
## set transactions ...[169 item(s), 9835 transaction(s)] done [0.01s].
## sorting and recoding items ... [59 item(s)] done [0.00s].
## creating transaction tree ... done [0.00s].
## checking subsets of size 1
## Warning in apriori(Groceries, parameter = list(minlen = 1, maxlen = 1,
## support = 0.02, : Mining stopped (maxlen reached). Only patterns up to a
## length of 1 returned!
##  done [0.00s].
## writing ... [59 set(s)] done [0.00s].
## creating S4 object  ... done [0.00s].
summary(itemsets)                               # found 59 itemsets
## set of 59 itemsets
## 
## most frequent items:
## frankfurter     sausage         ham        meat     chicken     (Other) 
##           1           1           1           1           1          54 
## 
## element (itemset/transaction) length distribution:sizes
##  1 
## 59 
## 
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##       1       1       1       1       1       1 
## 
## summary of quality measures:
##     support            count       
##  Min.   :0.02105   Min.   : 207.0  
##  1st Qu.:0.03015   1st Qu.: 296.5  
##  Median :0.04809   Median : 473.0  
##  Mean   :0.06200   Mean   : 609.8  
##  3rd Qu.:0.07666   3rd Qu.: 754.0  
##  Max.   :0.25552   Max.   :2513.0  
## 
## includes transaction ID lists: FALSE 
## 
## mining info:
##       data ntransactions support confidence
##  Groceries          9835    0.02          1
inspect(head(sort(itemsets,by="support"),10))   # lists top 10
##      items              support    count
## [1]  {whole milk}       0.25551601 2513 
## [2]  {other vegetables} 0.19349263 1903 
## [3]  {rolls/buns}       0.18393493 1809 
## [4]  {soda}             0.17437722 1715 
## [5]  {yogurt}           0.13950178 1372 
## [6]  {bottled water}    0.11052364 1087 
## [7]  {root vegetables}  0.10899847 1072 
## [8]  {tropical fruit}   0.10493137 1032 
## [9]  {shopping bags}    0.09852567  969 
## [10] {sausage}          0.09395018  924
# Second, get itemsets of length 2
itemsets<-apriori(Groceries,parameter=list(minlen=2,maxlen=2,support=0.02,target="frequent itemsets"))
## Apriori
## 
## Parameter specification:
##  confidence minval smax arem  aval originalSupport maxtime support minlen
##          NA    0.1    1 none FALSE            TRUE       5    0.02      2
##  maxlen            target   ext
##       2 frequent itemsets FALSE
## 
## Algorithmic control:
##  filter tree heap memopt load sort verbose
##     0.1 TRUE TRUE  FALSE TRUE    2    TRUE
## 
## Absolute minimum support count: 196 
## 
## set item appearances ...[0 item(s)] done [0.00s].
## set transactions ...[169 item(s), 9835 transaction(s)] done [0.00s].
## sorting and recoding items ... [59 item(s)] done [0.00s].
## creating transaction tree ... done [0.00s].
## checking subsets of size 1 2
## Warning in apriori(Groceries, parameter = list(minlen = 2, maxlen = 2,
## support = 0.02, : Mining stopped (maxlen reached). Only patterns up to a
## length of 2 returned!
##  done [0.00s].
## writing ... [61 set(s)] done [0.00s].
## creating S4 object  ... done [0.00s].
summary(itemsets)                               # found 61 itemsets
## set of 61 itemsets
## 
## most frequent items:
##       whole milk other vegetables           yogurt       rolls/buns 
##               25               17                9                9 
##             soda          (Other) 
##                9               53 
## 
## element (itemset/transaction) length distribution:sizes
##  2 
## 61 
## 
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##       2       2       2       2       2       2 
## 
## summary of quality measures:
##     support            count      
##  Min.   :0.02003   Min.   :197.0  
##  1st Qu.:0.02227   1st Qu.:219.0  
##  Median :0.02613   Median :257.0  
##  Mean   :0.02951   Mean   :290.3  
##  3rd Qu.:0.03223   3rd Qu.:317.0  
##  Max.   :0.07483   Max.   :736.0  
## 
## includes transaction ID lists: FALSE 
## 
## mining info:
##       data ntransactions support confidence
##  Groceries          9835    0.02          1
inspect(head(sort(itemsets,by="support"),10))   # lists top 10
##      items                              support    count
## [1]  {other vegetables,whole milk}      0.07483477 736  
## [2]  {whole milk,rolls/buns}            0.05663447 557  
## [3]  {whole milk,yogurt}                0.05602440 551  
## [4]  {root vegetables,whole milk}       0.04890696 481  
## [5]  {root vegetables,other vegetables} 0.04738180 466  
## [6]  {other vegetables,yogurt}          0.04341637 427  
## [7]  {other vegetables,rolls/buns}      0.04260295 419  
## [8]  {tropical fruit,whole milk}        0.04229792 416  
## [9]  {whole milk,soda}                  0.04006101 394  
## [10] {rolls/buns,soda}                  0.03833249 377
# Third, get itemsets of length 3
itemsets<-apriori(Groceries,parameter=list(minlen=3,maxlen=3,support=0.02,target="frequent itemsets"))
## Apriori
## 
## Parameter specification:
##  confidence minval smax arem  aval originalSupport maxtime support minlen
##          NA    0.1    1 none FALSE            TRUE       5    0.02      3
##  maxlen            target   ext
##       3 frequent itemsets FALSE
## 
## Algorithmic control:
##  filter tree heap memopt load sort verbose
##     0.1 TRUE TRUE  FALSE TRUE    2    TRUE
## 
## Absolute minimum support count: 196 
## 
## set item appearances ...[0 item(s)] done [0.00s].
## set transactions ...[169 item(s), 9835 transaction(s)] done [0.00s].
## sorting and recoding items ... [59 item(s)] done [0.00s].
## creating transaction tree ... done [0.00s].
## checking subsets of size 1 2 3
## Warning in apriori(Groceries, parameter = list(minlen = 3, maxlen = 3,
## support = 0.02, : Mining stopped (maxlen reached). Only patterns up to a
## length of 3 returned!
##  done [0.00s].
## writing ... [2 set(s)] done [0.00s].
## creating S4 object  ... done [0.00s].
summary(itemsets)                               # found 2 itemsets
## set of 2 itemsets
## 
## most frequent items:
## other vegetables       whole milk  root vegetables           yogurt 
##                2                2                1                1 
##      frankfurter          (Other) 
##                0                0 
## 
## element (itemset/transaction) length distribution:sizes
## 3 
## 2 
## 
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##       3       3       3       3       3       3 
## 
## summary of quality measures:
##     support            count      
##  Min.   :0.02227   Min.   :219.0  
##  1st Qu.:0.02250   1st Qu.:221.2  
##  Median :0.02272   Median :223.5  
##  Mean   :0.02272   Mean   :223.5  
##  3rd Qu.:0.02295   3rd Qu.:225.8  
##  Max.   :0.02318   Max.   :228.0  
## 
## includes transaction ID lists: FALSE 
## 
## mining info:
##       data ntransactions support confidence
##  Groceries          9835    0.02          1
inspect(head(sort(itemsets,by="support"),10))   # lists top 10
##     items                                         support    count
## [1] {root vegetables,other vegetables,whole milk} 0.02318251 228  
## [2] {other vegetables,whole milk,yogurt}          0.02226741 219
# Fourth, get itemsets of length 4
itemsets<-apriori(Groceries,parameter=list(minlen=4,maxlen=4,support=0.02,target="frequent itemsets"))
## Apriori
## 
## Parameter specification:
##  confidence minval smax arem  aval originalSupport maxtime support minlen
##          NA    0.1    1 none FALSE            TRUE       5    0.02      4
##  maxlen            target   ext
##       4 frequent itemsets FALSE
## 
## Algorithmic control:
##  filter tree heap memopt load sort verbose
##     0.1 TRUE TRUE  FALSE TRUE    2    TRUE
## 
## Absolute minimum support count: 196 
## 
## set item appearances ...[0 item(s)] done [0.00s].
## set transactions ...[169 item(s), 9835 transaction(s)] done [0.00s].
## sorting and recoding items ... [59 item(s)] done [0.00s].
## creating transaction tree ... done [0.00s].
## checking subsets of size 1 2 3 done [0.00s].
## writing ... [0 set(s)] done [0.00s].
## creating S4 object  ... done [0.00s].
summary(itemsets)                               # found 2 itemsets
## set of 0 itemsets
inspect(head(sort(itemsets,by="support"),10))   # lists top 10, No frequent 4-itemsets have been found, and the algorithm converges.

# The Apriori function  () is used to generate rules. A threshold is set lower than 0.001 and minimum confidence threshold is set to 0.6. Below code generates 2,918 rules.
rules <- apriori(Groceries,parameter=list(support=0.001,confidence=0.6,target="rules"))
## Apriori
## 
## Parameter specification:
##  confidence minval smax arem  aval originalSupport maxtime support minlen
##         0.6    0.1    1 none FALSE            TRUE       5   0.001      1
##  maxlen target   ext
##      10  rules FALSE
## 
## Algorithmic control:
##  filter tree heap memopt load sort verbose
##     0.1 TRUE TRUE  FALSE TRUE    2    TRUE
## 
## Absolute minimum support count: 9 
## 
## set item appearances ...[0 item(s)] done [0.00s].
## set transactions ...[169 item(s), 9835 transaction(s)] done [0.00s].
## sorting and recoding items ... [157 item(s)] done [0.00s].
## creating transaction tree ... done [0.00s].
## checking subsets of size 1 2 3 4 5 6 done [0.01s].
## writing ... [2918 rule(s)] done [0.00s].
## creating S4 object  ... done [0.00s].
summary(rules)            # finds 2918 rules
## set of 2918 rules
## 
## rule length distribution (lhs + rhs):sizes
##    2    3    4    5    6 
##    3  490 1765  626   34 
## 
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   2.000   4.000   4.000   4.068   4.000   6.000 
## 
## summary of quality measures:
##     support           confidence          lift            count      
##  Min.   :0.001017   Min.   :0.6000   Min.   : 2.348   Min.   :10.00  
##  1st Qu.:0.001118   1st Qu.:0.6316   1st Qu.: 2.668   1st Qu.:11.00  
##  Median :0.001220   Median :0.6818   Median : 3.168   Median :12.00  
##  Mean   :0.001480   Mean   :0.7028   Mean   : 3.450   Mean   :14.55  
##  3rd Qu.:0.001525   3rd Qu.:0.7500   3rd Qu.: 3.692   3rd Qu.:15.00  
##  Max.   :0.009354   Max.   :1.0000   Max.   :18.996   Max.   :92.00  
## 
## mining info:
##       data ntransactions support confidence
##  Groceries          9835   0.001        0.6
plot(rules)               # displays scatterplot
## To reduce overplotting, jitter is added! Use jitter = 0 to prevent jitter.

# Compute the 1/Support(Y) ie slope
slope<-sort(round(rules@quality$lift/rules@quality$confidence,2))

#Display the number of times each slope appears in dataset
unlist(lapply(split(slope,f=slope),length))
##  3.91  5.17  5.44  5.73  7.17  9.05  9.17  9.53 10.64 12.08 12.42 13.22 
##  1585   940    12     7   188     1   102    55     1     4     1     5 
## 13.83 13.95 18.05 23.76 26.44 30.08 
##     2     9     3     1     1     1
#Inspect function is used to display the top 10 rules sorted by lift
inspect(head(sort(rules,by="lift"),10))
##      lhs                        rhs                      support confidence      lift count
## [1]  {Instant food products,                                                               
##       soda}                  => {hamburger meat}     0.001220132  0.6315789 18.995654    12
## [2]  {soda,                                                                                
##       popcorn}               => {salty snack}        0.001220132  0.6315789 16.697793    12
## [3]  {ham,                                                                                 
##       processed cheese}      => {white bread}        0.001931876  0.6333333 15.045491    19
## [4]  {tropical fruit,                                                                      
##       other vegetables,                                                                    
##       yogurt,                                                                              
##       white bread}           => {butter}             0.001016777  0.6666667 12.030581    10
## [5]  {hamburger meat,                                                                      
##       yogurt,                                                                              
##       whipped/sour cream}    => {butter}             0.001016777  0.6250000 11.278670    10
## [6]  {tropical fruit,                                                                      
##       other vegetables,                                                                    
##       whole milk,                                                                          
##       yogurt,                                                                              
##       domestic eggs}         => {butter}             0.001016777  0.6250000 11.278670    10
## [7]  {liquor,                                                                              
##       red/blush wine}        => {bottled beer}       0.001931876  0.9047619 11.235269    19
## [8]  {other vegetables,                                                                    
##       butter,                                                                              
##       sugar}                 => {whipped/sour cream} 0.001016777  0.7142857  9.964539    10
## [9]  {whole milk,                                                                          
##       butter,                                                                              
##       hard cheese}           => {whipped/sour cream} 0.001423488  0.6666667  9.300236    14
## [10] {tropical fruit,                                                                      
##       other vegetables,                                                                    
##       butter,                                                                              
##       fruit/vegetable juice} => {whipped/sour cream} 0.001016777  0.6666667  9.300236    10
#Below code fetchces rules with confidence above 0.9
confidentRules<-rules[quality(rules)$confidence>0.9] 
confidentRules       # set of 127 rules
## set of 127 rules
#Plot a matrix-based visualization of the LHS v RHS of rules. This produces a Matrix-based visualization of LHS and RHS, colored by lift and confidence, 
plot(confidentRules,method="matrix",measure=c("lift","confidence"),control=list(reorder="none"))
## Itemsets in Antecedent (LHS)
##   [1] "{liquor,red/blush wine}"                                             
##   [2] "{curd,cereals}"                                                      
##   [3] "{soups,bottled beer}"                                                
##   [4] "{whipped/sour cream,house keeping products}"                         
##   [5] "{pastry,sweet spreads}"                                              
##   [6] "{rice,sugar}"                                                        
##   [7] "{rice,bottled water}"                                                
##   [8] "{canned fish,hygiene articles}"                                      
##   [9] "{grapes,onions}"                                                     
##  [10] "{hard cheese,oil}"                                                   
##  [11] "{root vegetables,butter,rice}"                                       
##  [12] "{herbs,whole milk,fruit/vegetable juice}"                            
##  [13] "{citrus fruit,tropical fruit,herbs}"                                 
##  [14] "{root vegetables,whipped/sour cream,flour}"                          
##  [15] "{butter,soft cheese,domestic eggs}"                                  
##  [16] "{tropical fruit,whipped/sour cream,soft cheese}"                     
##  [17] "{root vegetables,whipped/sour cream,soft cheese}"                    
##  [18] "{citrus fruit,root vegetables,soft cheese}"                          
##  [19] "{frankfurter,tropical fruit,frozen meals}"                           
##  [20] "{tropical fruit,butter,frozen meals}"                                
##  [21] "{tropical fruit,whipped/sour cream,hard cheese}"                     
##  [22] "{pork,whole milk,butter milk}"                                       
##  [23] "{pip fruit,butter milk,fruit/vegetable juice}"                       
##  [24] "{frankfurter,root vegetables,sliced cheese}"                         
##  [25] "{butter,whipped/sour cream,sliced cheese}"                           
##  [26] "{yogurt,oil,coffee}"                                                 
##  [27] "{root vegetables,onions,napkins}"                                    
##  [28] "{sausage,berries,butter}"                                            
##  [29] "{hamburger meat,tropical fruit,whipped/sour cream}"                  
##  [30] "{butter,hygiene articles,napkins}"                                   
##  [31] "{pip fruit,butter,hygiene articles}"                                 
##  [32] "{tropical fruit,butter,hygiene articles}"                            
##  [33] "{tropical fruit,domestic eggs,hygiene articles}"                     
##  [34] "{root vegetables,whipped/sour cream,hygiene articles}"               
##  [35] "{pip fruit,root vegetables,hygiene articles}"                        
##  [36] "{cream cheese ,domestic eggs,sugar}"                                 
##  [37] "{other vegetables,cream cheese ,sugar}"                              
##  [38] "{curd,domestic eggs,sugar}"                                          
##  [39] "{citrus fruit,domestic eggs,sugar}"                                  
##  [40] "{tropical fruit,domestic eggs,sugar}"                                
##  [41] "{yogurt,domestic eggs,sugar}"                                        
##  [42] "{root vegetables,whipped/sour cream,sugar}"                          
##  [43] "{pork,rolls/buns,waffles}"                                           
##  [44] "{whipped/sour cream,long life bakery product,napkins}"               
##  [45] "{tropical fruit,long life bakery product,napkins}"                   
##  [46] "{sausage,butter,long life bakery product}"                           
##  [47] "{tropical fruit,dessert,whipped/sour cream}"                         
##  [48] "{cream cheese ,domestic eggs,napkins}"                               
##  [49] "{root vegetables,butter,cream cheese }"                              
##  [50] "{pip fruit,whipped/sour cream,cream cheese }"                        
##  [51] "{sausage,pip fruit,cream cheese }"                                   
##  [52] "{citrus fruit,root vegetables,cream cheese }"                        
##  [53] "{root vegetables,butter,white bread}"                                
##  [54] "{butter,whipped/sour cream,coffee}"                                  
##  [55] "{root vegetables,domestic eggs,coffee}"                              
##  [56] "{butter,curd,domestic eggs}"                                         
##  [57] "{citrus fruit,butter,curd}"                                          
##  [58] "{domestic eggs,margarine,bottled beer}"                              
##  [59] "{pip fruit,whipped/sour cream,brown bread}"                          
##  [60] "{domestic eggs,margarine,fruit/vegetable juice}"                     
##  [61] "{butter,whipped/sour cream,soda}"                                    
##  [62] "{pip fruit,butter,pastry}"                                           
##  [63] "{tropical fruit,whipped/sour cream,fruit/vegetable juice}"           
##  [64] "{root vegetables,other vegetables,yogurt,rice}"                      
##  [65] "{root vegetables,whole milk,yogurt,rice}"                            
##  [66] "{tropical fruit,root vegetables,herbs,other vegetables}"             
##  [67] "{tropical fruit,grapes,whole milk,yogurt}"                           
##  [68] "{tropical fruit,pip fruit,yogurt,frozen meals}"                      
##  [69] "{root vegetables,other vegetables,yogurt,hard cheese}"               
##  [70] "{ham,tropical fruit,pip fruit,yogurt}"                               
##  [71] "{ham,tropical fruit,pip fruit,whole milk}"                           
##  [72] "{tropical fruit,butter,yogurt,sliced cheese}"                        
##  [73] "{tropical fruit,whole milk,butter,sliced cheese}"                    
##  [74] "{tropical fruit,root vegetables,yogurt,oil}"                         
##  [75] "{root vegetables,other vegetables,yogurt,oil}"                       
##  [76] "{root vegetables,whole milk,yogurt,oil}"                             
##  [77] "{root vegetables,other vegetables,yogurt,waffles}"                   
##  [78] "{other vegetables,curd,whipped/sour cream,cream cheese }"            
##  [79] "{citrus fruit,whole milk,whipped/sour cream,cream cheese }"          
##  [80] "{pip fruit,root vegetables,other vegetables,cream cheese }"          
##  [81] "{pip fruit,other vegetables,yogurt,cream cheese }"                   
##  [82] "{tropical fruit,butter,yogurt,white bread}"                          
##  [83] "{tropical fruit,other vegetables,butter,white bread}"                
##  [84] "{root vegetables,other vegetables,butter,white bread}"               
##  [85] "{root vegetables,whole milk,butter,white bread}"                     
##  [86] "{citrus fruit,other vegetables,yogurt,frozen vegetables}"            
##  [87] "{beef,tropical fruit,yogurt,rolls/buns}"                             
##  [88] "{tropical fruit,curd,yogurt,domestic eggs}"                          
##  [89] "{citrus fruit,tropical fruit,curd,yogurt}"                           
##  [90] "{other vegetables,butter,whipped/sour cream,napkins}"                
##  [91] "{pork,other vegetables,butter,whipped/sour cream}"                   
##  [92] "{pork,root vegetables,other vegetables,butter}"                      
##  [93] "{frankfurter,tropical fruit,root vegetables,yogurt}"                 
##  [94] "{pip fruit,root vegetables,other vegetables,brown bread}"            
##  [95] "{root vegetables,other vegetables,rolls/buns,brown bread}"           
##  [96] "{other vegetables,butter,whipped/sour cream,domestic eggs}"          
##  [97] "{tropical fruit,butter,yogurt,domestic eggs}"                        
##  [98] "{root vegetables,butter,yogurt,domestic eggs}"                       
##  [99] "{tropical fruit,butter,whipped/sour cream,fruit/vegetable juice}"    
## [100] "{whole milk,butter,whipped/sour cream,soda}"                         
## [101] "{citrus fruit,other vegetables,butter,bottled water}"                
## [102] "{whole milk,rolls/buns,soda,newspapers}"                             
## [103] "{pip fruit,other vegetables,whipped/sour cream,domestic eggs}"       
## [104] "{citrus fruit,whole milk,whipped/sour cream,domestic eggs}"          
## [105] "{tropical fruit,yogurt,whipped/sour cream,domestic eggs}"            
## [106] "{tropical fruit,other vegetables,whipped/sour cream,domestic eggs}"  
## [107] "{citrus fruit,tropical fruit,other vegetables,domestic eggs}"        
## [108] "{tropical fruit,yogurt,whipped/sour cream,fruit/vegetable juice}"    
## [109] "{tropical fruit,whole milk,whipped/sour cream,fruit/vegetable juice}"
## [110] "{pip fruit,root vegetables,yogurt,fruit/vegetable juice}"            
## [111] "{citrus fruit,other vegetables,soda,fruit/vegetable juice}"          
## [112] "{citrus fruit,whipped/sour cream,rolls/buns,pastry}"                 
## [113] "{citrus fruit,tropical fruit,root vegetables,whipped/sour cream}"    
## [114] "{pip fruit,root vegetables,other vegetables,bottled water}"          
## [115] "{tropical fruit,root vegetables,yogurt,pastry}"                      
## [116] "{sausage,tropical fruit,root vegetables,yogurt}"                     
## [117] "{sausage,tropical fruit,root vegetables,rolls/buns}"                 
## [118] "{tropical fruit,root vegetables,rolls/buns,bottled water}"           
## [119] "{tropical fruit,root vegetables,other vegetables,yogurt,oil}"        
## [120] "{tropical fruit,root vegetables,whole milk,yogurt,oil}"              
## [121] "{tropical fruit,other vegetables,whole milk,yogurt,oil}"             
## [122] "{tropical fruit,other vegetables,butter,yogurt,domestic eggs}"       
## [123] "{citrus fruit,root vegetables,whole milk,yogurt,whipped/sour cream}" 
## [124] "{citrus fruit,tropical fruit,root vegetables,whole milk,yogurt}"     
## Itemsets in Consequent (RHS)
## [1] "{bottled beer}"     "{whole milk}"       "{other vegetables}"
## [4] "{yogurt}"           "{root vegetables}"

#Visualize the top 5 rules with the highest lift and plot them
highLiftRules<-head(sort(rules,by="lift"),5) 
plot(highLiftRules,method="graph",control=list(type="items"))
## Warning: Unknown control parameters: type
## Available control parameters (with default values):
## main  =  Graph for 5 rules
## nodeColors    =  c("#66CC6680", "#9999CC80")
## nodeCol   =  c("#EE0000FF", "#EE0303FF", "#EE0606FF", "#EE0909FF", "#EE0C0CFF", "#EE0F0FFF", "#EE1212FF", "#EE1515FF", "#EE1818FF", "#EE1B1BFF", "#EE1E1EFF", "#EE2222FF", "#EE2525FF", "#EE2828FF", "#EE2B2BFF", "#EE2E2EFF", "#EE3131FF", "#EE3434FF", "#EE3737FF", "#EE3A3AFF", "#EE3D3DFF", "#EE4040FF", "#EE4444FF", "#EE4747FF", "#EE4A4AFF", "#EE4D4DFF", "#EE5050FF", "#EE5353FF", "#EE5656FF", "#EE5959FF", "#EE5C5CFF", "#EE5F5FFF", "#EE6262FF", "#EE6666FF", "#EE6969FF", "#EE6C6CFF", "#EE6F6FFF", "#EE7272FF", "#EE7575FF",  "#EE7878FF", "#EE7B7BFF", "#EE7E7EFF", "#EE8181FF", "#EE8484FF", "#EE8888FF", "#EE8B8BFF", "#EE8E8EFF", "#EE9191FF", "#EE9494FF", "#EE9797FF", "#EE9999FF", "#EE9B9BFF", "#EE9D9DFF", "#EE9F9FFF", "#EEA0A0FF", "#EEA2A2FF", "#EEA4A4FF", "#EEA5A5FF", "#EEA7A7FF", "#EEA9A9FF", "#EEABABFF", "#EEACACFF", "#EEAEAEFF", "#EEB0B0FF", "#EEB1B1FF", "#EEB3B3FF", "#EEB5B5FF", "#EEB7B7FF", "#EEB8B8FF", "#EEBABAFF", "#EEBCBCFF", "#EEBDBDFF", "#EEBFBFFF", "#EEC1C1FF", "#EEC3C3FF", "#EEC4C4FF", "#EEC6C6FF", "#EEC8C8FF",  "#EEC9C9FF", "#EECBCBFF", "#EECDCDFF", "#EECFCFFF", "#EED0D0FF", "#EED2D2FF", "#EED4D4FF", "#EED5D5FF", "#EED7D7FF", "#EED9D9FF", "#EEDBDBFF", "#EEDCDCFF", "#EEDEDEFF", "#EEE0E0FF", "#EEE1E1FF", "#EEE3E3FF", "#EEE5E5FF", "#EEE7E7FF", "#EEE8E8FF", "#EEEAEAFF", "#EEECECFF", "#EEEEEEFF")
## edgeCol   =  c("#474747FF", "#494949FF", "#4B4B4BFF", "#4D4D4DFF", "#4F4F4FFF", "#515151FF", "#535353FF", "#555555FF", "#575757FF", "#595959FF", "#5B5B5BFF", "#5E5E5EFF", "#606060FF", "#626262FF", "#646464FF", "#666666FF", "#686868FF", "#6A6A6AFF", "#6C6C6CFF", "#6E6E6EFF", "#707070FF", "#727272FF", "#747474FF", "#767676FF", "#787878FF", "#7A7A7AFF", "#7C7C7CFF", "#7E7E7EFF", "#808080FF", "#828282FF", "#848484FF", "#868686FF", "#888888FF", "#8A8A8AFF", "#8C8C8CFF", "#8D8D8DFF", "#8F8F8FFF", "#919191FF", "#939393FF",  "#959595FF", "#979797FF", "#999999FF", "#9A9A9AFF", "#9C9C9CFF", "#9E9E9EFF", "#A0A0A0FF", "#A2A2A2FF", "#A3A3A3FF", "#A5A5A5FF", "#A7A7A7FF", "#A9A9A9FF", "#AAAAAAFF", "#ACACACFF", "#AEAEAEFF", "#AFAFAFFF", "#B1B1B1FF", "#B3B3B3FF", "#B4B4B4FF", "#B6B6B6FF", "#B7B7B7FF", "#B9B9B9FF", "#BBBBBBFF", "#BCBCBCFF", "#BEBEBEFF", "#BFBFBFFF", "#C1C1C1FF", "#C2C2C2FF", "#C3C3C4FF", "#C5C5C5FF", "#C6C6C6FF", "#C8C8C8FF", "#C9C9C9FF", "#CACACAFF", "#CCCCCCFF", "#CDCDCDFF", "#CECECEFF", "#CFCFCFFF", "#D1D1D1FF",  "#D2D2D2FF", "#D3D3D3FF", "#D4D4D4FF", "#D5D5D5FF", "#D6D6D6FF", "#D7D7D7FF", "#D8D8D8FF", "#D9D9D9FF", "#DADADAFF", "#DBDBDBFF", "#DCDCDCFF", "#DDDDDDFF", "#DEDEDEFF", "#DEDEDEFF", "#DFDFDFFF", "#E0E0E0FF", "#E0E0E0FF", "#E1E1E1FF", "#E1E1E1FF", "#E2E2E2FF", "#E2E2E2FF", "#E2E2E2FF")
## alpha     =  0.5
## cex   =  1
## itemLabels    =  TRUE
## labelCol  =  #000000B3
## measureLabels     =  FALSE
## precision     =  3
## layout    =  NULL
## layoutParams  =  list()
## arrowSize     =  0.5
## engine    =  igraph
## plot  =  TRUE
## plot_options  =  list()
## max   =  100
## verbose   =  FALSE