Another interesting application of machine learning is to find interesting shopping patterns which could be used by online retailers, inventory managers in shopping marts to optimize their sales. The retailers can build recommendation systems out of the learned association rules. For instance, if shoppers frequently purchase bread with peanut butter, then it may be possible to increase profit by relocating peanut butter closer to bread. The association rules indicate combinations of items that are often purchased together in a set. This acquired knowledge might provide insight into new ways for a grocery chain to optimize the inventory, advertise promotions, or organize the physical layout of the store. The below analysis shows, how the apriori algorithms is used to find these association rules from the shopping data.

The dataset used for the analyis is taken from the arules package in R. The groceries dataset is not normal dataset, it is a type of transaction dataset and therefore it woulb be more efficient analysis to convert it to a sparse matrix.

#############Identifying Frequently-Purchased Groceries###########


##### Step-1: Exploring and preparing the data #######

# load the grocery data into a sparse matrix
library(arules)
## Warning: package 'arules' was built under R version 3.2.5
## Loading required package: Matrix
## 
## Attaching package: 'arules'
## 
## The following objects are masked from 'package:base':
## 
##     abbreviate, write
groceries <- read.transactions("groceries.csv", sep = ",")
summary(groceries)
## 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
## 1 abrasive cleaner
## 2 artif. sweetener
## 3   baby cosmetics
# look at the first five transactions
inspect(groceries[1:5])
##   items                     
## 1 {citrus fruit,            
##    margarine,               
##    ready soups,             
##    semi-finished bread}     
## 2 {coffee,                  
##    tropical fruit,          
##    yogurt}                  
## 3 {whole milk}              
## 4 {cream cheese,            
##    meat spreads,            
##    pip fruit,               
##    yogurt}                  
## 5 {condensed milk,          
##    long life bakery product,
##    other vegetables,        
##    whole milk}
# examine the frequency of items
itemFrequency(groceries[, 1:3])
## abrasive cleaner artif. sweetener   baby cosmetics 
##     0.0035587189     0.0032536858     0.0006100661
# plot the frequency of items
itemFrequencyPlot(groceries, support = 0.1)

itemFrequencyPlot(groceries, topN = 20)

# a visualization of the sparse matrix for the first five transactions
image(groceries[1:5])

# visualization of a random sample of 100 transactions
image(sample(groceries, 100))

######## Step 2: Training a model on the data ########
library(arules)

# default settings result in zero rules learned
apriori(groceries)
## Apriori
## 
## Parameter specification:
##  confidence minval smax arem  aval originalSupport support minlen maxlen
##         0.8    0.1    1 none FALSE            TRUE     0.1      1     10
##  target   ext
##   rules FALSE
## 
## Algorithmic control:
##  filter tree heap memopt load sort verbose
##     0.1 TRUE TRUE  FALSE TRUE    2    TRUE
## 
## Absolute minimum support count: 983 
## 
## set item appearances ...[0 item(s)] done [0.00s].
## set transactions ...[169 item(s), 9835 transaction(s)] done [0.00s].
## sorting and recoding items ... [8 item(s)] done [0.00s].
## creating transaction tree ... done [0.00s].
## checking subsets of size 1 2 done [0.00s].
## writing ... [0 rule(s)] done [0.00s].
## creating S4 object  ... done [0.00s].
## set of 0 rules
# set better support and confidence levels to learn more rules
groceryrules <- apriori(groceries, parameter = list(support =
                                                      0.006, confidence = 0.25, minlen = 2))
## Apriori
## 
## Parameter specification:
##  confidence minval smax arem  aval originalSupport support minlen maxlen
##        0.25    0.1    1 none FALSE            TRUE   0.006      2     10
##  target   ext
##   rules FALSE
## 
## Algorithmic control:
##  filter tree heap memopt load sort verbose
##     0.1 TRUE TRUE  FALSE TRUE    2    TRUE
## 
## Absolute minimum support count: 59 
## 
## set item appearances ...[0 item(s)] done [0.00s].
## set transactions ...[169 item(s), 9835 transaction(s)] done [0.00s].
## sorting and recoding items ... [109 item(s)] done [0.00s].
## creating transaction tree ... done [0.00s].
## checking subsets of size 1 2 3 4 done [0.01s].
## writing ... [463 rule(s)] done [0.00s].
## creating S4 object  ... done [0.00s].
groceryrules
## set of 463 rules
############# Step 3: Evaluating model performance #########
# summary of grocery association rules
summary(groceryrules)
## set of 463 rules
## 
## rule length distribution (lhs + rhs):sizes
##   2   3   4 
## 150 297  16 
## 
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   2.000   2.000   3.000   2.711   3.000   4.000 
## 
## summary of quality measures:
##     support           confidence          lift       
##  Min.   :0.006101   Min.   :0.2500   Min.   :0.9932  
##  1st Qu.:0.007117   1st Qu.:0.2971   1st Qu.:1.6229  
##  Median :0.008744   Median :0.3554   Median :1.9332  
##  Mean   :0.011539   Mean   :0.3786   Mean   :2.0351  
##  3rd Qu.:0.012303   3rd Qu.:0.4495   3rd Qu.:2.3565  
##  Max.   :0.074835   Max.   :0.6600   Max.   :3.9565  
## 
## mining info:
##       data ntransactions support confidence
##  groceries          9835   0.006       0.25
# look at the first three rules
inspect(groceryrules[1:3])
##   lhs                rhs               support     confidence lift    
## 1 {potted plants} => {whole milk}      0.006914082 0.4000000  1.565460
## 2 {pasta}         => {whole milk}      0.006100661 0.4054054  1.586614
## 3 {herbs}         => {root vegetables} 0.007015760 0.4312500  3.956477
############# Step 4: Improving model performance ############

# sorting grocery rules by lift
inspect(sort(groceryrules, by = "lift")[1:5])
##   lhs                   rhs                      support confidence     lift
## 1 {herbs}            => {root vegetables}    0.007015760  0.4312500 3.956477
## 2 {berries}          => {whipped/sour cream} 0.009049314  0.2721713 3.796886
## 3 {other vegetables,                                                        
##    tropical fruit,                                                          
##    whole milk}       => {root vegetables}    0.007015760  0.4107143 3.768074
## 4 {beef,                                                                    
##    other vegetables} => {root vegetables}    0.007930859  0.4020619 3.688692
## 5 {other vegetables,                                                        
##    tropical fruit}   => {pip fruit}          0.009456024  0.2634561 3.482649
# finding subsets of rules containing any berry items
berryrules <- subset(groceryrules, items %in% "berries")
inspect(berryrules)
##    lhs          rhs                  support     confidence lift    
## 57 {berries} => {whipped/sour cream} 0.009049314 0.2721713  3.796886
## 58 {berries} => {yogurt}             0.010574479 0.3180428  2.279848
## 59 {berries} => {other vegetables}   0.010269446 0.3088685  1.596280
## 60 {berries} => {whole milk}         0.011794611 0.3547401  1.388328
# writing the rules to a CSV file
write(groceryrules, file = "groceryrules.csv",
      sep = ",", quote = TRUE, row.names = FALSE)

# converting the rule set to a data frame
groceryrules_df <- as(groceryrules, "data.frame")

# The rules identified by the algorithms are
str(groceryrules_df)
## 'data.frame':    463 obs. of  4 variables:
##  $ rules     : Factor w/ 463 levels "{baking powder} => {other vegetables}",..: 340 302 207 206 208 341 402 21 139 140 ...
##  $ support   : num  0.00691 0.0061 0.00702 0.00773 0.00773 ...
##  $ confidence: num  0.4 0.405 0.431 0.475 0.475 ...
##  $ lift      : num  1.57 1.59 3.96 2.45 1.86 ...
groceryrules_df$rules
##   [1] {potted plants} => {whole milk}                                  
##   [2] {pasta} => {whole milk}                                          
##   [3] {herbs} => {root vegetables}                                     
##   [4] {herbs} => {other vegetables}                                    
##   [5] {herbs} => {whole milk}                                          
##   [6] {processed cheese} => {whole milk}                               
##   [7] {semi-finished bread} => {whole milk}                            
##   [8] {beverages} => {whole milk}                                      
##   [9] {detergent} => {other vegetables}                                
##  [10] {detergent} => {whole milk}                                      
##  [11] {pickled vegetables} => {other vegetables}                       
##  [12] {pickled vegetables} => {whole milk}                             
##  [13] {baking powder} => {other vegetables}                            
##  [14] {baking powder} => {whole milk}                                  
##  [15] {flour} => {other vegetables}                                    
##  [16] {flour} => {whole milk}                                          
##  [17] {soft cheese} => {other vegetables}                              
##  [18] {soft cheese} => {whole milk}                                    
##  [19] {specialty bar} => {soda}                                        
##  [20] {misc. beverages} => {soda}                                      
##  [21] {grapes} => {tropical fruit}                                     
##  [22] {grapes} => {other vegetables}                                   
##  [23] {grapes} => {whole milk}                                         
##  [24] {cat food} => {yogurt}                                           
##  [25] {cat food} => {other vegetables}                                 
##  [26] {cat food} => {whole milk}                                       
##  [27] {specialty chocolate} => {whole milk}                            
##  [28] {meat} => {rolls/buns}                                           
##  [29] {meat} => {other vegetables}                                     
##  [30] {meat} => {whole milk}                                           
##  [31] {frozen meals} => {other vegetables}                             
##  [32] {frozen meals} => {whole milk}                                   
##  [33] {hard cheese} => {yogurt}                                        
##  [34] {hard cheese} => {other vegetables}                              
##  [35] {hard cheese} => {whole milk}                                    
##  [36] {butter milk} => {yogurt}                                        
##  [37] {butter milk} => {rolls/buns}                                    
##  [38] {butter milk} => {other vegetables}                              
##  [39] {butter milk} => {whole milk}                                    
##  [40] {candy} => {soda}                                                
##  [41] {candy} => {whole milk}                                          
##  [42] {ham} => {yogurt}                                                
##  [43] {ham} => {rolls/buns}                                            
##  [44] {ham} => {other vegetables}                                      
##  [45] {ham} => {whole milk}                                            
##  [46] {sliced cheese} => {sausage}                                     
##  [47] {sliced cheese} => {yogurt}                                      
##  [48] {sliced cheese} => {rolls/buns}                                  
##  [49] {sliced cheese} => {other vegetables}                            
##  [50] {sliced cheese} => {whole milk}                                  
##  [51] {oil} => {root vegetables}                                       
##  [52] {oil} => {other vegetables}                                      
##  [53] {oil} => {whole milk}                                            
##  [54] {onions} => {root vegetables}                                    
##  [55] {onions} => {other vegetables}                                   
##  [56] {onions} => {whole milk}                                         
##  [57] {berries} => {whipped/sour cream}                                
##  [58] {berries} => {yogurt}                                            
##  [59] {berries} => {other vegetables}                                  
##  [60] {berries} => {whole milk}                                        
##  [61] {hamburger meat} => {rolls/buns}                                 
##  [62] {hamburger meat} => {other vegetables}                           
##  [63] {hamburger meat} => {whole milk}                                 
##  [64] {hygiene articles} => {other vegetables}                         
##  [65] {hygiene articles} => {whole milk}                               
##  [66] {salty snack} => {other vegetables}                              
##  [67] {salty snack} => {whole milk}                                    
##  [68] {sugar} => {other vegetables}                                    
##  [69] {sugar} => {whole milk}                                          
##  [70] {waffles} => {other vegetables}                                  
##  [71] {waffles} => {whole milk}                                        
##  [72] {long life bakery product} => {other vegetables}                 
##  [73] {long life bakery product} => {whole milk}                       
##  [74] {dessert} => {soda}                                              
##  [75] {dessert} => {yogurt}                                            
##  [76] {dessert} => {other vegetables}                                  
##  [77] {dessert} => {whole milk}                                        
##  [78] {cream cheese} => {yogurt}                                       
##  [79] {cream cheese} => {rolls/buns}                                   
##  [80] {cream cheese} => {other vegetables}                             
##  [81] {cream cheese} => {whole milk}                                   
##  [82] {chicken} => {root vegetables}                                   
##  [83] {chicken} => {other vegetables}                                  
##  [84] {chicken} => {whole milk}                                        
##  [85] {white bread} => {other vegetables}                              
##  [86] {white bread} => {whole milk}                                    
##  [87] {chocolate} => {soda}                                            
##  [88] {chocolate} => {other vegetables}                                
##  [89] {chocolate} => {whole milk}                                      
##  [90] {coffee} => {whole milk}                                         
##  [91] {frozen vegetables} => {yogurt}                                  
##  [92] {frozen vegetables} => {other vegetables}                        
##  [93] {frozen vegetables} => {whole milk}                              
##  [94] {beef} => {root vegetables}                                      
##  [95] {beef} => {rolls/buns}                                           
##  [96] {beef} => {other vegetables}                                     
##  [97] {beef} => {whole milk}                                           
##  [98] {curd} => {yogurt}                                               
##  [99] {curd} => {other vegetables}                                     
## [100] {curd} => {whole milk}                                           
## [101] {napkins} => {other vegetables}                                  
## [102] {napkins} => {whole milk}                                        
## [103] {pork} => {other vegetables}                                     
## [104] {pork} => {whole milk}                                           
## [105] {frankfurter} => {rolls/buns}                                    
## [106] {frankfurter} => {other vegetables}                              
## [107] {frankfurter} => {whole milk}                                    
## [108] {bottled beer} => {whole milk}                                   
## [109] {brown bread} => {other vegetables}                              
## [110] {brown bread} => {whole milk}                                    
## [111] {margarine} => {rolls/buns}                                      
## [112] {margarine} => {other vegetables}                                
## [113] {margarine} => {whole milk}                                      
## [114] {butter} => {yogurt}                                             
## [115] {butter} => {other vegetables}                                   
## [116] {butter} => {whole milk}                                         
## [117] {newspapers} => {whole milk}                                     
## [118] {domestic eggs} => {other vegetables}                            
## [119] {domestic eggs} => {whole milk}                                  
## [120] {fruit/vegetable juice} => {soda}                                
## [121] {fruit/vegetable juice} => {yogurt}                              
## [122] {fruit/vegetable juice} => {other vegetables}                    
## [123] {fruit/vegetable juice} => {whole milk}                          
## [124] {whipped/sour cream} => {yogurt}                                 
## [125] {whipped/sour cream} => {other vegetables}                       
## [126] {whipped/sour cream} => {whole milk}                             
## [127] {pip fruit} => {tropical fruit}                                  
## [128] {pip fruit} => {other vegetables}                                
## [129] {pip fruit} => {whole milk}                                      
## [130] {pastry} => {other vegetables}                                   
## [131] {pastry} => {whole milk}                                         
## [132] {citrus fruit} => {yogurt}                                       
## [133] {citrus fruit} => {other vegetables}                             
## [134] {citrus fruit} => {whole milk}                                   
## [135] {sausage} => {soda}                                              
## [136] {sausage} => {rolls/buns}                                        
## [137] {sausage} => {other vegetables}                                  
## [138] {sausage} => {whole milk}                                        
## [139] {bottled water} => {soda}                                        
## [140] {bottled water} => {whole milk}                                  
## [141] {tropical fruit} => {yogurt}                                     
## [142] {tropical fruit} => {other vegetables}                           
## [143] {tropical fruit} => {whole milk}                                 
## [144] {root vegetables} => {other vegetables}                          
## [145] {root vegetables} => {whole milk}                                
## [146] {yogurt} => {other vegetables}                                   
## [147] {yogurt} => {whole milk}                                         
## [148] {rolls/buns} => {whole milk}                                     
## [149] {other vegetables} => {whole milk}                               
## [150] {whole milk} => {other vegetables}                               
## [151] {onions,other vegetables} => {whole milk}                        
## [152] {onions,whole milk} => {other vegetables}                        
## [153] {hamburger meat,other vegetables} => {whole milk}                
## [154] {hamburger meat,whole milk} => {other vegetables}                
## [155] {other vegetables,sugar} => {whole milk}                         
## [156] {sugar,whole milk} => {other vegetables}                         
## [157] {cream cheese,yogurt} => {whole milk}                            
## [158] {cream cheese,whole milk} => {yogurt}                            
## [159] {cream cheese,other vegetables} => {whole milk}                  
## [160] {cream cheese,whole milk} => {other vegetables}                  
## [161] {chicken,other vegetables} => {whole milk}                       
## [162] {chicken,whole milk} => {other vegetables}                       
## [163] {coffee,other vegetables} => {whole milk}                        
## [164] {coffee,whole milk} => {other vegetables}                        
## [165] {frozen vegetables,root vegetables} => {other vegetables}        
## [166] {frozen vegetables,other vegetables} => {root vegetables}        
## [167] {frozen vegetables,root vegetables} => {whole milk}              
## [168] {frozen vegetables,whole milk} => {root vegetables}              
## [169] {frozen vegetables,yogurt} => {whole milk}                       
## [170] {frozen vegetables,whole milk} => {yogurt}                       
## [171] {frozen vegetables,other vegetables} => {whole milk}             
## [172] {frozen vegetables,whole milk} => {other vegetables}             
## [173] {beef,root vegetables} => {other vegetables}                     
## [174] {beef,other vegetables} => {root vegetables}                     
## [175] {beef,root vegetables} => {whole milk}                           
## [176] {beef,whole milk} => {root vegetables}                           
## [177] {beef,yogurt} => {whole milk}                                    
## [178] {beef,whole milk} => {yogurt}                                    
## [179] {beef,rolls/buns} => {whole milk}                                
## [180] {beef,whole milk} => {rolls/buns}                                
## [181] {beef,other vegetables} => {whole milk}                          
## [182] {beef,whole milk} => {other vegetables}                          
## [183] {curd,tropical fruit} => {whole milk}                            
## [184] {curd,root vegetables} => {whole milk}                           
## [185] {curd,yogurt} => {other vegetables}                              
## [186] {curd,other vegetables} => {yogurt}                              
## [187] {curd,yogurt} => {whole milk}                                    
## [188] {curd,whole milk} => {yogurt}                                    
## [189] {curd,other vegetables} => {whole milk}                          
## [190] {curd,whole milk} => {other vegetables}                          
## [191] {napkins,yogurt} => {whole milk}                                 
## [192] {napkins,whole milk} => {yogurt}                                 
## [193] {napkins,other vegetables} => {whole milk}                       
## [194] {napkins,whole milk} => {other vegetables}                       
## [195] {pork,root vegetables} => {other vegetables}                     
## [196] {other vegetables,pork} => {root vegetables}                     
## [197] {pork,root vegetables} => {whole milk}                           
## [198] {pork,whole milk} => {root vegetables}                           
## [199] {pork,rolls/buns} => {whole milk}                                
## [200] {pork,whole milk} => {rolls/buns}                                
## [201] {other vegetables,pork} => {whole milk}                          
## [202] {pork,whole milk} => {other vegetables}                          
## [203] {frankfurter,yogurt} => {whole milk}                             
## [204] {frankfurter,whole milk} => {yogurt}                             
## [205] {frankfurter,other vegetables} => {whole milk}                   
## [206] {frankfurter,whole milk} => {other vegetables}                   
## [207] {bottled beer,bottled water} => {whole milk}                     
## [208] {bottled beer,whole milk} => {bottled water}                     
## [209] {bottled beer,other vegetables} => {whole milk}                  
## [210] {bottled beer,whole milk} => {other vegetables}                  
## [211] {brown bread,yogurt} => {whole milk}                             
## [212] {brown bread,whole milk} => {yogurt}                             
## [213] {brown bread,other vegetables} => {whole milk}                   
## [214] {brown bread,whole milk} => {other vegetables}                   
## [215] {margarine,yogurt} => {whole milk}                               
## [216] {margarine,whole milk} => {yogurt}                               
## [217] {margarine,rolls/buns} => {whole milk}                           
## [218] {margarine,whole milk} => {rolls/buns}                           
## [219] {margarine,other vegetables} => {whole milk}                     
## [220] {margarine,whole milk} => {other vegetables}                     
## [221] {butter,whipped/sour cream} => {whole milk}                      
## [222] {butter,tropical fruit} => {whole milk}                          
## [223] {butter,root vegetables} => {other vegetables}                   
## [224] {butter,other vegetables} => {root vegetables}                   
## [225] {butter,root vegetables} => {whole milk}                         
## [226] {butter,whole milk} => {root vegetables}                         
## [227] {butter,yogurt} => {other vegetables}                            
## [228] {butter,other vegetables} => {yogurt}                            
## [229] {butter,yogurt} => {whole milk}                                  
## [230] {butter,whole milk} => {yogurt}                                  
## [231] {butter,rolls/buns} => {whole milk}                              
## [232] {butter,other vegetables} => {whole milk}                        
## [233] {butter,whole milk} => {other vegetables}                        
## [234] {newspapers,yogurt} => {whole milk}                              
## [235] {newspapers,rolls/buns} => {whole milk}                          
## [236] {newspapers,whole milk} => {rolls/buns}                          
## [237] {newspapers,other vegetables} => {whole milk}                    
## [238] {newspapers,whole milk} => {other vegetables}                    
## [239] {domestic eggs,tropical fruit} => {whole milk}                   
## [240] {domestic eggs,root vegetables} => {other vegetables}            
## [241] {domestic eggs,other vegetables} => {root vegetables}            
## [242] {domestic eggs,root vegetables} => {whole milk}                  
## [243] {domestic eggs,whole milk} => {root vegetables}                  
## [244] {domestic eggs,yogurt} => {whole milk}                           
## [245] {domestic eggs,whole milk} => {yogurt}                           
## [246] {domestic eggs,rolls/buns} => {whole milk}                       
## [247] {domestic eggs,other vegetables} => {whole milk}                 
## [248] {domestic eggs,whole milk} => {other vegetables}                 
## [249] {fruit/vegetable juice,tropical fruit} => {other vegetables}     
## [250] {fruit/vegetable juice,other vegetables} => {tropical fruit}     
## [251] {fruit/vegetable juice,root vegetables} => {other vegetables}    
## [252] {fruit/vegetable juice,other vegetables} => {root vegetables}    
## [253] {fruit/vegetable juice,root vegetables} => {whole milk}          
## [254] {fruit/vegetable juice,soda} => {whole milk}                     
## [255] {fruit/vegetable juice,yogurt} => {other vegetables}             
## [256] {fruit/vegetable juice,other vegetables} => {yogurt}             
## [257] {fruit/vegetable juice,yogurt} => {whole milk}                   
## [258] {fruit/vegetable juice,whole milk} => {yogurt}                   
## [259] {fruit/vegetable juice,other vegetables} => {whole milk}         
## [260] {fruit/vegetable juice,whole milk} => {other vegetables}         
## [261] {citrus fruit,whipped/sour cream} => {whole milk}                
## [262] {tropical fruit,whipped/sour cream} => {yogurt}                  
## [263] {whipped/sour cream,yogurt} => {tropical fruit}                  
## [264] {tropical fruit,whipped/sour cream} => {other vegetables}        
## [265] {other vegetables,whipped/sour cream} => {tropical fruit}        
## [266] {tropical fruit,whipped/sour cream} => {whole milk}              
## [267] {root vegetables,whipped/sour cream} => {yogurt}                 
## [268] {whipped/sour cream,yogurt} => {root vegetables}                 
## [269] {root vegetables,whipped/sour cream} => {other vegetables}       
## [270] {other vegetables,whipped/sour cream} => {root vegetables}       
## [271] {root vegetables,whipped/sour cream} => {whole milk}             
## [272] {whipped/sour cream,whole milk} => {root vegetables}             
## [273] {whipped/sour cream,yogurt} => {other vegetables}                
## [274] {other vegetables,whipped/sour cream} => {yogurt}                
## [275] {whipped/sour cream,yogurt} => {whole milk}                      
## [276] {whipped/sour cream,whole milk} => {yogurt}                      
## [277] {rolls/buns,whipped/sour cream} => {other vegetables}            
## [278] {rolls/buns,whipped/sour cream} => {whole milk}                  
## [279] {other vegetables,whipped/sour cream} => {whole milk}            
## [280] {whipped/sour cream,whole milk} => {other vegetables}            
## [281] {pip fruit,tropical fruit} => {yogurt}                           
## [282] {pip fruit,yogurt} => {tropical fruit}                           
## [283] {pip fruit,tropical fruit} => {other vegetables}                 
## [284] {other vegetables,pip fruit} => {tropical fruit}                 
## [285] {other vegetables,tropical fruit} => {pip fruit}                 
## [286] {pip fruit,tropical fruit} => {whole milk}                       
## [287] {pip fruit,whole milk} => {tropical fruit}                       
## [288] {pip fruit,root vegetables} => {other vegetables}                
## [289] {other vegetables,pip fruit} => {root vegetables}                
## [290] {pip fruit,root vegetables} => {whole milk}                      
## [291] {pip fruit,whole milk} => {root vegetables}                      
## [292] {pip fruit,yogurt} => {other vegetables}                         
## [293] {other vegetables,pip fruit} => {yogurt}                         
## [294] {pip fruit,yogurt} => {whole milk}                               
## [295] {pip fruit,whole milk} => {yogurt}                               
## [296] {pip fruit,rolls/buns} => {whole milk}                           
## [297] {other vegetables,pip fruit} => {whole milk}                     
## [298] {pip fruit,whole milk} => {other vegetables}                     
## [299] {pastry,tropical fruit} => {whole milk}                          
## [300] {pastry,soda} => {whole milk}                                    
## [301] {pastry,yogurt} => {other vegetables}                            
## [302] {other vegetables,pastry} => {yogurt}                            
## [303] {pastry,yogurt} => {whole milk}                                  
## [304] {pastry,whole milk} => {yogurt}                                  
## [305] {pastry,rolls/buns} => {other vegetables}                        
## [306] {other vegetables,pastry} => {rolls/buns}                        
## [307] {pastry,rolls/buns} => {whole milk}                              
## [308] {pastry,whole milk} => {rolls/buns}                              
## [309] {other vegetables,pastry} => {whole milk}                        
## [310] {pastry,whole milk} => {other vegetables}                        
## [311] {citrus fruit,tropical fruit} => {yogurt}                        
## [312] {citrus fruit,yogurt} => {tropical fruit}                        
## [313] {citrus fruit,tropical fruit} => {other vegetables}              
## [314] {citrus fruit,other vegetables} => {tropical fruit}              
## [315] {other vegetables,tropical fruit} => {citrus fruit}              
## [316] {citrus fruit,tropical fruit} => {whole milk}                    
## [317] {citrus fruit,whole milk} => {tropical fruit}                    
## [318] {citrus fruit,root vegetables} => {other vegetables}             
## [319] {citrus fruit,other vegetables} => {root vegetables}             
## [320] {citrus fruit,root vegetables} => {whole milk}                   
## [321] {citrus fruit,whole milk} => {root vegetables}                   
## [322] {citrus fruit,yogurt} => {other vegetables}                      
## [323] {citrus fruit,other vegetables} => {yogurt}                      
## [324] {citrus fruit,yogurt} => {whole milk}                            
## [325] {citrus fruit,whole milk} => {yogurt}                            
## [326] {citrus fruit,rolls/buns} => {whole milk}                        
## [327] {citrus fruit,other vegetables} => {whole milk}                  
## [328] {citrus fruit,whole milk} => {other vegetables}                  
## [329] {root vegetables,shopping bags} => {other vegetables}            
## [330] {other vegetables,shopping bags} => {root vegetables}            
## [331] {shopping bags,soda} => {rolls/buns}                             
## [332] {rolls/buns,shopping bags} => {soda}                             
## [333] {shopping bags,soda} => {whole milk}                             
## [334] {shopping bags,whole milk} => {soda}                             
## [335] {other vegetables,shopping bags} => {whole milk}                 
## [336] {shopping bags,whole milk} => {other vegetables}                 
## [337] {sausage,tropical fruit} => {whole milk}                         
## [338] {root vegetables,sausage} => {other vegetables}                  
## [339] {other vegetables,sausage} => {root vegetables}                  
## [340] {root vegetables,sausage} => {whole milk}                        
## [341] {sausage,whole milk} => {root vegetables}                        
## [342] {sausage,soda} => {rolls/buns}                                   
## [343] {rolls/buns,sausage} => {soda}                                   
## [344] {rolls/buns,soda} => {sausage}                                   
## [345] {sausage,soda} => {other vegetables}                             
## [346] {other vegetables,sausage} => {soda}                             
## [347] {sausage,soda} => {whole milk}                                   
## [348] {sausage,yogurt} => {other vegetables}                           
## [349] {other vegetables,sausage} => {yogurt}                           
## [350] {sausage,yogurt} => {whole milk}                                 
## [351] {sausage,whole milk} => {yogurt}                                 
## [352] {rolls/buns,sausage} => {other vegetables}                       
## [353] {other vegetables,sausage} => {rolls/buns}                       
## [354] {rolls/buns,sausage} => {whole milk}                             
## [355] {sausage,whole milk} => {rolls/buns}                             
## [356] {other vegetables,sausage} => {whole milk}                       
## [357] {sausage,whole milk} => {other vegetables}                       
## [358] {bottled water,tropical fruit} => {yogurt}                       
## [359] {bottled water,yogurt} => {tropical fruit}                       
## [360] {bottled water,tropical fruit} => {other vegetables}             
## [361] {bottled water,other vegetables} => {tropical fruit}             
## [362] {bottled water,tropical fruit} => {whole milk}                   
## [363] {bottled water,root vegetables} => {other vegetables}            
## [364] {bottled water,other vegetables} => {root vegetables}            
## [365] {bottled water,root vegetables} => {whole milk}                  
## [366] {bottled water,soda} => {yogurt}                                 
## [367] {bottled water,yogurt} => {soda}                                 
## [368] {soda,yogurt} => {bottled water}                                 
## [369] {bottled water,rolls/buns} => {soda}                             
## [370] {bottled water,soda} => {whole milk}                             
## [371] {bottled water,yogurt} => {rolls/buns}                           
## [372] {bottled water,rolls/buns} => {yogurt}                           
## [373] {bottled water,yogurt} => {other vegetables}                     
## [374] {bottled water,other vegetables} => {yogurt}                     
## [375] {bottled water,yogurt} => {whole milk}                           
## [376] {bottled water,whole milk} => {yogurt}                           
## [377] {bottled water,rolls/buns} => {other vegetables}                 
## [378] {bottled water,other vegetables} => {rolls/buns}                 
## [379] {bottled water,rolls/buns} => {whole milk}                       
## [380] {bottled water,whole milk} => {rolls/buns}                       
## [381] {bottled water,other vegetables} => {whole milk}                 
## [382] {bottled water,whole milk} => {other vegetables}                 
## [383] {root vegetables,tropical fruit} => {yogurt}                     
## [384] {tropical fruit,yogurt} => {root vegetables}                     
## [385] {root vegetables,yogurt} => {tropical fruit}                     
## [386] {root vegetables,tropical fruit} => {other vegetables}           
## [387] {other vegetables,tropical fruit} => {root vegetables}           
## [388] {other vegetables,root vegetables} => {tropical fruit}           
## [389] {root vegetables,tropical fruit} => {whole milk}                 
## [390] {tropical fruit,whole milk} => {root vegetables}                 
## [391] {soda,tropical fruit} => {yogurt}                                
## [392] {soda,tropical fruit} => {other vegetables}                      
## [393] {soda,tropical fruit} => {whole milk}                            
## [394] {tropical fruit,yogurt} => {rolls/buns}                          
## [395] {rolls/buns,tropical fruit} => {yogurt}                          
## [396] {rolls/buns,yogurt} => {tropical fruit}                          
## [397] {tropical fruit,yogurt} => {other vegetables}                    
## [398] {other vegetables,tropical fruit} => {yogurt}                    
## [399] {other vegetables,yogurt} => {tropical fruit}                    
## [400] {tropical fruit,yogurt} => {whole milk}                          
## [401] {tropical fruit,whole milk} => {yogurt}                          
## [402] {whole milk,yogurt} => {tropical fruit}                          
## [403] {rolls/buns,tropical fruit} => {other vegetables}                
## [404] {rolls/buns,tropical fruit} => {whole milk}                      
## [405] {tropical fruit,whole milk} => {rolls/buns}                      
## [406] {other vegetables,tropical fruit} => {whole milk}                
## [407] {tropical fruit,whole milk} => {other vegetables}                
## [408] {root vegetables,soda} => {other vegetables}                     
## [409] {other vegetables,soda} => {root vegetables}                     
## [410] {root vegetables,soda} => {whole milk}                           
## [411] {root vegetables,yogurt} => {rolls/buns}                         
## [412] {rolls/buns,root vegetables} => {yogurt}                         
## [413] {root vegetables,yogurt} => {other vegetables}                   
## [414] {other vegetables,root vegetables} => {yogurt}                   
## [415] {other vegetables,yogurt} => {root vegetables}                   
## [416] {root vegetables,yogurt} => {whole milk}                         
## [417] {root vegetables,whole milk} => {yogurt}                         
## [418] {whole milk,yogurt} => {root vegetables}                         
## [419] {rolls/buns,root vegetables} => {other vegetables}               
## [420] {other vegetables,root vegetables} => {rolls/buns}               
## [421] {other vegetables,rolls/buns} => {root vegetables}               
## [422] {rolls/buns,root vegetables} => {whole milk}                     
## [423] {root vegetables,whole milk} => {rolls/buns}                     
## [424] {other vegetables,root vegetables} => {whole milk}               
## [425] {root vegetables,whole milk} => {other vegetables}               
## [426] {other vegetables,whole milk} => {root vegetables}               
## [427] {soda,yogurt} => {rolls/buns}                                    
## [428] {rolls/buns,yogurt} => {soda}                                    
## [429] {soda,yogurt} => {other vegetables}                              
## [430] {other vegetables,soda} => {yogurt}                              
## [431] {soda,yogurt} => {whole milk}                                    
## [432] {soda,whole milk} => {yogurt}                                    
## [433] {rolls/buns,soda} => {other vegetables}                          
## [434] {other vegetables,soda} => {rolls/buns}                          
## [435] {other vegetables,soda} => {whole milk}                          
## [436] {soda,whole milk} => {other vegetables}                          
## [437] {rolls/buns,yogurt} => {other vegetables}                        
## [438] {other vegetables,yogurt} => {rolls/buns}                        
## [439] {other vegetables,rolls/buns} => {yogurt}                        
## [440] {rolls/buns,yogurt} => {whole milk}                              
## [441] {whole milk,yogurt} => {rolls/buns}                              
## [442] {rolls/buns,whole milk} => {yogurt}                              
## [443] {other vegetables,yogurt} => {whole milk}                        
## [444] {whole milk,yogurt} => {other vegetables}                        
## [445] {other vegetables,whole milk} => {yogurt}                        
## [446] {other vegetables,rolls/buns} => {whole milk}                    
## [447] {rolls/buns,whole milk} => {other vegetables}                    
## [448] {other vegetables,root vegetables,tropical fruit} => {whole milk}
## [449] {root vegetables,tropical fruit,whole milk} => {other vegetables}
## [450] {other vegetables,tropical fruit,whole milk} => {root vegetables}
## [451] {other vegetables,root vegetables,whole milk} => {tropical fruit}
## [452] {other vegetables,tropical fruit,yogurt} => {whole milk}         
## [453] {tropical fruit,whole milk,yogurt} => {other vegetables}         
## [454] {other vegetables,tropical fruit,whole milk} => {yogurt}         
## [455] {other vegetables,whole milk,yogurt} => {tropical fruit}         
## [456] {other vegetables,root vegetables,yogurt} => {whole milk}        
## [457] {root vegetables,whole milk,yogurt} => {other vegetables}        
## [458] {other vegetables,root vegetables,whole milk} => {yogurt}        
## [459] {other vegetables,whole milk,yogurt} => {root vegetables}        
## [460] {other vegetables,rolls/buns,root vegetables} => {whole milk}    
## [461] {rolls/buns,root vegetables,whole milk} => {other vegetables}    
## [462] {other vegetables,root vegetables,whole milk} => {rolls/buns}    
## [463] {other vegetables,rolls/buns,whole milk} => {root vegetables}    
## 463 Levels: {baking powder} => {other vegetables} ...

One solution to the Big Data problem are the association rules. Without the prior knowledge of which data patterns it needs to look for, apriori algorithm as an unsupervised learning algorithm can extract information out of a large dataset. It has reduced big chunk of information into insightful set of results. Several wealth of association patterns are found which can be used by the retailer to organize market campaigns to improve their sales. The same methods applied here can be used at much larger databases to target bigger chunks of market.