library(mlbench)
## Warning: package 'mlbench' was built under R version 4.2.1
library(readr)
library(data.table)
library(stats)
library(arules)
## Warning: package 'arules' was built under R version 4.2.1
## Loading required package: Matrix
##
## Attaching package: 'arules'
## The following objects are masked from 'package:base':
##
## abbreviate, write
library(arulesViz)
## Warning: package 'arulesViz' was built under R version 4.2.1
library(kernlab)
##
## Attaching package: 'kernlab'
## The following object is masked from 'package:arules':
##
## size
data(Groceries)
myrules <- apriori(data = Groceries, parameter=list(support=0.1, confidence=0.8, minlen=1))
## Apriori
##
## Parameter specification:
## confidence minval smax arem aval originalSupport maxtime support minlen
## 0.8 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: 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].
inspect(myrules)
summary(myrules)
## set of 0 rules
To see the proportion of transactions that contain the item
itemFrequency(Groceries [ , 1:5])
## frankfurter sausage liver loaf ham meat
## 0.058973055 0.093950178 0.005083884 0.026029487 0.025826131
Check and visualize the most frequent Items - item frequency
plots:
frequent_items <- eclat(Groceries, parameter = list(support = 0.7, minlen = 4))
## Eclat
##
## parameter specification:
## tidLists support minlen maxlen target ext
## FALSE 0.7 4 10 frequent itemsets TRUE
##
## algorithmic control:
## sparse sort verbose
## 7 -2 TRUE
##
## Absolute minimum support count: 6884
##
## eclat - zero frequent items
inspect(head(frequent_items, 2))
itemFrequencyPlot(Groceries, topN = 20, type = "absolute", main = "Item frequency")

Remove Redundant Rules (by confidence)
groceryrules <- sort(groceryrules, by = "confidence", decreasing = TRUE)
inspect(groceryrules)
## lhs rhs support confidence coverage lift count
## [1] {citrus fruit,
## root vegetables} => {other vegetables} 0.01037112 0.5862069 0.01769192 3.0296084 102
## [2] {tropical fruit,
## root vegetables} => {other vegetables} 0.01230300 0.5845411 0.02104728 3.0209991 121
## [3] {curd,
## yogurt} => {whole milk} 0.01006609 0.5823529 0.01728521 2.2791250 99
## [4] {other vegetables,
## butter} => {whole milk} 0.01148958 0.5736041 0.02003050 2.2448850 113
## [5] {tropical fruit,
## root vegetables} => {whole milk} 0.01199797 0.5700483 0.02104728 2.2309690 118
## [6] {root vegetables,
## yogurt} => {whole milk} 0.01453991 0.5629921 0.02582613 2.2033536 143
## [7] {other vegetables,
## domestic eggs} => {whole milk} 0.01230300 0.5525114 0.02226741 2.1623358 121
## [8] {yogurt,
## whipped/sour cream} => {whole milk} 0.01087951 0.5245098 0.02074225 2.0527473 107
## [9] {root vegetables,
## rolls/buns} => {whole milk} 0.01270971 0.5230126 0.02430097 2.0468876 125
## [10] {pip fruit,
## other vegetables} => {whole milk} 0.01352313 0.5175097 0.02613116 2.0253514 133
## [11] {tropical fruit,
## yogurt} => {whole milk} 0.01514997 0.5173611 0.02928317 2.0247698 149
## [12] {other vegetables,
## yogurt} => {whole milk} 0.02226741 0.5128806 0.04341637 2.0072345 219
## [13] {other vegetables,
## whipped/sour cream} => {whole milk} 0.01464159 0.5070423 0.02887646 1.9843854 144
## [14] {root vegetables,
## rolls/buns} => {other vegetables} 0.01220132 0.5020921 0.02430097 2.5948898 120
## [15] {root vegetables,
## yogurt} => {other vegetables} 0.01291307 0.5000000 0.02582613 2.5840778 127
## [16] {other vegetables,
## fruit/vegetable juice} => {whole milk} 0.01047280 0.4975845 0.02104728 1.9473713 103
## [17] {butter} => {whole milk} 0.02755465 0.4972477 0.05541434 1.9460530 271
## [18] {curd} => {whole milk} 0.02613116 0.4904580 0.05327911 1.9194805 257
## [19] {yogurt,
## whipped/sour cream} => {other vegetables} 0.01016777 0.4901961 0.02074225 2.5334096 100
## [20] {root vegetables,
## other vegetables} => {whole milk} 0.02318251 0.4892704 0.04738180 1.9148326 228
## [21] {tropical fruit,
## other vegetables} => {whole milk} 0.01708185 0.4759207 0.03589222 1.8625865 168
## [22] {citrus fruit,
## yogurt} => {whole milk} 0.01026945 0.4741784 0.02165735 1.8557678 101
## [23] {root vegetables,
## whole milk} => {other vegetables} 0.02318251 0.4740125 0.04890696 2.4497702 228
## [24] {domestic eggs} => {whole milk} 0.02999492 0.4727564 0.06344687 1.8502027 295
## [25] {pork,
## other vegetables} => {whole milk} 0.01016777 0.4694836 0.02165735 1.8373939 100
## [26] {other vegetables,
## pastry} => {whole milk} 0.01057448 0.4684685 0.02257245 1.8334212 104
## [27] {onions} => {other vegetables} 0.01423488 0.4590164 0.03101169 2.3722681 140
## [28] {pork,
## whole milk} => {other vegetables} 0.01016777 0.4587156 0.02216573 2.3707136 100
## [29] {whole milk,
## whipped/sour cream} => {other vegetables} 0.01464159 0.4542587 0.03223183 2.3476795 144
## [30] {yogurt,
## rolls/buns} => {whole milk} 0.01555669 0.4526627 0.03436706 1.7715630 153
## [31] {citrus fruit,
## other vegetables} => {whole milk} 0.01301474 0.4507042 0.02887646 1.7638982 128
## [32] {whipped/sour cream} => {whole milk} 0.03223183 0.4496454 0.07168277 1.7597542 317
## [33] {pip fruit,
## whole milk} => {other vegetables} 0.01352313 0.4493243 0.03009659 2.3221780 133
## [34] {root vegetables} => {whole milk} 0.04890696 0.4486940 0.10899847 1.7560310 481
## [35] {tropical fruit,
## rolls/buns} => {whole milk} 0.01098119 0.4462810 0.02460600 1.7465872 108
## [36] {sugar} => {whole milk} 0.01504830 0.4444444 0.03385867 1.7393996 148
## [37] {hamburger meat} => {whole milk} 0.01474326 0.4434251 0.03324860 1.7354101 145
## [38] {ham} => {whole milk} 0.01148958 0.4414062 0.02602949 1.7275091 113
## [39] {sliced cheese} => {whole milk} 0.01077783 0.4398340 0.02450432 1.7213560 106
## [40] {root vegetables} => {other vegetables} 0.04738180 0.4347015 0.10899847 2.2466049 466
## [41] {other vegetables,
## bottled water} => {whole milk} 0.01077783 0.4344262 0.02480935 1.7001918 106
## [42] {citrus fruit,
## whole milk} => {other vegetables} 0.01301474 0.4266667 0.03050330 2.2050797 128
## [43] {other vegetables,
## soda} => {whole milk} 0.01392984 0.4254658 0.03274021 1.6651240 137
## [44] {frozen vegetables} => {whole milk} 0.02043721 0.4249471 0.04809354 1.6630940 201
## [45] {tropical fruit,
## yogurt} => {other vegetables} 0.01230300 0.4201389 0.02928317 2.1713431 121
## [46] {other vegetables,
## rolls/buns} => {whole milk} 0.01789527 0.4200477 0.04260295 1.6439194 176
## [47] {chicken} => {other vegetables} 0.01789527 0.4170616 0.04290798 2.1554393 176
## [48] {whole milk,
## butter} => {other vegetables} 0.01148958 0.4169742 0.02755465 2.1549874 113
## [49] {hamburger meat} => {other vegetables} 0.01382816 0.4159021 0.03324860 2.1494470 136
## [50] {cream cheese } => {whole milk} 0.01647178 0.4153846 0.03965430 1.6256696 162
## [51] {butter milk} => {whole milk} 0.01159126 0.4145455 0.02796136 1.6223854 114
## [52] {margarine} => {whole milk} 0.02419929 0.4131944 0.05856634 1.6170980 238
## [53] {hard cheese} => {whole milk} 0.01006609 0.4107884 0.02450432 1.6076815 99
## [54] {whole milk,
## domestic eggs} => {other vegetables} 0.01230300 0.4101695 0.02999492 2.1198197 121
## [55] {chicken} => {whole milk} 0.01759024 0.4099526 0.04290798 1.6044106 173
## [56] {white bread} => {whole milk} 0.01708185 0.4057971 0.04209456 1.5881474 168
## [57] {beef} => {whole milk} 0.02125064 0.4050388 0.05246568 1.5851795 209
## [58] {tropical fruit,
## whole milk} => {other vegetables} 0.01708185 0.4038462 0.04229792 2.0871397 168
## [59] {tropical fruit} => {whole milk} 0.04229792 0.4031008 0.10493137 1.5775950 416
## [60] {whipped/sour cream} => {other vegetables} 0.02887646 0.4028369 0.07168277 2.0819237 284
## [61] {oil} => {whole milk} 0.01128622 0.4021739 0.02806304 1.5739675 111
## [62] {yogurt} => {whole milk} 0.05602440 0.4016035 0.13950178 1.5717351 551
## [63] {pip fruit} => {whole milk} 0.03009659 0.3978495 0.07564820 1.5570432 296
## [64] {whole milk,
## yogurt} => {other vegetables} 0.02226741 0.3974592 0.05602440 2.0541308 219
## [65] {whole milk,
## fruit/vegetable juice} => {other vegetables} 0.01047280 0.3931298 0.02663955 2.0317558 103
## [66] {onions} => {whole milk} 0.01209964 0.3901639 0.03101169 1.5269647 119
## [67] {hygiene articles} => {whole milk} 0.01281139 0.3888889 0.03294357 1.5219746 126
## [68] {brown bread} => {whole milk} 0.02521607 0.3887147 0.06487036 1.5212930 248
## [69] {other vegetables} => {whole milk} 0.07483477 0.3867578 0.19349263 1.5136341 736
## [70] {whole milk,
## curd} => {yogurt} 0.01006609 0.3852140 0.02613116 2.7613555 99
## [71] {pork} => {whole milk} 0.02216573 0.3844797 0.05765125 1.5047187 218
## [72] {yogurt,
## soda} => {whole milk} 0.01047280 0.3828996 0.02735130 1.4985348 103
## [73] {sausage,
## other vegetables} => {whole milk} 0.01016777 0.3773585 0.02694459 1.4768487 100
## [74] {napkins} => {whole milk} 0.01972547 0.3766990 0.05236401 1.4742678 194
## [75] {beef} => {other vegetables} 0.01972547 0.3759690 0.05246568 1.9430662 194
## [76] {pork} => {other vegetables} 0.02165735 0.3756614 0.05765125 1.9414764 213
## [77] {pastry} => {whole milk} 0.03324860 0.3737143 0.08896797 1.4625865 327
## [78] {butter milk} => {other vegetables} 0.01037112 0.3709091 0.02796136 1.9169159 102
## [79] {frozen vegetables} => {other vegetables} 0.01779359 0.3699789 0.04809354 1.9121083 175
## [80] {dessert} => {whole milk} 0.01372649 0.3698630 0.03711235 1.4475140 135
## [81] {citrus fruit} => {whole milk} 0.03050330 0.3685504 0.08276563 1.4423768 300
## [82] {fruit/vegetable juice} => {whole milk} 0.02663955 0.3684951 0.07229283 1.4421604 262
## [83] {butter} => {other vegetables} 0.02003050 0.3614679 0.05541434 1.8681223 197
## [84] {long life bakery product} => {whole milk} 0.01352313 0.3614130 0.03741739 1.4144438 133
## [85] {citrus fruit,
## other vegetables} => {root vegetables} 0.01037112 0.3591549 0.02887646 3.2950455 102
## [86] {tropical fruit,
## whole milk} => {yogurt} 0.01514997 0.3581731 0.04229792 2.5675162 149
## [87] {berries} => {whole milk} 0.01179461 0.3547401 0.03324860 1.3883281 116
## [88] {other vegetables,
## whipped/sour cream} => {yogurt} 0.01016777 0.3521127 0.02887646 2.5240730 100
## [89] {domestic eggs} => {other vegetables} 0.02226741 0.3509615 0.06344687 1.8138238 219
## [90] {citrus fruit} => {other vegetables} 0.02887646 0.3488943 0.08276563 1.8031403 284
## [91] {frankfurter} => {whole milk} 0.02053889 0.3482759 0.05897306 1.3630295 202
## [92] {whole milk,
## soda} => {other vegetables} 0.01392984 0.3477157 0.04006101 1.7970490 137
## [93] {cream cheese } => {other vegetables} 0.01372649 0.3461538 0.03965430 1.7889769 135
## [94] {pip fruit} => {other vegetables} 0.02613116 0.3454301 0.07564820 1.7852365 257
## [95] {tropical fruit,
## other vegetables} => {root vegetables} 0.01230300 0.3427762 0.03589222 3.1447798 121
## [96] {tropical fruit,
## other vegetables} => {yogurt} 0.01230300 0.3427762 0.03589222 2.4571457 121
## [97] {newspapers} => {whole milk} 0.02735130 0.3426752 0.07981698 1.3411103 269
## [98] {tropical fruit} => {other vegetables} 0.03589222 0.3420543 0.10493137 1.7677896 353
## [99] {sausage,
## whole milk} => {other vegetables} 0.01016777 0.3401361 0.02989324 1.7578760 100
## [100] {whole milk,
## whipped/sour cream} => {yogurt} 0.01087951 0.3375394 0.03223183 2.4196066 107
## [101] {margarine} => {other vegetables} 0.01972547 0.3368056 0.05856634 1.7406635 194
## [102] {citrus fruit,
## whole milk} => {yogurt} 0.01026945 0.3366667 0.03050330 2.4133503 101
## [103] {chocolate} => {whole milk} 0.01667514 0.3360656 0.04961871 1.3152427 164
## [104] {yogurt,
## rolls/buns} => {other vegetables} 0.01148958 0.3343195 0.03436706 1.7278153 113
## [105] {beef} => {root vegetables} 0.01738688 0.3313953 0.05246568 3.0403668 171
## [106] {waffles} => {whole milk} 0.01270971 0.3306878 0.03843416 1.2941961 125
## [107] {white bread} => {other vegetables} 0.01372649 0.3260870 0.04209456 1.6852681 135
## [108] {frankfurter} => {rolls/buns} 0.01921708 0.3258621 0.05897306 1.7716161 189
## [109] {sausage} => {rolls/buns} 0.03060498 0.3257576 0.09395018 1.7710480 301
## [110] {curd} => {yogurt} 0.01728521 0.3244275 0.05327911 2.3256154 170
## [111] {curd} => {other vegetables} 0.01718353 0.3225191 0.05327911 1.6668288 169
## [112] {coffee} => {whole milk} 0.01870869 0.3222417 0.05805796 1.2611408 184
## [113] {sugar} => {other vegetables} 0.01077783 0.3183183 0.03385867 1.6451186 106
## [114] {sausage} => {whole milk} 0.02989324 0.3181818 0.09395018 1.2452520 294
## [115] {berries} => {yogurt} 0.01057448 0.3180428 0.03324860 2.2798477 104
## [116] {whole milk,
## pastry} => {other vegetables} 0.01057448 0.3180428 0.03324860 1.6436947 104
## [117] {whole milk,
## rolls/buns} => {other vegetables} 0.01789527 0.3159785 0.05663447 1.6330258 176
## [118] {whole milk,
## bottled water} => {other vegetables} 0.01077783 0.3136095 0.03436706 1.6207825 106
## [119] {cream cheese } => {yogurt} 0.01240468 0.3128205 0.03965430 2.2424123 122
## [120] {dessert} => {other vegetables} 0.01159126 0.3123288 0.03711235 1.6141636 114
## [121] {yogurt} => {other vegetables} 0.04341637 0.3112245 0.13950178 1.6084566 427
## [122] {bottled water} => {whole milk} 0.03436706 0.3109476 0.11052364 1.2169396 338
## [123] {other vegetables,
## whole milk} => {root vegetables} 0.02318251 0.3097826 0.07483477 2.8420820 228
## [124] {berries} => {other vegetables} 0.01026945 0.3088685 0.03324860 1.5962805 101
## [125] {rolls/buns} => {whole milk} 0.05663447 0.3079049 0.18393493 1.2050318 557
## [126] {other vegetables,
## whole milk} => {yogurt} 0.02226741 0.2975543 0.07483477 2.1329789 219
## [127] {other vegetables,
## yogurt} => {root vegetables} 0.01291307 0.2974239 0.04341637 2.7286977 127
## [128] {root vegetables,
## whole milk} => {yogurt} 0.01453991 0.2972973 0.04890696 2.1311362 143
## [129] {salty snack} => {whole milk} 0.01118454 0.2956989 0.03782410 1.1572618 110
## [130] {whole milk} => {other vegetables} 0.07483477 0.2928770 0.25551601 1.5136341 736
## [131] {fruit/vegetable juice} => {other vegetables} 0.02104728 0.2911392 0.07229283 1.5046529 207
## [132] {whipped/sour cream} => {yogurt} 0.02074225 0.2893617 0.07168277 2.0742510 204
## [133] {brown bread} => {other vegetables} 0.01870869 0.2884013 0.06487036 1.4905025 184
## [134] {sausage} => {other vegetables} 0.02694459 0.2867965 0.09395018 1.4822091 265
## [135] {other vegetables,
## rolls/buns} => {root vegetables} 0.01220132 0.2863962 0.04260295 2.6275247 120
## [136] {long life bakery product} => {other vegetables} 0.01067616 0.2853261 0.03741739 1.4746096 105
## [137] {salty snack} => {other vegetables} 0.01077783 0.2849462 0.03782410 1.4726465 106
## [138] {tropical fruit,
## whole milk} => {root vegetables} 0.01199797 0.2836538 0.04229792 2.6023653 118
## [139] {other vegetables,
## yogurt} => {tropical fruit} 0.01230300 0.2833724 0.04341637 2.7005496 121
## [140] {frankfurter} => {other vegetables} 0.01647178 0.2793103 0.05897306 1.4435193 162
## [141] {tropical fruit} => {yogurt} 0.02928317 0.2790698 0.10493137 2.0004746 288
## [142] {whole milk,
## yogurt} => {rolls/buns} 0.01555669 0.2776770 0.05602440 1.5096478 153
## [143] {napkins} => {other vegetables} 0.01443823 0.2757282 0.05236401 1.4250060 142
## [144] {whole milk,
## rolls/buns} => {yogurt} 0.01555669 0.2746858 0.05663447 1.9690488 153
## [145] {chocolate} => {soda} 0.01352313 0.2725410 0.04961871 1.5629391 133
## [146] {root vegetables,
## other vegetables} => {yogurt} 0.01291307 0.2725322 0.04738180 1.9536108 127
## [147] {whole milk,
## yogurt} => {tropical fruit} 0.01514997 0.2704174 0.05602440 2.5770885 149
## [148] {pip fruit} => {tropical fruit} 0.02043721 0.2701613 0.07564820 2.5746476 201
## [149] {other vegetables,
## rolls/buns} => {yogurt} 0.01148958 0.2696897 0.04260295 1.9332351 113
## [150] {other vegetables,
## yogurt} => {rolls/buns} 0.01148958 0.2646370 0.04341637 1.4387534 113
## [151] {butter} => {yogurt} 0.01464159 0.2642202 0.05541434 1.8940273 144
## [152] {bottled water} => {soda} 0.02897814 0.2621895 0.11052364 1.5035766 285
## [153] {waffles} => {other vegetables} 0.01006609 0.2619048 0.03843416 1.3535645 99
## [154] {citrus fruit} => {yogurt} 0.02165735 0.2616708 0.08276563 1.8757521 213
## [155] {whole milk,
## soda} => {yogurt} 0.01047280 0.2614213 0.04006101 1.8739641 103
## [156] {root vegetables,
## whole milk} => {rolls/buns} 0.01270971 0.2598753 0.04890696 1.4128652 125
## [157] {beef} => {rolls/buns} 0.01362481 0.2596899 0.05246568 1.4118576 134
## [158] {root vegetables,
## other vegetables} => {tropical fruit} 0.01230300 0.2596567 0.04738180 2.4745380 121
## [159] {tropical fruit,
## whole milk} => {rolls/buns} 0.01098119 0.2596154 0.04229792 1.4114524 108
## [160] {whole milk,
## yogurt} => {root vegetables} 0.01453991 0.2595281 0.05602440 2.3810253 143
## [161] {fruit/vegetable juice} => {yogurt} 0.01870869 0.2587904 0.07229283 1.8551049 184
## [162] {sausage} => {soda} 0.02430097 0.2586580 0.09395018 1.4833245 239
## [163] {frozen vegetables} => {yogurt} 0.01240468 0.2579281 0.04809354 1.8489235 122
## [164] {root vegetables,
## other vegetables} => {rolls/buns} 0.01220132 0.2575107 0.04738180 1.4000100 120
## [165] {chocolate} => {other vegetables} 0.01270971 0.2561475 0.04961871 1.3238103 125
## [166] {fruit/vegetable juice} => {soda} 0.01840366 0.2545710 0.07229283 1.4598869 181
## [167] {bottled beer} => {whole milk} 0.02043721 0.2537879 0.08052872 0.9932367 201
## [168] {pastry} => {other vegetables} 0.02257245 0.2537143 0.08896797 1.3112349 222
## [169] {chicken} => {root vegetables} 0.01087951 0.2535545 0.04290798 2.3262206 107
## [170] {margarine} => {rolls/buns} 0.01474326 0.2517361 0.05856634 1.3686151 145
groceryrules.sorted = sort(groceryrules, by = "lift")
subset.matrix = is.subset(groceryrules.sorted, groceryrules.sorted)
subset.matrix[lower.tri(subset.matrix, diag = TRUE)] = NA
## Warning in `[<-`(`*tmp*`, as.vector(i), value = NA): x[.] <- val: x is
## "ngTMatrix", val not in {TRUE, FALSE} is coerced; NA |--> TRUE.
redundant = colSums(subset.matrix, na.rm = TRUE) >= 1
which(redundant)
## {citrus fruit,root vegetables,other vegetables}
## 1
## {tropical fruit,root vegetables,other vegetables}
## 2
## {beef,root vegetables}
## 3
## {citrus fruit,root vegetables,other vegetables}
## 4
## {tropical fruit,root vegetables,other vegetables}
## 5
## {root vegetables,other vegetables,whole milk}
## 6
## {whole milk,curd,yogurt}
## 7
## {root vegetables,other vegetables,yogurt}
## 8
## {tropical fruit,other vegetables,yogurt}
## 9
## {root vegetables,other vegetables,rolls/buns}
## 10
## {tropical fruit,root vegetables,whole milk}
## 11
## {root vegetables,other vegetables,rolls/buns}
## 12
## {root vegetables,other vegetables,yogurt}
## 13
## {tropical fruit,whole milk,yogurt}
## 14
## {tropical fruit,pip fruit}
## 15
## {tropical fruit,whole milk,yogurt}
## 16
## {other vegetables,yogurt,whipped/sour cream}
## 17
## {other vegetables,yogurt,whipped/sour cream}
## 18
## {tropical fruit,root vegetables,other vegetables}
## 19
## {tropical fruit,other vegetables,yogurt}
## 20
## {root vegetables,other vegetables,whole milk}
## 21
## {whole milk,yogurt,whipped/sour cream}
## 22
## {citrus fruit,whole milk,yogurt}
## 23
## {root vegetables,whole milk,yogurt}
## 24
## {onions,other vegetables}
## 25
## {pork,other vegetables,whole milk}
## 26
## {other vegetables,whole milk,whipped/sour cream}
## 27
## {chicken,root vegetables}
## 28
## {curd,yogurt}
## 29
## {pip fruit,other vegetables,whole milk}
## 30
## {berries,yogurt}
## 31
## {whole milk,curd,yogurt}
## 32
## {root vegetables,other vegetables}
## 33
## {other vegetables,whole milk,butter}
## 34
## {yogurt,cream cheese }
## 35
## {tropical fruit,root vegetables,whole milk}
## 36
## {citrus fruit,other vegetables,whole milk}
## 37
## {root vegetables,whole milk,yogurt}
## 38
## {tropical fruit,other vegetables,yogurt}
## 39
## {other vegetables,whole milk,domestic eggs}
## 40
## {chicken,other vegetables}
## 41
## {other vegetables,whole milk,butter}
## 42
## {hamburger meat,other vegetables}
## 43
## {other vegetables,whole milk,yogurt}
## 44
## {root vegetables,whole milk,yogurt}
## 45
## {other vegetables,whole milk,domestic eggs}
## 46
## {tropical fruit,other vegetables,whole milk}
## 47
## {other vegetables,whipped/sour cream}
## 48
## {yogurt,whipped/sour cream}
## 49
## {other vegetables,whole milk,yogurt}
## 50
## {whole milk,yogurt,whipped/sour cream}
## 51
## {root vegetables,whole milk,rolls/buns}
## 52
## {other vegetables,whole milk,fruit/vegetable juice}
## 53
## {pip fruit,other vegetables,whole milk}
## 54
## {tropical fruit,whole milk,yogurt}
## 55
## {other vegetables,whole milk,yogurt}
## 56
## {tropical fruit,yogurt}
## 57
## {other vegetables,whole milk,whipped/sour cream}
## 58
## {whole milk,yogurt,rolls/buns}
## 59
## {root vegetables,other vegetables,yogurt}
## 60
## {other vegetables,whole milk,fruit/vegetable juice}
## 61
## {whole milk,butter}
## 62
## {beef,other vegetables}
## 63
## {pork,other vegetables}
## 64
## {other vegetables,yogurt,rolls/buns}
## 65
## {whole milk,curd}
## 66
## {other vegetables,butter milk}
## 67
## {root vegetables,other vegetables,whole milk}
## 68
## {other vegetables,frozen vegetables}
## 69
## {butter,yogurt}
## 70
## {citrus fruit,yogurt}
## 71
## {whole milk,yogurt,soda}
## 72
## {other vegetables,butter}
## 73
## {tropical fruit,other vegetables,whole milk}
## 74
## {citrus fruit,whole milk,yogurt}
## 75
## {yogurt,fruit/vegetable juice}
## 76
## {whole milk,domestic eggs}
## 77
## {yogurt,frozen vegetables}
## 78
## {pork,other vegetables,whole milk}
## 79
## {other vegetables,whole milk,pastry}
## 80
## {other vegetables,domestic eggs}
## 81
## {citrus fruit,other vegetables}
## 82
## {other vegetables,whole milk,soda}
## 83
## {other vegetables,cream cheese }
## 84
## {pip fruit,other vegetables}
## 85
## {frankfurter,rolls/buns}
## 86
## {whole milk,yogurt,rolls/buns}
## 87
## {sausage,rolls/buns}
## 88
## {tropical fruit,other vegetables}
## 89
## {citrus fruit,other vegetables,whole milk}
## 90
## {whole milk,whipped/sour cream}
## 91
## {sausage,other vegetables,whole milk}
## 92
## {root vegetables,whole milk}
## 93
## {tropical fruit,whole milk,rolls/buns}
## 94
## {other vegetables,margarine}
## 95
## {whole milk,sugar}
## 96
## {hamburger meat,whole milk}
## 97
## {other vegetables,yogurt,rolls/buns}
## 98
## {ham,whole milk}
## 99
## {whole milk,sliced cheese}
## 100
## {other vegetables,whole milk,bottled water}
## 101
## {other vegetables,white bread}
## 102
## {other vegetables,curd}
## 103
## {other vegetables,whole milk,soda}
## 104
## {whole milk,frozen vegetables}
## 105
## {other vegetables,sugar}
## 106
## {other vegetables,whole milk,rolls/buns}
## 107
## {other vegetables,whole milk,pastry}
## 108
## {other vegetables,whole milk,rolls/buns}
## 109
## {whole milk,cream cheese }
## 110
## {whole milk,butter milk}
## 111
## {other vegetables,whole milk,bottled water}
## 112
## {whole milk,margarine}
## 113
## {other vegetables,dessert}
## 114
## {other vegetables,yogurt}
## 115
## {whole milk,hard cheese}
## 116
## {chicken,whole milk}
## 117
## {berries,other vegetables}
## 118
## {whole milk,white bread}
## 119
## {beef,whole milk}
## 120
## {tropical fruit,whole milk}
## 121
## {whole milk,oil}
## 122
## {whole milk,yogurt}
## 123
## {soda,chocolate}
## 124
## {pip fruit,whole milk}
## 125
## {onions,whole milk}
## 126
## {whole milk,hygiene articles}
## 127
## {whole milk,brown bread}
## 128
## {other vegetables,whole milk}
## 129
## {other vegetables,whole milk}
## 130
## {whole milk,yogurt,rolls/buns}
## 131
## {pork,whole milk}
## 132
## {other vegetables,fruit/vegetable juice}
## 133
## {bottled water,soda}
## 134
## {whole milk,yogurt,soda}
## 135
## {other vegetables,brown bread}
## 136
## {sausage,soda}
## 137
## {sausage,other vegetables}
## 138
## {sausage,other vegetables,whole milk}
## 139
## {other vegetables,long life bakery product}
## 140
## {whole milk,napkins}
## 141
## {other vegetables,salty snack}
## 142
## {whole milk,pastry}
## 143
## {soda,fruit/vegetable juice}
## 144
## {whole milk,dessert}
## 145
## {frankfurter,other vegetables}
## 146
## {citrus fruit,whole milk}
## 147
## {whole milk,fruit/vegetable juice}
## 148
## {other vegetables,yogurt,rolls/buns}
## 149
## {other vegetables,napkins}
## 150
## {whole milk,long life bakery product}
## 151
## {root vegetables,whole milk,rolls/buns}
## 152
## {beef,rolls/buns}
## 153
## {tropical fruit,whole milk,rolls/buns}
## 154
## {root vegetables,other vegetables,rolls/buns}
## 155
## {berries,whole milk}
## 156
## {rolls/buns,margarine}
## 157
## {frankfurter,whole milk}
## 158
## {other vegetables,waffles}
## 159
## {whole milk,newspapers}
## 160
## {other vegetables,chocolate}
## 161
## {whole milk,chocolate}
## 162
## {other vegetables,pastry}
## 163
## {whole milk,waffles}
## 164
## {whole milk,coffee}
## 165
## {sausage,whole milk}
## 166
## {whole milk,bottled water}
## 167
## {whole milk,rolls/buns}
## 168
## {whole milk,salty snack}
## 169
## {whole milk,bottled beer}
## 170
groceryrules.pruned = groceryrules.sorted[!redundant]
inspect(groceryrules.pruned)
Remove Redundant Rules (by Lift)
groceryrules <- sort(groceryrules, by = "lift", decreasing = TRUE)
inspect(groceryrules)
## lhs rhs support confidence coverage lift count
## [1] {citrus fruit,
## other vegetables} => {root vegetables} 0.01037112 0.3591549 0.02887646 3.2950455 102
## [2] {tropical fruit,
## other vegetables} => {root vegetables} 0.01230300 0.3427762 0.03589222 3.1447798 121
## [3] {beef} => {root vegetables} 0.01738688 0.3313953 0.05246568 3.0403668 171
## [4] {citrus fruit,
## root vegetables} => {other vegetables} 0.01037112 0.5862069 0.01769192 3.0296084 102
## [5] {tropical fruit,
## root vegetables} => {other vegetables} 0.01230300 0.5845411 0.02104728 3.0209991 121
## [6] {other vegetables,
## whole milk} => {root vegetables} 0.02318251 0.3097826 0.07483477 2.8420820 228
## [7] {whole milk,
## curd} => {yogurt} 0.01006609 0.3852140 0.02613116 2.7613555 99
## [8] {other vegetables,
## yogurt} => {root vegetables} 0.01291307 0.2974239 0.04341637 2.7286977 127
## [9] {other vegetables,
## yogurt} => {tropical fruit} 0.01230300 0.2833724 0.04341637 2.7005496 121
## [10] {other vegetables,
## rolls/buns} => {root vegetables} 0.01220132 0.2863962 0.04260295 2.6275247 120
## [11] {tropical fruit,
## whole milk} => {root vegetables} 0.01199797 0.2836538 0.04229792 2.6023653 118
## [12] {root vegetables,
## rolls/buns} => {other vegetables} 0.01220132 0.5020921 0.02430097 2.5948898 120
## [13] {root vegetables,
## yogurt} => {other vegetables} 0.01291307 0.5000000 0.02582613 2.5840778 127
## [14] {whole milk,
## yogurt} => {tropical fruit} 0.01514997 0.2704174 0.05602440 2.5770885 149
## [15] {pip fruit} => {tropical fruit} 0.02043721 0.2701613 0.07564820 2.5746476 201
## [16] {tropical fruit,
## whole milk} => {yogurt} 0.01514997 0.3581731 0.04229792 2.5675162 149
## [17] {yogurt,
## whipped/sour cream} => {other vegetables} 0.01016777 0.4901961 0.02074225 2.5334096 100
## [18] {other vegetables,
## whipped/sour cream} => {yogurt} 0.01016777 0.3521127 0.02887646 2.5240730 100
## [19] {root vegetables,
## other vegetables} => {tropical fruit} 0.01230300 0.2596567 0.04738180 2.4745380 121
## [20] {tropical fruit,
## other vegetables} => {yogurt} 0.01230300 0.3427762 0.03589222 2.4571457 121
## [21] {root vegetables,
## whole milk} => {other vegetables} 0.02318251 0.4740125 0.04890696 2.4497702 228
## [22] {whole milk,
## whipped/sour cream} => {yogurt} 0.01087951 0.3375394 0.03223183 2.4196066 107
## [23] {citrus fruit,
## whole milk} => {yogurt} 0.01026945 0.3366667 0.03050330 2.4133503 101
## [24] {whole milk,
## yogurt} => {root vegetables} 0.01453991 0.2595281 0.05602440 2.3810253 143
## [25] {onions} => {other vegetables} 0.01423488 0.4590164 0.03101169 2.3722681 140
## [26] {pork,
## whole milk} => {other vegetables} 0.01016777 0.4587156 0.02216573 2.3707136 100
## [27] {whole milk,
## whipped/sour cream} => {other vegetables} 0.01464159 0.4542587 0.03223183 2.3476795 144
## [28] {chicken} => {root vegetables} 0.01087951 0.2535545 0.04290798 2.3262206 107
## [29] {curd} => {yogurt} 0.01728521 0.3244275 0.05327911 2.3256154 170
## [30] {pip fruit,
## whole milk} => {other vegetables} 0.01352313 0.4493243 0.03009659 2.3221780 133
## [31] {berries} => {yogurt} 0.01057448 0.3180428 0.03324860 2.2798477 104
## [32] {curd,
## yogurt} => {whole milk} 0.01006609 0.5823529 0.01728521 2.2791250 99
## [33] {root vegetables} => {other vegetables} 0.04738180 0.4347015 0.10899847 2.2466049 466
## [34] {other vegetables,
## butter} => {whole milk} 0.01148958 0.5736041 0.02003050 2.2448850 113
## [35] {cream cheese } => {yogurt} 0.01240468 0.3128205 0.03965430 2.2424123 122
## [36] {tropical fruit,
## root vegetables} => {whole milk} 0.01199797 0.5700483 0.02104728 2.2309690 118
## [37] {citrus fruit,
## whole milk} => {other vegetables} 0.01301474 0.4266667 0.03050330 2.2050797 128
## [38] {root vegetables,
## yogurt} => {whole milk} 0.01453991 0.5629921 0.02582613 2.2033536 143
## [39] {tropical fruit,
## yogurt} => {other vegetables} 0.01230300 0.4201389 0.02928317 2.1713431 121
## [40] {other vegetables,
## domestic eggs} => {whole milk} 0.01230300 0.5525114 0.02226741 2.1623358 121
## [41] {chicken} => {other vegetables} 0.01789527 0.4170616 0.04290798 2.1554393 176
## [42] {whole milk,
## butter} => {other vegetables} 0.01148958 0.4169742 0.02755465 2.1549874 113
## [43] {hamburger meat} => {other vegetables} 0.01382816 0.4159021 0.03324860 2.1494470 136
## [44] {other vegetables,
## whole milk} => {yogurt} 0.02226741 0.2975543 0.07483477 2.1329789 219
## [45] {root vegetables,
## whole milk} => {yogurt} 0.01453991 0.2972973 0.04890696 2.1311362 143
## [46] {whole milk,
## domestic eggs} => {other vegetables} 0.01230300 0.4101695 0.02999492 2.1198197 121
## [47] {tropical fruit,
## whole milk} => {other vegetables} 0.01708185 0.4038462 0.04229792 2.0871397 168
## [48] {whipped/sour cream} => {other vegetables} 0.02887646 0.4028369 0.07168277 2.0819237 284
## [49] {whipped/sour cream} => {yogurt} 0.02074225 0.2893617 0.07168277 2.0742510 204
## [50] {whole milk,
## yogurt} => {other vegetables} 0.02226741 0.3974592 0.05602440 2.0541308 219
## [51] {yogurt,
## whipped/sour cream} => {whole milk} 0.01087951 0.5245098 0.02074225 2.0527473 107
## [52] {root vegetables,
## rolls/buns} => {whole milk} 0.01270971 0.5230126 0.02430097 2.0468876 125
## [53] {whole milk,
## fruit/vegetable juice} => {other vegetables} 0.01047280 0.3931298 0.02663955 2.0317558 103
## [54] {pip fruit,
## other vegetables} => {whole milk} 0.01352313 0.5175097 0.02613116 2.0253514 133
## [55] {tropical fruit,
## yogurt} => {whole milk} 0.01514997 0.5173611 0.02928317 2.0247698 149
## [56] {other vegetables,
## yogurt} => {whole milk} 0.02226741 0.5128806 0.04341637 2.0072345 219
## [57] {tropical fruit} => {yogurt} 0.02928317 0.2790698 0.10493137 2.0004746 288
## [58] {other vegetables,
## whipped/sour cream} => {whole milk} 0.01464159 0.5070423 0.02887646 1.9843854 144
## [59] {whole milk,
## rolls/buns} => {yogurt} 0.01555669 0.2746858 0.05663447 1.9690488 153
## [60] {root vegetables,
## other vegetables} => {yogurt} 0.01291307 0.2725322 0.04738180 1.9536108 127
## [61] {other vegetables,
## fruit/vegetable juice} => {whole milk} 0.01047280 0.4975845 0.02104728 1.9473713 103
## [62] {butter} => {whole milk} 0.02755465 0.4972477 0.05541434 1.9460530 271
## [63] {beef} => {other vegetables} 0.01972547 0.3759690 0.05246568 1.9430662 194
## [64] {pork} => {other vegetables} 0.02165735 0.3756614 0.05765125 1.9414764 213
## [65] {other vegetables,
## rolls/buns} => {yogurt} 0.01148958 0.2696897 0.04260295 1.9332351 113
## [66] {curd} => {whole milk} 0.02613116 0.4904580 0.05327911 1.9194805 257
## [67] {butter milk} => {other vegetables} 0.01037112 0.3709091 0.02796136 1.9169159 102
## [68] {root vegetables,
## other vegetables} => {whole milk} 0.02318251 0.4892704 0.04738180 1.9148326 228
## [69] {frozen vegetables} => {other vegetables} 0.01779359 0.3699789 0.04809354 1.9121083 175
## [70] {butter} => {yogurt} 0.01464159 0.2642202 0.05541434 1.8940273 144
## [71] {citrus fruit} => {yogurt} 0.02165735 0.2616708 0.08276563 1.8757521 213
## [72] {whole milk,
## soda} => {yogurt} 0.01047280 0.2614213 0.04006101 1.8739641 103
## [73] {butter} => {other vegetables} 0.02003050 0.3614679 0.05541434 1.8681223 197
## [74] {tropical fruit,
## other vegetables} => {whole milk} 0.01708185 0.4759207 0.03589222 1.8625865 168
## [75] {citrus fruit,
## yogurt} => {whole milk} 0.01026945 0.4741784 0.02165735 1.8557678 101
## [76] {fruit/vegetable juice} => {yogurt} 0.01870869 0.2587904 0.07229283 1.8551049 184
## [77] {domestic eggs} => {whole milk} 0.02999492 0.4727564 0.06344687 1.8502027 295
## [78] {frozen vegetables} => {yogurt} 0.01240468 0.2579281 0.04809354 1.8489235 122
## [79] {pork,
## other vegetables} => {whole milk} 0.01016777 0.4694836 0.02165735 1.8373939 100
## [80] {other vegetables,
## pastry} => {whole milk} 0.01057448 0.4684685 0.02257245 1.8334212 104
## [81] {domestic eggs} => {other vegetables} 0.02226741 0.3509615 0.06344687 1.8138238 219
## [82] {citrus fruit} => {other vegetables} 0.02887646 0.3488943 0.08276563 1.8031403 284
## [83] {whole milk,
## soda} => {other vegetables} 0.01392984 0.3477157 0.04006101 1.7970490 137
## [84] {cream cheese } => {other vegetables} 0.01372649 0.3461538 0.03965430 1.7889769 135
## [85] {pip fruit} => {other vegetables} 0.02613116 0.3454301 0.07564820 1.7852365 257
## [86] {frankfurter} => {rolls/buns} 0.01921708 0.3258621 0.05897306 1.7716161 189
## [87] {yogurt,
## rolls/buns} => {whole milk} 0.01555669 0.4526627 0.03436706 1.7715630 153
## [88] {sausage} => {rolls/buns} 0.03060498 0.3257576 0.09395018 1.7710480 301
## [89] {tropical fruit} => {other vegetables} 0.03589222 0.3420543 0.10493137 1.7677896 353
## [90] {citrus fruit,
## other vegetables} => {whole milk} 0.01301474 0.4507042 0.02887646 1.7638982 128
## [91] {whipped/sour cream} => {whole milk} 0.03223183 0.4496454 0.07168277 1.7597542 317
## [92] {sausage,
## whole milk} => {other vegetables} 0.01016777 0.3401361 0.02989324 1.7578760 100
## [93] {root vegetables} => {whole milk} 0.04890696 0.4486940 0.10899847 1.7560310 481
## [94] {tropical fruit,
## rolls/buns} => {whole milk} 0.01098119 0.4462810 0.02460600 1.7465872 108
## [95] {margarine} => {other vegetables} 0.01972547 0.3368056 0.05856634 1.7406635 194
## [96] {sugar} => {whole milk} 0.01504830 0.4444444 0.03385867 1.7393996 148
## [97] {hamburger meat} => {whole milk} 0.01474326 0.4434251 0.03324860 1.7354101 145
## [98] {yogurt,
## rolls/buns} => {other vegetables} 0.01148958 0.3343195 0.03436706 1.7278153 113
## [99] {ham} => {whole milk} 0.01148958 0.4414062 0.02602949 1.7275091 113
## [100] {sliced cheese} => {whole milk} 0.01077783 0.4398340 0.02450432 1.7213560 106
## [101] {other vegetables,
## bottled water} => {whole milk} 0.01077783 0.4344262 0.02480935 1.7001918 106
## [102] {white bread} => {other vegetables} 0.01372649 0.3260870 0.04209456 1.6852681 135
## [103] {curd} => {other vegetables} 0.01718353 0.3225191 0.05327911 1.6668288 169
## [104] {other vegetables,
## soda} => {whole milk} 0.01392984 0.4254658 0.03274021 1.6651240 137
## [105] {frozen vegetables} => {whole milk} 0.02043721 0.4249471 0.04809354 1.6630940 201
## [106] {sugar} => {other vegetables} 0.01077783 0.3183183 0.03385867 1.6451186 106
## [107] {other vegetables,
## rolls/buns} => {whole milk} 0.01789527 0.4200477 0.04260295 1.6439194 176
## [108] {whole milk,
## pastry} => {other vegetables} 0.01057448 0.3180428 0.03324860 1.6436947 104
## [109] {whole milk,
## rolls/buns} => {other vegetables} 0.01789527 0.3159785 0.05663447 1.6330258 176
## [110] {cream cheese } => {whole milk} 0.01647178 0.4153846 0.03965430 1.6256696 162
## [111] {butter milk} => {whole milk} 0.01159126 0.4145455 0.02796136 1.6223854 114
## [112] {whole milk,
## bottled water} => {other vegetables} 0.01077783 0.3136095 0.03436706 1.6207825 106
## [113] {margarine} => {whole milk} 0.02419929 0.4131944 0.05856634 1.6170980 238
## [114] {dessert} => {other vegetables} 0.01159126 0.3123288 0.03711235 1.6141636 114
## [115] {yogurt} => {other vegetables} 0.04341637 0.3112245 0.13950178 1.6084566 427
## [116] {hard cheese} => {whole milk} 0.01006609 0.4107884 0.02450432 1.6076815 99
## [117] {chicken} => {whole milk} 0.01759024 0.4099526 0.04290798 1.6044106 173
## [118] {berries} => {other vegetables} 0.01026945 0.3088685 0.03324860 1.5962805 101
## [119] {white bread} => {whole milk} 0.01708185 0.4057971 0.04209456 1.5881474 168
## [120] {beef} => {whole milk} 0.02125064 0.4050388 0.05246568 1.5851795 209
## [121] {tropical fruit} => {whole milk} 0.04229792 0.4031008 0.10493137 1.5775950 416
## [122] {oil} => {whole milk} 0.01128622 0.4021739 0.02806304 1.5739675 111
## [123] {yogurt} => {whole milk} 0.05602440 0.4016035 0.13950178 1.5717351 551
## [124] {chocolate} => {soda} 0.01352313 0.2725410 0.04961871 1.5629391 133
## [125] {pip fruit} => {whole milk} 0.03009659 0.3978495 0.07564820 1.5570432 296
## [126] {onions} => {whole milk} 0.01209964 0.3901639 0.03101169 1.5269647 119
## [127] {hygiene articles} => {whole milk} 0.01281139 0.3888889 0.03294357 1.5219746 126
## [128] {brown bread} => {whole milk} 0.02521607 0.3887147 0.06487036 1.5212930 248
## [129] {other vegetables} => {whole milk} 0.07483477 0.3867578 0.19349263 1.5136341 736
## [130] {whole milk} => {other vegetables} 0.07483477 0.2928770 0.25551601 1.5136341 736
## [131] {whole milk,
## yogurt} => {rolls/buns} 0.01555669 0.2776770 0.05602440 1.5096478 153
## [132] {pork} => {whole milk} 0.02216573 0.3844797 0.05765125 1.5047187 218
## [133] {fruit/vegetable juice} => {other vegetables} 0.02104728 0.2911392 0.07229283 1.5046529 207
## [134] {bottled water} => {soda} 0.02897814 0.2621895 0.11052364 1.5035766 285
## [135] {yogurt,
## soda} => {whole milk} 0.01047280 0.3828996 0.02735130 1.4985348 103
## [136] {brown bread} => {other vegetables} 0.01870869 0.2884013 0.06487036 1.4905025 184
## [137] {sausage} => {soda} 0.02430097 0.2586580 0.09395018 1.4833245 239
## [138] {sausage} => {other vegetables} 0.02694459 0.2867965 0.09395018 1.4822091 265
## [139] {sausage,
## other vegetables} => {whole milk} 0.01016777 0.3773585 0.02694459 1.4768487 100
## [140] {long life bakery product} => {other vegetables} 0.01067616 0.2853261 0.03741739 1.4746096 105
## [141] {napkins} => {whole milk} 0.01972547 0.3766990 0.05236401 1.4742678 194
## [142] {salty snack} => {other vegetables} 0.01077783 0.2849462 0.03782410 1.4726465 106
## [143] {pastry} => {whole milk} 0.03324860 0.3737143 0.08896797 1.4625865 327
## [144] {fruit/vegetable juice} => {soda} 0.01840366 0.2545710 0.07229283 1.4598869 181
## [145] {dessert} => {whole milk} 0.01372649 0.3698630 0.03711235 1.4475140 135
## [146] {frankfurter} => {other vegetables} 0.01647178 0.2793103 0.05897306 1.4435193 162
## [147] {citrus fruit} => {whole milk} 0.03050330 0.3685504 0.08276563 1.4423768 300
## [148] {fruit/vegetable juice} => {whole milk} 0.02663955 0.3684951 0.07229283 1.4421604 262
## [149] {other vegetables,
## yogurt} => {rolls/buns} 0.01148958 0.2646370 0.04341637 1.4387534 113
## [150] {napkins} => {other vegetables} 0.01443823 0.2757282 0.05236401 1.4250060 142
## [151] {long life bakery product} => {whole milk} 0.01352313 0.3614130 0.03741739 1.4144438 133
## [152] {root vegetables,
## whole milk} => {rolls/buns} 0.01270971 0.2598753 0.04890696 1.4128652 125
## [153] {beef} => {rolls/buns} 0.01362481 0.2596899 0.05246568 1.4118576 134
## [154] {tropical fruit,
## whole milk} => {rolls/buns} 0.01098119 0.2596154 0.04229792 1.4114524 108
## [155] {root vegetables,
## other vegetables} => {rolls/buns} 0.01220132 0.2575107 0.04738180 1.4000100 120
## [156] {berries} => {whole milk} 0.01179461 0.3547401 0.03324860 1.3883281 116
## [157] {margarine} => {rolls/buns} 0.01474326 0.2517361 0.05856634 1.3686151 145
## [158] {frankfurter} => {whole milk} 0.02053889 0.3482759 0.05897306 1.3630295 202
## [159] {waffles} => {other vegetables} 0.01006609 0.2619048 0.03843416 1.3535645 99
## [160] {newspapers} => {whole milk} 0.02735130 0.3426752 0.07981698 1.3411103 269
## [161] {chocolate} => {other vegetables} 0.01270971 0.2561475 0.04961871 1.3238103 125
## [162] {chocolate} => {whole milk} 0.01667514 0.3360656 0.04961871 1.3152427 164
## [163] {pastry} => {other vegetables} 0.02257245 0.2537143 0.08896797 1.3112349 222
## [164] {waffles} => {whole milk} 0.01270971 0.3306878 0.03843416 1.2941961 125
## [165] {coffee} => {whole milk} 0.01870869 0.3222417 0.05805796 1.2611408 184
## [166] {sausage} => {whole milk} 0.02989324 0.3181818 0.09395018 1.2452520 294
## [167] {bottled water} => {whole milk} 0.03436706 0.3109476 0.11052364 1.2169396 338
## [168] {rolls/buns} => {whole milk} 0.05663447 0.3079049 0.18393493 1.2050318 557
## [169] {salty snack} => {whole milk} 0.01118454 0.2956989 0.03782410 1.1572618 110
## [170] {bottled beer} => {whole milk} 0.02043721 0.2537879 0.08052872 0.9932367 201
Force target classification atributes
groceryrules <- apriori(Groceries, parameter = list(support = 0.006, confidence = 0.25, minlen = 2))
## Apriori
##
## Parameter specification:
## confidence minval smax arem aval originalSupport maxtime support minlen
## 0.25 0.1 1 none FALSE TRUE 5 0.006 2
## 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: 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.00s].
## writing ... [463 rule(s)] done [0.00s].
## creating S4 object ... done [0.00s].
groceryrules
## set of 463 rules
inspect(groceryrules[1:6])
## lhs rhs support confidence coverage
## [1] {pot plants} => {whole milk} 0.006914082 0.4000000 0.01728521
## [2] {pasta} => {whole milk} 0.006100661 0.4054054 0.01504830
## [3] {herbs} => {root vegetables} 0.007015760 0.4312500 0.01626843
## [4] {herbs} => {other vegetables} 0.007727504 0.4750000 0.01626843
## [5] {herbs} => {whole milk} 0.007727504 0.4750000 0.01626843
## [6] {processed cheese} => {whole milk} 0.007015760 0.4233129 0.01657346
## lift count
## [1] 1.565460 68
## [2] 1.586614 60
## [3] 3.956477 69
## [4] 2.454874 76
## [5] 1.858983 76
## [6] 1.656698 69
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 coverage lift
## Min. :0.006101 Min. :0.2500 Min. :0.009964 Min. :0.9932
## 1st Qu.:0.007117 1st Qu.:0.2971 1st Qu.:0.018709 1st Qu.:1.6229
## Median :0.008744 Median :0.3554 Median :0.024809 Median :1.9332
## Mean :0.011539 Mean :0.3786 Mean :0.032608 Mean :2.0351
## 3rd Qu.:0.012303 3rd Qu.:0.4495 3rd Qu.:0.035892 3rd Qu.:2.3565
## Max. :0.074835 Max. :0.6600 Max. :0.255516 Max. :3.9565
## count
## Min. : 60.0
## 1st Qu.: 70.0
## Median : 86.0
## Mean :113.5
## 3rd Qu.:121.0
## Max. :736.0
##
## mining info:
## data ntransactions support confidence
## Groceries 9835 0.006 0.25
## call
## apriori(data = Groceries, parameter = list(support = 0.006, confidence = 0.25, minlen = 2))
inspect(sort(groceryrules, by = "confidence")[1:5])
## lhs rhs support confidence
## [1] {butter, whipped/sour cream} => {whole milk} 0.006710727 0.6600000
## [2] {butter, yogurt} => {whole milk} 0.009354347 0.6388889
## [3] {root vegetables, butter} => {whole milk} 0.008235892 0.6377953
## [4] {tropical fruit, curd} => {whole milk} 0.006507372 0.6336634
## [5] {tropical fruit, butter} => {whole milk} 0.006202339 0.6224490
## coverage lift count
## [1] 0.010167768 2.583008 66
## [2] 0.014641586 2.500387 92
## [3] 0.012913066 2.496107 81
## [4] 0.010269446 2.479936 64
## [5] 0.009964413 2.436047 61
inspect(sort(groceryrules, by = "lift", decreasing = TRUE) [1:5])
## lhs rhs support confidence coverage lift count
## [1] {herbs} => {root vegetables} 0.007015760 0.4312500 0.01626843 3.956477 69
## [2] {berries} => {whipped/sour cream} 0.009049314 0.2721713 0.03324860 3.796886 89
## [3] {tropical fruit,
## other vegetables,
## whole milk} => {root vegetables} 0.007015760 0.4107143 0.01708185 3.768074 69
## [4] {beef,
## other vegetables} => {root vegetables} 0.007930859 0.4020619 0.01972547 3.688692 78
## [5] {tropical fruit,
## other vegetables} => {pip fruit} 0.009456024 0.2634561 0.03589222 3.482649 93
Force the target classification attribute on RHS of association
rules (AI4OPT)
rules <- apriori(Groceries, parameter = list(supp = 0.006, conf = .25), appearance = list(default = "lhs", rhs = c("whole milk", "berries")), control = list(verbose = F))
inspect(head(sort(rules, by = "lift", decreasing = T), 4))
## lhs rhs support confidence
## [1] {butter, whipped/sour cream} => {whole milk} 0.006710727 0.6600000
## [2] {butter, yogurt} => {whole milk} 0.009354347 0.6388889
## [3] {root vegetables, butter} => {whole milk} 0.008235892 0.6377953
## [4] {tropical fruit, curd} => {whole milk} 0.006507372 0.6336634
## coverage lift count
## [1] 0.01016777 2.583008 66
## [2] 0.01464159 2.500387 92
## [3] 0.01291307 2.496107 81
## [4] 0.01026945 2.479936 64
# Force the target classification attribute on RHS of association rules (AI4OPT)
rules <- apriori(Groceries, parameter = list(supp = 0.006, conf = .25), appearance = list(default = "lhs", rhs = c("berries", "pip fruit")), control = list(verbose = F))
inspect(head(sort(rules, by = "lift", decreasing = T), 5))
## lhs rhs support confidence
## [1] {tropical fruit, other vegetables} => {pip fruit} 0.009456024 0.2634561
## coverage lift count
## [1] 0.03589222 3.482649 93
Plot Association Rules on Selected Metrics Dimensions
plot(groceryrules, measure = c("support", "lift"), shading = "confidence")
## To reduce overplotting, jitter is added! Use jitter = 0 to prevent jitter.

plot(groceryrules, shading = "order", control = list(main = "Two-key plot"))
## To reduce overplotting, jitter is added! Use jitter = 0 to prevent jitter.
