Good afternoon,
I'm conducting Market Basket analysis at the moment and I have reduced the LHS rules down to the top 15 most frequently bought items, and this has worked well using the following code:
rules2 <- apriori(bb_pivot,
parameter = list(minlen=2,maxlen=3,conf=0.95),
appearance = list(lhs=c("Coffee=1",
"Bread=1",
"Tea=1",
"Cake=1",
"Pastry=1",
"Sandwich=1",
"Medialuna=1",
"Hot chocolate=1",
"Cookies=1",
"Brownie=1",
"Farm House=1",
"Muffin=1",
"Alfajores=1",
"Juice=1",
"Soup=1"),
default="rhs"))
However, I am only interested in the rules that are generated when other items are bought with these top 15 items, not the times when they were bought in the absence of another item. The rules I've generated with the above code mostly follow the below output:
lhs rhs support confidence coverage lift count
[1] {Cake=1} => {Medialuna=0} 0.1001585 0.9643947 0.1038563 1.0279275 948
[2] {Cake=1} => {Farm House=0} 0.1023772 0.9857579 0.1038563 1.0259730 969
[3] {Cake=1} => {Toast=0} 0.1016376 0.9786368 0.1038563 1.0126596 962
[4] {Cake=1} => {Scandinavian=0} 0.1023772 0.9857579 0.1038563 1.0152555 969
[5] {Cake=1} => {Truffles=0} 0.1012150 0.9745677 0.1038563 0.9947463 958
Is there a way for me to only select rules based on the RHS being 'yes/1', without coding for the 94 different items in my set on the RHS?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…