#20200531 Blind study
library(arules)
## Warning: package 'arules' was built under R version 3.6.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 3.6.1
## Loading required package: grid
## Registered S3 method overwritten by 'seriation':
## method from
## reorder.hclust gclus
#Dataset from https://www.kaggle.com/irfanasrullah/groceries
raw <- read.transactions("groceries.csv") #read.transactions(file.choose())를 사용해서 그냥 클릭하던가
## Warning in asMethod(object): removing duplicated items in transactions
notrans <- read.csv("groceries.csv")
str(raw) #transaction data. matrix로 표현하자면 sparse matrix
## Formal class 'transactions' [package "arules"] with 3 slots
## ..@ data :Formal class 'ngCMatrix' [package "Matrix"] with 5 slots
## .. .. ..@ i : int [1:35261] 542 1424 3059 5737 3121 5856 3856 6700 1037 3126 ...
## .. .. ..@ p : int [1:9836] 0 4 6 8 12 19 22 23 27 29 ...
## .. .. ..@ Dim : int [1:2] 6871 9835
## .. .. ..@ Dimnames:List of 2
## .. .. .. ..$ : NULL
## .. .. .. ..$ : NULL
## .. .. ..@ factors : list()
## ..@ itemInfo :'data.frame': 6871 obs. of 1 variable:
## .. ..$ labels: chr [1:6871] "(appetizer)" "(appetizer),bathroom" "(appetizer),cake" "(appetizer),candy,cling" ...
## ..@ itemsetInfo:'data.frame': 0 obs. of 0 variables
str(notrans) #그냥 읽어오면 이런식
## 'data.frame': 15295 obs. of 4 variables:
## $ citrus.fruit : Factor w/ 167 levels "abrasive cleaner",..: 156 165 109 102 165 1 121 102 83 113 ...
## $ semi.finished.bread: Factor w/ 162 levels "","abrasive cleaner",..: 161 1 161 160 14 1 1 153 1 1 ...
## $ margarine : Factor w/ 164 levels "","abrasive cleaner",..: 34 1 39 35 163 1 1 120 1 1 ...
## $ ready.soups : Factor w/ 162 levels "","abrasive cleaner",..: 1 1 87 83 116 1 1 12 1 1 ...
inspect(raw[1:6]) #볼 때는 이렇게
## items
## [1] {bread,margarine,ready,
## citrus,
## fruit,semi-finished,
## soups}
## [2] {fruit,yogurt,coffee,
## tropical}
## [3] {milk,
## whole}
## [4] {cheese,meat,
## fruit,yogurt,cream,
## pip,
## spreads}
## [5] {bakery,
## life,
## milk,condensed,
## milk,long,
## other,
## product,
## vegetables,whole}
## [6] {cleaner,
## milk,butter,yogurt,rice,abrasive,
## whole}
gr_rules <- apriori(raw) #default로 돌리니까 rule 이 안나옴.
## 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 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 ...[6871 item(s), 9835 transaction(s)] done [0.03s].
## sorting and recoding items ... [0 item(s)] done [0.00s].
## creating transaction tree ... done [0.00s].
## checking subsets of size 1 done [0.00s].
## writing ... [0 rule(s)] done [0.00s].
## creating S4 object ... done [0.00s].
#support : a와 b가 동시에 일어날 확률(a와 b를 동시 구매/전체 거래수) support(A)=P(A)
#confidence : a를 샀을 때 b를 살 확률(a를 포함하는 거래/a와 b를 동시에 구매한 수) confidence(A→B)=P(A,B)P(A)
#lift : a와 b를 동시에 구매한 수/ (a구매(b와 독립) X b 구매(a와 독립)) 1이면 관계없음. 1을 기준으로 lift(A→B)=P(A,B)P(A)⋅P(B)
gr_rules <- apriori(raw, parameter =list(supp = .001, conf = .7))
## Apriori
##
## Parameter specification:
## confidence minval smax arem aval originalSupport maxtime support minlen
## 0.7 0.1 1 none FALSE TRUE 5 0.001 1
## maxlen target ext
## 10 rules FALSE
##
## Algorithmic control:
## filter tree heap memopt load sort verbose
## 0.1 TRUE TRUE FALSE TRUE 2 TRUE
##
## Absolute minimum support count: 9
##
## set item appearances ...[0 item(s)] done [0.00s].
## set transactions ...[6871 item(s), 9835 transaction(s)] done [0.03s].
## sorting and recoding items ... [477 item(s)] done [0.00s].
## creating transaction tree ... done [0.00s].
## checking subsets of size 1 2 3 4 done [0.00s].
## writing ... [184 rule(s)] done [0.00s].
## creating S4 object ... done [0.00s].
inspect(gr_rules[1:5]) #rule을 볼때는 inspect함수사용
## lhs rhs support confidence lift count
## [1] {sparkling} => {wine} 0.001016777 0.9090909 41.393098 10
## [2] {potted} => {plants} 0.001016777 0.9090909 59.211318 10
## [3] {red/blush} => {wine} 0.001016777 0.7692308 35.024929 10
## [4] {hygiene} => {articles} 0.001220132 0.7500000 44.169162 12
## [5] {soda,canned} => {beer} 0.001525165 0.7142857 8.474065 15
inspect(sort(gr_rules, by = "support", decreasing = T)) #support값이 가장 기본이고, 이걸 중심으로 보자
## lhs rhs support confidence lift count
## [1] {life} => {bakery} 0.037417387 1.0000000 26.725543 368
## [2] {bakery} => {life} 0.037417387 1.0000000 26.725543 368
## [3] {canned} => {beer} 0.026537875 0.8080495 9.586450 261
## [4] {product} => {life} 0.013218099 1.0000000 26.725543 130
## [5] {product} => {bakery} 0.013218099 1.0000000 26.725543 130
## [6] {life,
## product} => {bakery} 0.013218099 1.0000000 26.725543 130
## [7] {bakery,
## product} => {life} 0.013218099 1.0000000 26.725543 130
## [8] {beer,shopping} => {bags} 0.006914082 1.0000000 10.128733 68
## [9] {life,
## vegetables,whole} => {bakery} 0.006609049 1.0000000 26.725543 65
## [10] {bakery,
## vegetables,whole} => {life} 0.006609049 1.0000000 26.725543 65
## [11] {bags,
## life} => {bakery} 0.005388917 1.0000000 26.725543 53
## [12] {bags,
## bakery} => {life} 0.005388917 1.0000000 26.725543 53
## [13] {shopping} => {bags} 0.004880529 1.0000000 10.128733 48
## [14] {juice,long} => {life} 0.004270463 1.0000000 26.725543 42
## [15] {juice,long} => {bakery} 0.004270463 1.0000000 26.725543 42
## [16] {juice,long,
## life} => {bakery} 0.004270463 1.0000000 26.725543 42
## [17] {bakery,
## juice,long} => {life} 0.004270463 1.0000000 26.725543 42
## [18] {products,shopping} => {bags} 0.003660397 1.0000000 10.128733 36
## [19] {articles,shopping} => {bags} 0.003457041 1.0000000 10.128733 34
## [20] {snack,long} => {life} 0.003355363 1.0000000 26.725543 33
## [21] {snack,long} => {bakery} 0.003355363 1.0000000 26.725543 33
## [22] {life,
## snack,long} => {bakery} 0.003355363 1.0000000 26.725543 33
## [23] {bakery,
## snack,long} => {life} 0.003355363 1.0000000 26.725543 33
## [24] {salty} => {snack} 0.003050330 0.7692308 51.465201 30
## [25] {wine,shopping} => {bags} 0.003050330 1.0000000 10.128733 30
## [26] {bar,shopping} => {bags} 0.003050330 1.0000000 10.128733 30
## [27] {fruit,pip,
## vegetables,other} => {fruit,root} 0.002745297 0.7941176 22.314706 27
## [28] {life,
## vegetables,other} => {bakery} 0.002745297 1.0000000 26.725543 27
## [29] {bakery,
## vegetables,other} => {life} 0.002745297 1.0000000 26.725543 27
## [30] {product,specialty} => {life} 0.002541942 1.0000000 26.725543 25
## [31] {product,specialty} => {bakery} 0.002541942 1.0000000 26.725543 25
## [32] {life,
## product,specialty} => {bakery} 0.002541942 1.0000000 26.725543 25
## [33] {bakery,
## product,specialty} => {life} 0.002541942 1.0000000 26.725543 25
## [34] {juice,shopping} => {bags} 0.002440264 1.0000000 10.128733 24
## [35] {beer,long} => {life} 0.002440264 1.0000000 26.725543 24
## [36] {beer,long} => {bakery} 0.002440264 1.0000000 26.725543 24
## [37] {beer,long,
## life} => {bakery} 0.002440264 1.0000000 26.725543 24
## [38] {bakery,
## beer,long} => {life} 0.002440264 1.0000000 26.725543 24
## [39] {fruit,tropical,
## vegetables,other} => {fruit,root} 0.002440264 0.7058824 19.835294 24
## [40] {fruit,pip,
## life} => {bakery} 0.002440264 1.0000000 26.725543 24
## [41] {bakery,
## fruit,pip} => {life} 0.002440264 1.0000000 26.725543 24
## [42] {life,
## whole} => {bakery} 0.002440264 1.0000000 26.725543 24
## [43] {bakery,
## whole} => {life} 0.002440264 1.0000000 26.725543 24
## [44] {citrus,
## vegetables,other} => {fruit,root} 0.002440264 0.8571429 24.085714 24
## [45] {product,shopping} => {life} 0.002338587 1.0000000 26.725543 23
## [46] {product,shopping} => {bakery} 0.002338587 1.0000000 26.725543 23
## [47] {product,shopping} => {bags} 0.002338587 1.0000000 10.128733 23
## [48] {milk,butter,whipped/sour} => {vegetables,whole} 0.002338587 0.7187500 7.520113 23
## [49] {life,
## product,shopping} => {bakery} 0.002338587 1.0000000 26.725543 23
## [50] {bakery,
## product,shopping} => {life} 0.002338587 1.0000000 26.725543 23
## [51] {life,
## product,shopping} => {bags} 0.002338587 1.0000000 10.128733 23
## [52] {bags,
## product,shopping} => {life} 0.002338587 1.0000000 26.725543 23
## [53] {bakery,
## product,shopping} => {bags} 0.002338587 1.0000000 10.128733 23
## [54] {bags,
## product,shopping} => {bakery} 0.002338587 1.0000000 26.725543 23
## [55] {citrus,
## life} => {bakery} 0.002338587 1.0000000 26.725543 23
## [56] {bakery,
## citrus} => {life} 0.002338587 1.0000000 26.725543 23
## [57] {bakery,
## life,
## product,shopping} => {bags} 0.002338587 1.0000000 10.128733 23
## [58] {bags,
## life,
## product,shopping} => {bakery} 0.002338587 1.0000000 26.725543 23
## [59] {bags,
## bakery,
## product,shopping} => {life} 0.002338587 1.0000000 26.725543 23
## [60] {cheese,frozen,
## vegetables,other} => {vegetables,whole} 0.002236909 0.7333333 7.672695 22
## [61] {snack,shopping} => {bags} 0.002135231 1.0000000 10.128733 21
## [62] {life,
## tropical} => {bakery} 0.002135231 1.0000000 26.725543 21
## [63] {bakery,
## tropical} => {life} 0.002135231 1.0000000 26.725543 21
## [64] {gum,shopping} => {bags} 0.002033554 1.0000000 10.128733 20
## [65] {fruit,whole,
## life} => {bakery} 0.002033554 1.0000000 26.725543 20
## [66] {bakery,
## fruit,whole} => {life} 0.002033554 1.0000000 26.725543 20
## [67] {fruit,other,
## life} => {bakery} 0.002033554 1.0000000 26.725543 20
## [68] {bakery,
## fruit,other} => {life} 0.002033554 1.0000000 26.725543 20
## [69] {tropical,
## vegetables,other} => {fruit,root} 0.002033554 0.7692308 21.615385 20
## [70] {fruit,root,
## life} => {bakery} 0.002033554 1.0000000 26.725543 20
## [71] {bakery,
## fruit,root} => {life} 0.002033554 1.0000000 26.725543 20
## [72] {chocolate,shopping} => {bags} 0.001931876 1.0000000 10.128733 19
## [73] {cheese,frozen,
## life} => {bakery} 0.001931876 1.0000000 26.725543 19
## [74] {bakery,
## cheese,frozen} => {life} 0.001931876 1.0000000 26.725543 19
## [75] {long} => {life} 0.001830198 1.0000000 26.725543 18
## [76] {long} => {bakery} 0.001830198 1.0000000 26.725543 18
## [77] {plants,shopping} => {bags} 0.001830198 1.0000000 10.128733 18
## [78] {life,
## long} => {bakery} 0.001830198 1.0000000 26.725543 18
## [79] {bakery,
## long} => {life} 0.001830198 1.0000000 26.725543 18
## [80] {cheese,frozen,
## fruit,root} => {vegetables,whole} 0.001830198 0.7500000 7.847074 18
## [81] {water,long} => {life} 0.001728521 1.0000000 26.725543 17
## [82] {water,long} => {bakery} 0.001728521 1.0000000 26.725543 17
## [83] {life,
## water,long} => {bakery} 0.001728521 1.0000000 26.725543 17
## [84] {bakery,
## water,long} => {life} 0.001728521 1.0000000 26.725543 17
## [85] {life,
## other} => {bakery} 0.001728521 1.0000000 26.725543 17
## [86] {bakery,
## other} => {life} 0.001728521 1.0000000 26.725543 17
## [87] {product,chocolate} => {life} 0.001626843 1.0000000 26.725543 16
## [88] {product,chocolate} => {bakery} 0.001626843 1.0000000 26.725543 16
## [89] {wine,long} => {life} 0.001626843 1.0000000 26.725543 16
## [90] {wine,long} => {bakery} 0.001626843 1.0000000 26.725543 16
## [91] {life,
## product,chocolate} => {bakery} 0.001626843 1.0000000 26.725543 16
## [92] {bakery,
## product,chocolate} => {life} 0.001626843 1.0000000 26.725543 16
## [93] {life,
## wine,long} => {bakery} 0.001626843 1.0000000 26.725543 16
## [94] {bakery,
## wine,long} => {life} 0.001626843 1.0000000 26.725543 16
## [95] {fruit,pip,
## vegetables,other,
## vegetables,whole} => {fruit,root} 0.001626843 0.7619048 21.409524 16
## [96] {soda,canned} => {beer} 0.001525165 0.7142857 8.474065 15
## [97] {beer,liquor,red/blush} => {wine} 0.001423488 0.7000000 31.872685 14
## [98] {bread,shopping} => {bags} 0.001423488 1.0000000 10.128733 14
## [99] {water,shopping} => {bags} 0.001423488 1.0000000 10.128733 14
## [100] {product,
## vegetables,whole} => {life} 0.001423488 1.0000000 26.725543 14
## [101] {product,
## vegetables,whole} => {bakery} 0.001423488 1.0000000 26.725543 14
## [102] {life,
## product,
## vegetables,whole} => {bakery} 0.001423488 1.0000000 26.725543 14
## [103] {bakery,
## product,
## vegetables,whole} => {life} 0.001423488 1.0000000 26.725543 14
## [104] {life,
## vegetables,frozen} => {bakery} 0.001321810 1.0000000 26.725543 13
## [105] {bakery,
## vegetables,frozen} => {life} 0.001321810 1.0000000 26.725543 13
## [106] {hygiene} => {articles} 0.001220132 0.7500000 44.169162 12
## [107] {product,newspapers} => {life} 0.001220132 1.0000000 26.725543 12
## [108] {product,newspapers} => {bakery} 0.001220132 1.0000000 26.725543 12
## [109] {bread,long} => {life} 0.001220132 1.0000000 26.725543 12
## [110] {bread,long} => {bakery} 0.001220132 1.0000000 26.725543 12
## [111] {beverages,long} => {life} 0.001220132 1.0000000 26.725543 12
## [112] {beverages,long} => {bakery} 0.001220132 1.0000000 26.725543 12
## [113] {products,canned} => {food} 0.001220132 0.8571429 63.863636 12
## [114] {water,long} => {product} 0.001220132 0.7058824 53.402715 12
## [115] {life,
## product,newspapers} => {bakery} 0.001220132 1.0000000 26.725543 12
## [116] {bakery,
## product,newspapers} => {life} 0.001220132 1.0000000 26.725543 12
## [117] {bread,long,
## life} => {bakery} 0.001220132 1.0000000 26.725543 12
## [118] {bakery,
## bread,long} => {life} 0.001220132 1.0000000 26.725543 12
## [119] {beverages,long,
## life} => {bakery} 0.001220132 1.0000000 26.725543 12
## [120] {bakery,
## beverages,long} => {life} 0.001220132 1.0000000 26.725543 12
## [121] {product,
## water,long} => {life} 0.001220132 1.0000000 26.725543 12
## [122] {life,
## water,long} => {product} 0.001220132 0.7058824 53.402715 12
## [123] {product,
## water,long} => {bakery} 0.001220132 1.0000000 26.725543 12
## [124] {bakery,
## water,long} => {product} 0.001220132 0.7058824 53.402715 12
## [125] {juice,long,
## product} => {life} 0.001220132 1.0000000 26.725543 12
## [126] {juice,long,
## product} => {bakery} 0.001220132 1.0000000 26.725543 12
## [127] {milk,yogurt,whipped/sour,
## vegetables,other} => {vegetables,whole} 0.001220132 1.0000000 10.462766 12
## [128] {life,
## plants} => {bakery} 0.001220132 1.0000000 26.725543 12
## [129] {bakery,
## plants} => {life} 0.001220132 1.0000000 26.725543 12
## [130] {life,
## product,
## water,long} => {bakery} 0.001220132 1.0000000 26.725543 12
## [131] {bakery,
## product,
## water,long} => {life} 0.001220132 1.0000000 26.725543 12
## [132] {bakery,
## life,
## water,long} => {product} 0.001220132 0.7058824 53.402715 12
## [133] {juice,long,
## life,
## product} => {bakery} 0.001220132 1.0000000 26.725543 12
## [134] {bakery,
## juice,long,
## product} => {life} 0.001220132 1.0000000 26.725543 12
## [135] {fruit,other,
## life,
## vegetables,whole} => {bakery} 0.001220132 1.0000000 26.725543 12
## [136] {bakery,
## fruit,other,
## vegetables,whole} => {life} 0.001220132 1.0000000 26.725543 12
## [137] {citrus,
## vegetables,other,
## vegetables,whole} => {fruit,root} 0.001220132 0.8571429 24.085714 12
## [138] {fruit,root,
## life,
## vegetables,other} => {bakery} 0.001220132 1.0000000 26.725543 12
## [139] {bakery,
## fruit,root,
## vegetables,other} => {life} 0.001220132 1.0000000 26.725543 12
## [140] {vegetables,shopping} => {bags} 0.001118454 1.0000000 10.128733 11
## [141] {film/bags,shopping} => {bags} 0.001118454 1.0000000 10.128733 11
## [142] {care,shopping} => {bags} 0.001118454 1.0000000 10.128733 11
## [143] {(seeds),shopping} => {bags} 0.001118454 1.0000000 10.128733 11
## [144] {long,
## product} => {life} 0.001118454 1.0000000 26.725543 11
## [145] {long,
## product} => {bakery} 0.001118454 1.0000000 26.725543 11
## [146] {beer,shopping,
## canned} => {bags} 0.001118454 1.0000000 10.128733 11
## [147] {bags,
## canned} => {beer,shopping} 0.001118454 0.7333333 106.063725 11
## [148] {snack,long,
## vegetables,whole} => {life} 0.001118454 1.0000000 26.725543 11
## [149] {snack,long,
## vegetables,whole} => {bakery} 0.001118454 1.0000000 26.725543 11
## [150] {fruit,root,
## milk,yogurt,whipped/sour} => {vegetables,whole} 0.001118454 1.0000000 10.462766 11
## [151] {keeping,
## life} => {bakery} 0.001118454 1.0000000 26.725543 11
## [152] {bakery,
## keeping} => {life} 0.001118454 1.0000000 26.725543 11
## [153] {milk,frozen,
## other} => {vegetables,whole} 0.001118454 0.7333333 7.672695 11
## [154] {fruit,other,
## milk,frozen} => {vegetables,whole} 0.001118454 0.7857143 8.220745 11
## [155] {cheese,domestic,
## vegetables,other} => {vegetables,whole} 0.001118454 0.7333333 7.672695 11
## [156] {milk,whipped/sour,
## vegetables,other} => {vegetables,whole} 0.001118454 1.0000000 10.462766 11
## [157] {life,
## root} => {bakery} 0.001118454 1.0000000 26.725543 11
## [158] {bakery,
## root} => {life} 0.001118454 1.0000000 26.725543 11
## [159] {fruit,tropical,
## life} => {bakery} 0.001118454 1.0000000 26.725543 11
## [160] {bakery,
## fruit,tropical} => {life} 0.001118454 1.0000000 26.725543 11
## [161] {life,
## long,
## product} => {bakery} 0.001118454 1.0000000 26.725543 11
## [162] {bakery,
## long,
## product} => {life} 0.001118454 1.0000000 26.725543 11
## [163] {life,
## snack,long,
## vegetables,whole} => {bakery} 0.001118454 1.0000000 26.725543 11
## [164] {bakery,
## snack,long,
## vegetables,whole} => {life} 0.001118454 1.0000000 26.725543 11
## [165] {life,
## other,
## vegetables,whole} => {bakery} 0.001118454 1.0000000 26.725543 11
## [166] {bakery,
## other,
## vegetables,whole} => {life} 0.001118454 1.0000000 26.725543 11
## [167] {life,
## vegetables,other,
## vegetables,whole} => {bakery} 0.001118454 1.0000000 26.725543 11
## [168] {bakery,
## vegetables,other,
## vegetables,whole} => {life} 0.001118454 1.0000000 26.725543 11
## [169] {sparkling} => {wine} 0.001016777 0.9090909 41.393098 10
## [170] {potted} => {plants} 0.001016777 0.9090909 59.211318 10
## [171] {red/blush} => {wine} 0.001016777 0.7692308 35.024929 10
## [172] {beverages,shopping} => {bags} 0.001016777 1.0000000 10.128733 10
## [173] {food,shopping} => {bags} 0.001016777 1.0000000 10.128733 10
## [174] {bread,Instant} => {food} 0.001016777 1.0000000 74.507576 10
## [175] {keeping,
## products,shopping} => {bags} 0.001016777 1.0000000 10.128733 10
## [176] {bar,
## life} => {bakery} 0.001016777 1.0000000 26.725543 10
## [177] {bakery,
## bar} => {life} 0.001016777 1.0000000 26.725543 10
## [178] {cheese,domestic,
## fruit,root} => {vegetables,whole} 0.001016777 0.7692308 8.048282 10
## [179] {life,
## products} => {bakery} 0.001016777 1.0000000 26.725543 10
## [180] {bakery,
## products} => {life} 0.001016777 1.0000000 26.725543 10
## [181] {pip,
## vegetables,other} => {fruit,root} 0.001016777 0.9090909 25.545455 10
## [182] {citrus,
## fruit,tropical,
## vegetables,other} => {fruit,root} 0.001016777 0.7142857 20.071429 10
## [183] {bags,
## life,
## vegetables,whole} => {bakery} 0.001016777 1.0000000 26.725543 10
## [184] {bags,
## bakery,
## vegetables,whole} => {life} 0.001016777 1.0000000 26.725543 10
inspect(gr_rules)
## lhs rhs support confidence lift count
## [1] {sparkling} => {wine} 0.001016777 0.9090909 41.393098 10
## [2] {potted} => {plants} 0.001016777 0.9090909 59.211318 10
## [3] {red/blush} => {wine} 0.001016777 0.7692308 35.024929 10
## [4] {hygiene} => {articles} 0.001220132 0.7500000 44.169162 12
## [5] {soda,canned} => {beer} 0.001525165 0.7142857 8.474065 15
## [6] {beverages,shopping} => {bags} 0.001016777 1.0000000 10.128733 10
## [7] {vegetables,shopping} => {bags} 0.001118454 1.0000000 10.128733 11
## [8] {food,shopping} => {bags} 0.001016777 1.0000000 10.128733 10
## [9] {film/bags,shopping} => {bags} 0.001118454 1.0000000 10.128733 11
## [10] {care,shopping} => {bags} 0.001118454 1.0000000 10.128733 11
## [11] {beer,liquor,red/blush} => {wine} 0.001423488 0.7000000 31.872685 14
## [12] {bread,shopping} => {bags} 0.001423488 1.0000000 10.128733 14
## [13] {long} => {life} 0.001830198 1.0000000 26.725543 18
## [14] {long} => {bakery} 0.001830198 1.0000000 26.725543 18
## [15] {(seeds),shopping} => {bags} 0.001118454 1.0000000 10.128733 11
## [16] {water,shopping} => {bags} 0.001423488 1.0000000 10.128733 14
## [17] {product,newspapers} => {life} 0.001220132 1.0000000 26.725543 12
## [18] {product,newspapers} => {bakery} 0.001220132 1.0000000 26.725543 12
## [19] {salty} => {snack} 0.003050330 0.7692308 51.465201 30
## [20] {bread,long} => {life} 0.001220132 1.0000000 26.725543 12
## [21] {bread,long} => {bakery} 0.001220132 1.0000000 26.725543 12
## [22] {bread,Instant} => {food} 0.001016777 1.0000000 74.507576 10
## [23] {shopping} => {bags} 0.004880529 1.0000000 10.128733 48
## [24] {gum,shopping} => {bags} 0.002033554 1.0000000 10.128733 20
## [25] {beverages,long} => {life} 0.001220132 1.0000000 26.725543 12
## [26] {beverages,long} => {bakery} 0.001220132 1.0000000 26.725543 12
## [27] {chocolate,shopping} => {bags} 0.001931876 1.0000000 10.128733 19
## [28] {product,chocolate} => {life} 0.001626843 1.0000000 26.725543 16
## [29] {product,chocolate} => {bakery} 0.001626843 1.0000000 26.725543 16
## [30] {products,canned} => {food} 0.001220132 0.8571429 63.863636 12
## [31] {plants,shopping} => {bags} 0.001830198 1.0000000 10.128733 18
## [32] {water,long} => {product} 0.001220132 0.7058824 53.402715 12
## [33] {water,long} => {life} 0.001728521 1.0000000 26.725543 17
## [34] {water,long} => {bakery} 0.001728521 1.0000000 26.725543 17
## [35] {wine,shopping} => {bags} 0.003050330 1.0000000 10.128733 30
## [36] {snack,shopping} => {bags} 0.002135231 1.0000000 10.128733 21
## [37] {juice,shopping} => {bags} 0.002440264 1.0000000 10.128733 24
## [38] {wine,long} => {life} 0.001626843 1.0000000 26.725543 16
## [39] {wine,long} => {bakery} 0.001626843 1.0000000 26.725543 16
## [40] {bar,shopping} => {bags} 0.003050330 1.0000000 10.128733 30
## [41] {product,shopping} => {life} 0.002338587 1.0000000 26.725543 23
## [42] {product,shopping} => {bakery} 0.002338587 1.0000000 26.725543 23
## [43] {product,shopping} => {bags} 0.002338587 1.0000000 10.128733 23
## [44] {products,shopping} => {bags} 0.003660397 1.0000000 10.128733 36
## [45] {beer,long} => {life} 0.002440264 1.0000000 26.725543 24
## [46] {beer,long} => {bakery} 0.002440264 1.0000000 26.725543 24
## [47] {articles,shopping} => {bags} 0.003457041 1.0000000 10.128733 34
## [48] {milk,butter,whipped/sour} => {vegetables,whole} 0.002338587 0.7187500 7.520113 23
## [49] {product,specialty} => {life} 0.002541942 1.0000000 26.725543 25
## [50] {product,specialty} => {bakery} 0.002541942 1.0000000 26.725543 25
## [51] {beer,shopping} => {bags} 0.006914082 1.0000000 10.128733 68
## [52] {snack,long} => {life} 0.003355363 1.0000000 26.725543 33
## [53] {snack,long} => {bakery} 0.003355363 1.0000000 26.725543 33
## [54] {juice,long} => {life} 0.004270463 1.0000000 26.725543 42
## [55] {juice,long} => {bakery} 0.004270463 1.0000000 26.725543 42
## [56] {canned} => {beer} 0.026537875 0.8080495 9.586450 261
## [57] {product} => {life} 0.013218099 1.0000000 26.725543 130
## [58] {product} => {bakery} 0.013218099 1.0000000 26.725543 130
## [59] {life} => {bakery} 0.037417387 1.0000000 26.725543 368
## [60] {bakery} => {life} 0.037417387 1.0000000 26.725543 368
## [61] {long,
## product} => {life} 0.001118454 1.0000000 26.725543 11
## [62] {long,
## product} => {bakery} 0.001118454 1.0000000 26.725543 11
## [63] {life,
## long} => {bakery} 0.001830198 1.0000000 26.725543 18
## [64] {bakery,
## long} => {life} 0.001830198 1.0000000 26.725543 18
## [65] {life,
## product,newspapers} => {bakery} 0.001220132 1.0000000 26.725543 12
## [66] {bakery,
## product,newspapers} => {life} 0.001220132 1.0000000 26.725543 12
## [67] {bread,long,
## life} => {bakery} 0.001220132 1.0000000 26.725543 12
## [68] {bakery,
## bread,long} => {life} 0.001220132 1.0000000 26.725543 12
## [69] {beverages,long,
## life} => {bakery} 0.001220132 1.0000000 26.725543 12
## [70] {bakery,
## beverages,long} => {life} 0.001220132 1.0000000 26.725543 12
## [71] {life,
## product,chocolate} => {bakery} 0.001626843 1.0000000 26.725543 16
## [72] {bakery,
## product,chocolate} => {life} 0.001626843 1.0000000 26.725543 16
## [73] {product,
## water,long} => {life} 0.001220132 1.0000000 26.725543 12
## [74] {life,
## water,long} => {product} 0.001220132 0.7058824 53.402715 12
## [75] {product,
## water,long} => {bakery} 0.001220132 1.0000000 26.725543 12
## [76] {bakery,
## water,long} => {product} 0.001220132 0.7058824 53.402715 12
## [77] {life,
## water,long} => {bakery} 0.001728521 1.0000000 26.725543 17
## [78] {bakery,
## water,long} => {life} 0.001728521 1.0000000 26.725543 17
## [79] {life,
## wine,long} => {bakery} 0.001626843 1.0000000 26.725543 16
## [80] {bakery,
## wine,long} => {life} 0.001626843 1.0000000 26.725543 16
## [81] {life,
## product,shopping} => {bakery} 0.002338587 1.0000000 26.725543 23
## [82] {bakery,
## product,shopping} => {life} 0.002338587 1.0000000 26.725543 23
## [83] {life,
## product,shopping} => {bags} 0.002338587 1.0000000 10.128733 23
## [84] {bags,
## product,shopping} => {life} 0.002338587 1.0000000 26.725543 23
## [85] {bakery,
## product,shopping} => {bags} 0.002338587 1.0000000 10.128733 23
## [86] {bags,
## product,shopping} => {bakery} 0.002338587 1.0000000 26.725543 23
## [87] {keeping,
## products,shopping} => {bags} 0.001016777 1.0000000 10.128733 10
## [88] {beer,long,
## life} => {bakery} 0.002440264 1.0000000 26.725543 24
## [89] {bakery,
## beer,long} => {life} 0.002440264 1.0000000 26.725543 24
## [90] {life,
## product,specialty} => {bakery} 0.002541942 1.0000000 26.725543 25
## [91] {bakery,
## product,specialty} => {life} 0.002541942 1.0000000 26.725543 25
## [92] {beer,shopping,
## canned} => {bags} 0.001118454 1.0000000 10.128733 11
## [93] {bags,
## canned} => {beer,shopping} 0.001118454 0.7333333 106.063725 11
## [94] {life,
## snack,long} => {bakery} 0.003355363 1.0000000 26.725543 33
## [95] {bakery,
## snack,long} => {life} 0.003355363 1.0000000 26.725543 33
## [96] {snack,long,
## vegetables,whole} => {life} 0.001118454 1.0000000 26.725543 11
## [97] {snack,long,
## vegetables,whole} => {bakery} 0.001118454 1.0000000 26.725543 11
## [98] {juice,long,
## product} => {life} 0.001220132 1.0000000 26.725543 12
## [99] {juice,long,
## product} => {bakery} 0.001220132 1.0000000 26.725543 12
## [100] {juice,long,
## life} => {bakery} 0.004270463 1.0000000 26.725543 42
## [101] {bakery,
## juice,long} => {life} 0.004270463 1.0000000 26.725543 42
## [102] {fruit,root,
## milk,yogurt,whipped/sour} => {vegetables,whole} 0.001118454 1.0000000 10.462766 11
## [103] {milk,yogurt,whipped/sour,
## vegetables,other} => {vegetables,whole} 0.001220132 1.0000000 10.462766 12
## [104] {keeping,
## life} => {bakery} 0.001118454 1.0000000 26.725543 11
## [105] {bakery,
## keeping} => {life} 0.001118454 1.0000000 26.725543 11
## [106] {life,
## plants} => {bakery} 0.001220132 1.0000000 26.725543 12
## [107] {bakery,
## plants} => {life} 0.001220132 1.0000000 26.725543 12
## [108] {life,
## product} => {bakery} 0.013218099 1.0000000 26.725543 130
## [109] {bakery,
## product} => {life} 0.013218099 1.0000000 26.725543 130
## [110] {product,
## vegetables,whole} => {life} 0.001423488 1.0000000 26.725543 14
## [111] {product,
## vegetables,whole} => {bakery} 0.001423488 1.0000000 26.725543 14
## [112] {bar,
## life} => {bakery} 0.001016777 1.0000000 26.725543 10
## [113] {bakery,
## bar} => {life} 0.001016777 1.0000000 26.725543 10
## [114] {milk,frozen,
## other} => {vegetables,whole} 0.001118454 0.7333333 7.672695 11
## [115] {fruit,other,
## milk,frozen} => {vegetables,whole} 0.001118454 0.7857143 8.220745 11
## [116] {cheese,domestic,
## fruit,root} => {vegetables,whole} 0.001016777 0.7692308 8.048282 10
## [117] {cheese,domestic,
## vegetables,other} => {vegetables,whole} 0.001118454 0.7333333 7.672695 11
## [118] {milk,whipped/sour,
## vegetables,other} => {vegetables,whole} 0.001118454 1.0000000 10.462766 11
## [119] {life,
## vegetables,frozen} => {bakery} 0.001321810 1.0000000 26.725543 13
## [120] {bakery,
## vegetables,frozen} => {life} 0.001321810 1.0000000 26.725543 13
## [121] {life,
## products} => {bakery} 0.001016777 1.0000000 26.725543 10
## [122] {bakery,
## products} => {life} 0.001016777 1.0000000 26.725543 10
## [123] {pip,
## vegetables,other} => {fruit,root} 0.001016777 0.9090909 25.545455 10
## [124] {life,
## root} => {bakery} 0.001118454 1.0000000 26.725543 11
## [125] {bakery,
## root} => {life} 0.001118454 1.0000000 26.725543 11
## [126] {fruit,tropical,
## vegetables,other} => {fruit,root} 0.002440264 0.7058824 19.835294 24
## [127] {fruit,tropical,
## life} => {bakery} 0.001118454 1.0000000 26.725543 11
## [128] {bakery,
## fruit,tropical} => {life} 0.001118454 1.0000000 26.725543 11
## [129] {cheese,frozen,
## fruit,root} => {vegetables,whole} 0.001830198 0.7500000 7.847074 18
## [130] {cheese,frozen,
## vegetables,other} => {vegetables,whole} 0.002236909 0.7333333 7.672695 22
## [131] {cheese,frozen,
## life} => {bakery} 0.001931876 1.0000000 26.725543 19
## [132] {bakery,
## cheese,frozen} => {life} 0.001931876 1.0000000 26.725543 19
## [133] {life,
## other} => {bakery} 0.001728521 1.0000000 26.725543 17
## [134] {bakery,
## other} => {life} 0.001728521 1.0000000 26.725543 17
## [135] {fruit,whole,
## life} => {bakery} 0.002033554 1.0000000 26.725543 20
## [136] {bakery,
## fruit,whole} => {life} 0.002033554 1.0000000 26.725543 20
## [137] {fruit,pip,
## vegetables,other} => {fruit,root} 0.002745297 0.7941176 22.314706 27
## [138] {fruit,pip,
## life} => {bakery} 0.002440264 1.0000000 26.725543 24
## [139] {bakery,
## fruit,pip} => {life} 0.002440264 1.0000000 26.725543 24
## [140] {fruit,other,
## life} => {bakery} 0.002033554 1.0000000 26.725543 20
## [141] {bakery,
## fruit,other} => {life} 0.002033554 1.0000000 26.725543 20
## [142] {tropical,
## vegetables,other} => {fruit,root} 0.002033554 0.7692308 21.615385 20
## [143] {life,
## tropical} => {bakery} 0.002135231 1.0000000 26.725543 21
## [144] {bakery,
## tropical} => {life} 0.002135231 1.0000000 26.725543 21
## [145] {life,
## whole} => {bakery} 0.002440264 1.0000000 26.725543 24
## [146] {bakery,
## whole} => {life} 0.002440264 1.0000000 26.725543 24
## [147] {citrus,
## vegetables,other} => {fruit,root} 0.002440264 0.8571429 24.085714 24
## [148] {citrus,
## life} => {bakery} 0.002338587 1.0000000 26.725543 23
## [149] {bakery,
## citrus} => {life} 0.002338587 1.0000000 26.725543 23
## [150] {fruit,root,
## life} => {bakery} 0.002033554 1.0000000 26.725543 20
## [151] {bakery,
## fruit,root} => {life} 0.002033554 1.0000000 26.725543 20
## [152] {life,
## vegetables,other} => {bakery} 0.002745297 1.0000000 26.725543 27
## [153] {bakery,
## vegetables,other} => {life} 0.002745297 1.0000000 26.725543 27
## [154] {bags,
## life} => {bakery} 0.005388917 1.0000000 26.725543 53
## [155] {bags,
## bakery} => {life} 0.005388917 1.0000000 26.725543 53
## [156] {life,
## vegetables,whole} => {bakery} 0.006609049 1.0000000 26.725543 65
## [157] {bakery,
## vegetables,whole} => {life} 0.006609049 1.0000000 26.725543 65
## [158] {life,
## long,
## product} => {bakery} 0.001118454 1.0000000 26.725543 11
## [159] {bakery,
## long,
## product} => {life} 0.001118454 1.0000000 26.725543 11
## [160] {life,
## product,
## water,long} => {bakery} 0.001220132 1.0000000 26.725543 12
## [161] {bakery,
## product,
## water,long} => {life} 0.001220132 1.0000000 26.725543 12
## [162] {bakery,
## life,
## water,long} => {product} 0.001220132 0.7058824 53.402715 12
## [163] {bakery,
## life,
## product,shopping} => {bags} 0.002338587 1.0000000 10.128733 23
## [164] {bags,
## life,
## product,shopping} => {bakery} 0.002338587 1.0000000 26.725543 23
## [165] {bags,
## bakery,
## product,shopping} => {life} 0.002338587 1.0000000 26.725543 23
## [166] {life,
## snack,long,
## vegetables,whole} => {bakery} 0.001118454 1.0000000 26.725543 11
## [167] {bakery,
## snack,long,
## vegetables,whole} => {life} 0.001118454 1.0000000 26.725543 11
## [168] {juice,long,
## life,
## product} => {bakery} 0.001220132 1.0000000 26.725543 12
## [169] {bakery,
## juice,long,
## product} => {life} 0.001220132 1.0000000 26.725543 12
## [170] {life,
## product,
## vegetables,whole} => {bakery} 0.001423488 1.0000000 26.725543 14
## [171] {bakery,
## product,
## vegetables,whole} => {life} 0.001423488 1.0000000 26.725543 14
## [172] {citrus,
## fruit,tropical,
## vegetables,other} => {fruit,root} 0.001016777 0.7142857 20.071429 10
## [173] {life,
## other,
## vegetables,whole} => {bakery} 0.001118454 1.0000000 26.725543 11
## [174] {bakery,
## other,
## vegetables,whole} => {life} 0.001118454 1.0000000 26.725543 11
## [175] {fruit,pip,
## vegetables,other,
## vegetables,whole} => {fruit,root} 0.001626843 0.7619048 21.409524 16
## [176] {fruit,other,
## life,
## vegetables,whole} => {bakery} 0.001220132 1.0000000 26.725543 12
## [177] {bakery,
## fruit,other,
## vegetables,whole} => {life} 0.001220132 1.0000000 26.725543 12
## [178] {citrus,
## vegetables,other,
## vegetables,whole} => {fruit,root} 0.001220132 0.8571429 24.085714 12
## [179] {fruit,root,
## life,
## vegetables,other} => {bakery} 0.001220132 1.0000000 26.725543 12
## [180] {bakery,
## fruit,root,
## vegetables,other} => {life} 0.001220132 1.0000000 26.725543 12
## [181] {life,
## vegetables,other,
## vegetables,whole} => {bakery} 0.001118454 1.0000000 26.725543 11
## [182] {bakery,
## vegetables,other,
## vegetables,whole} => {life} 0.001118454 1.0000000 26.725543 11
## [183] {bags,
## life,
## vegetables,whole} => {bakery} 0.001016777 1.0000000 26.725543 10
## [184] {bags,
## bakery,
## vegetables,whole} => {life} 0.001016777 1.0000000 26.725543 10
red_rules <- is.redundant(gr_rules) #redundant한 rule이 있다.
summary(red_rules) #109 개나 있다
## Mode FALSE TRUE
## logical 75 109
gr_red_rules <- gr_rules[!red_rules] #redundant 하면 빼자
gr_rules #184개의 룰이
## set of 184 rules
gr_red_rules #75개로 줄어들었음
## set of 75 rules
gr_rules_bakery <- apriori(raw,
parameter = list(supp = 0.001, conf = .45),
appearance = list(default = "rhs", lhs = "bakery"))
## Apriori
##
## Parameter specification:
## confidence minval smax arem aval originalSupport maxtime support minlen
## 0.45 0.1 1 none FALSE TRUE 5 0.001 1
## maxlen target ext
## 10 rules FALSE
##
## Algorithmic control:
## filter tree heap memopt load sort verbose
## 0.1 TRUE TRUE FALSE TRUE 2 TRUE
##
## Absolute minimum support count: 9
##
## set item appearances ...[1 item(s)] done [0.00s].
## set transactions ...[6871 item(s), 9835 transaction(s)] done [0.04s].
## sorting and recoding items ... [477 item(s)] done [0.00s].
## creating transaction tree ... done [0.00s].
## checking subsets of size 1 2 done [0.00s].
## writing ... [1 rule(s)] done [0.00s].
## creating S4 object ... done [0.00s].
inspect(gr_rules_bakery) #왼쪽에 빵이 있는 룰을 알아봤다.
## lhs rhs support confidence lift count
## [1] {bakery} => {life} 0.03741739 1 26.72554 368
plot(gr_red_rules, method = "graph", engine = 'interactive') #rule을 plot하기
#plot(gr_red_rules, method = "graph", interactive = T)
#문서요약을 해보자 다음번엔