Background

Pada Latihan ini kita akan membuat association rules dari data yang digunakan diambil dari Weka dataset. Dataset dapat diakses pada data/supermarket.csv. supermarket.csv merupakan dataset yang berisi daftar pembelian barang setiap transaksinya.

Data Preparation

Objek supermarket memiliki 2 column : TID dan Name.

##       TID                    name      
##  Min.   :   1   bread and cake : 3330  
##  1st Qu.:1162   fruit          : 2962  
##  Median :2324   vegetables     : 2961  
##  Mean   :2317   milk cream     : 2939  
##  3rd Qu.:3476   baking needs   : 2795  
##  Max.   :4627   frozen foods   : 2717  
##                 (Other)        :61922

Objek supermarket ada 79626 observasi

## 'data.frame':    79626 obs. of  2 variables:
##  $ TID : int  1 1 1 1 1 1 1 1 1 1 ...
##  $ name: Factor w/ 100 levels "750ml red imp ",..: 5 11 7 53 10 16 23 24 85 27 ...

Exploratory Analysis

Jawaban : bread and cake adalah barang yang paling sering di beli, sebanyak 3,330.

Jawaban : ini daftar banyak barang yang dibeli setiap transaksi, dengan TID = 1285, memiliki jumlah barang yang dibeli paling banyak, sebanyak 47.

Build Rules

## 'data.frame':    79626 obs. of  2 variables:
##  $ TID : int  1 1 1 1 1 1 1 1 1 1 ...
##  $ name: Factor w/ 100 levels "750ml red imp ",..: 5 11 7 53 10 16 23 24 85 27 ...
## $`1`
##  [1] baby needs         bread and cake     baking needs       juice sat cord ms 
##  [5] biscuits           canned vegetables  cleaners polishers coffee            
##  [9] sauces gravy pkle  confectionary      dishcloths scour   frozen foods      
## [13] razor blades       party snack foods  tissues paper prd  wrapping          
## [17] mens toiletries    cheese             milk cream         margarine         
## [21] small goods        fruit              vegetables         750ml white nz    
## 100 Levels: 750ml red imp  750ml red nz  750ml white imp  ... wrapping
## 
## $`2`
##  [1] canned fish meat   canned fruit       canned vegetables  sauces gravy pkle 
##  [5] deod disinfectant  frozen foods       pet foods          laundry needs     
##  [9] tissues paper prd  deodorants soap    haircare           milk cream        
## [13] fruit              vegetables        
## 100 Levels: 750ml red imp  750ml red nz  750ml white imp  ... wrapping
## 
## $`3`
##  [1] bread and cake     baking needs       juice sat cord ms  biscuits          
##  [5] canned fruit       sauces gravy pkle  puddings deserts   wrapping          
##  [9] health food other  small goods        dairy foods        beef              
## [13] lamb               fruit              vegetables         stationary        
## 100 Levels: 750ml red imp  750ml red nz  750ml white imp  ... wrapping
##     items                transactionID
## [1] {750ml white nz ,                 
##      baby needs ,                     
##      baking needs ,                   
##      biscuits,                        
##      bread and cake ,                 
##      canned vegetables ,              
##      cheese,                          
##      cleaners polishers,              
##      coffee,                          
##      confectionary,                   
##      dishcloths scour,                
##      frozen foods ,                   
##      fruit,                           
##      juice sat cord ms,               
##      margarine,                       
##      mens toiletries ,                
##      milk cream,                      
##      party snack foods ,              
##      razor blades ,                   
##      sauces gravy pkle,               
##      small goods ,                    
##      tissues paper prd ,              
##      vegetables,                      
##      wrapping}                       1
## [2] {canned fish meat ,               
##      canned fruit ,                   
##      canned vegetables ,              
##      deod disinfectant,               
##      deodorants soap,                 
##      frozen foods ,                   
##      fruit,                           
##      haircare,                        
##      laundry needs ,                  
##      milk cream,                      
##      pet foods ,                      
##      sauces gravy pkle,               
##      tissues paper prd ,              
##      vegetables}                     2
## [3] {baking needs ,                   
##      beef,                            
##      biscuits,                        
##      bread and cake ,                 
##      canned fruit ,                   
##      dairy foods ,                    
##      fruit,                           
##      health food other ,              
##      juice sat cord ms,               
##      lamb,                            
##      puddings deserts,                
##      sauces gravy pkle,               
##      small goods ,                    
##      stationary,                      
##      vegetables,                      
##      wrapping}                       3
## [1]  100 4601
## Apriori
## 
## Parameter specification:
##  confidence minval smax arem  aval originalSupport maxtime support minlen
##        0.75    0.1    1 none FALSE            TRUE       5     0.1      1
##  maxlen target  ext
##      10  rules TRUE
## 
## Algorithmic control:
##  filter tree heap memopt load sort verbose
##     0.1 TRUE TRUE  FALSE TRUE    2    TRUE
## 
## Absolute minimum support count: 460 
## 
## set item appearances ...[0 item(s)] done [0.00s].
## set transactions ...[100 item(s), 4601 transaction(s)] done [0.01s].
## sorting and recoding items ... [47 item(s)] done [0.00s].
## creating transaction tree ... done [0.00s].
## checking subsets of size 1 2 3 4 5 6 7 done [0.06s].
## writing ... [9958 rule(s)] done [0.00s].
## creating S4 object  ... done [0.00s].

Jawaban: Dihasilkan 9,958 rules, dengan perincian: rule dengan 2 item , sebanyak 41 rules rule dengan 3 item , sebanyak 720 rules rule dengan 4 item, sebanyak 3,440 rules rule dengan 5 item, sebanyak 4,367 rules rule dengan 6 item, sebanyak 1,320 rules rule dengan 7 item, sebanyak 70 rules.

## set of 9958 rules
## 
## rule length distribution (lhs + rhs):sizes
##    2    3    4    5    6    7 
##   41  720 3440 4367 1320   70 
## 
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   2.000   4.000   5.000   4.644   5.000   7.000 
## 
## summary of quality measures:
##     support         confidence        coverage           lift      
##  Min.   :0.1002   Min.   :0.7500   Min.   :0.1098   Min.   :1.042  
##  1st Qu.:0.1067   1st Qu.:0.7716   1st Qu.:0.1324   1st Qu.:1.196  
##  Median :0.1161   Median :0.7995   Median :0.1452   Median :1.252  
##  Mean   :0.1259   Mean   :0.8080   Mean   :0.1563   Mean   :1.260  
##  3rd Qu.:0.1332   3rd Qu.:0.8408   3rd Qu.:0.1674   3rd Qu.:1.313  
##  Max.   :0.5079   Max.   :0.9205   Max.   :0.6438   Max.   :1.594  
##      count       
##  Min.   : 461.0  
##  1st Qu.: 491.0  
##  Median : 534.0  
##  Mean   : 579.2  
##  3rd Qu.: 613.0  
##  Max.   :2337.0  
## 
## mining info:
##                     data ntransactions support confidence
##  supermarket_transaction          4601     0.1       0.75

Rules Interpretation

##     lhs                    rhs                    support confidence  coverage     lift count
## [1] {baking needs ,                                                                          
##      biscuits,                                                                               
##      bread and cake ,                                                                        
##      juice sat cord ms,                                                                      
##      sauces gravy pkle} => {party snack foods } 0.1010650  0.8072917 0.1251902 1.594141   465
## [2] {laundry needs ,                                                                         
##      wrapping}          => {tissues paper prd } 0.1038905  0.7697262 0.1349707 1.576106   478
## [3] {biscuits,                                                                               
##      bread and cake ,                                                                        
##      frozen foods ,                                                                          
##      juice sat cord ms,                                                                      
##      sauces gravy pkle} => {party snack foods } 0.1056292  0.7928222 0.1332319 1.565569   486

Interpretasi: rule dengan 5 item {baking needs ,
biscuits,
bread and cake ,
juice sat cord ms,
sauces gravy pkle} => {party snack foods } meningkatkan peluang pembelian {party snack foods }PALING TINGGI.

##     lhs                rhs                 support confidence  coverage     lift count
## [1] {biscuits,                                                                        
##      frozen foods ,                                                                   
##      milk cream,                                                                      
##      pet foods ,                                                                      
##      vegetables}    => {bread and cake } 0.1032384  0.9205426 0.1121495 1.271897   475
## [2] {baking needs ,                                                                   
##      biscuits,                                                                        
##      fruit,                                                                           
##      margarine,                                                                       
##      milk cream,                                                                      
##      vegetables}    => {bread and cake } 0.1008476  0.9188119 0.1097587 1.269506   464
## [3] {biscuits,                                                                        
##      frozen foods ,                                                                   
##      margarine,                                                                       
##      milk cream,                                                                      
##      vegetables}    => {bread and cake } 0.1167138  0.9179487 0.1271463 1.268313   537

Interpretasi: rule {biscuits,
frozen foods ,
milk cream,
pet foods ,
vegetables} => {bread and cake } memiliki nilai confidence PALING TINGGI 0.9205426, yang mana pembelian biscuits,frozen foods ,milk cream, pet foods , vegetables, memiliki kemungkinan 92,05% untuk pembelian bread and cake.

Interpretasi: rule 8807 {baking needs ,
biscuits,
bread and cake ,
juice sat cord ms,
sauces gravy pkle} => {party snack foods } memiliki lift paling tinggi 1.59

Interpretasi: dari lingkaran merah yang terbesar menandakan party snack foods yang banyak di beli

Kesimpulan: 1. Party Snack Foods adalah item yang PALING BANYAK di beli. tissues paper prd merupakan item KEDUA PALING BANYAK di beli. 2. Pembelian item2 ini : {biscuits,frozen foods , milk cream, pet foods , vegetables} meningkatkan peluang pembeliaan Party Snack Foods.