0
votes

I am trying to do Market basket analysis using apriori and I an stuck at a point. My entire products catalogue is divided into two parts x and y. I wish to find those rules A->B where A always contains at least an item from x and B at least an item from y. I am trying to adjust the appearance variable .

association.rules <- apriori(tr, parameter = list(supp=0.001, conf=0.8),appearance =list(lhs= "*something*",rhs="*something*"))

So that lhs contains at least one product from x and can have zero or more products from y. Similarly rhs must contain at least one product from yand can have zero or more products from x.

How should I adjust the lhs and rhs values of appearance parameter in apriori algorithm ?

1
What exactly is your question? Please do not answer here - update your post accordingly...desertnaut
@desertnaut have updated the postAkanksha Gupta

1 Answers

1
votes

From the examples in ?APappearance:

library(arules)
data("Adult")

## find only rules with income-related variables in the right-hand-side.
incomeItems <- grep("^income=", itemLabels(Adult), value = TRUE)
incomeItems
rules <- apriori(Adult, parameter = list(support=0.2, confidence = 0.5), 
  appearance = list(rhs = incomeItems))
inspect(head(rules))

incomeItems is your y and all other items are your x. RHS can only contain the items in y and LHS can only contain the other items (x).