2

I have a large data set (matrix of 0s and 1s) with 200 variables(each variable is an item) and almost 1M rows (each row is a transaction). I use "arules" package in R for association rule mining. I considered 2 items and I want to create all the rules that have at least one of them at the left hand side of the rule. The code that I wrote is:

rules <- apriori(data, parameter = list(support = 0.1, confidence = 0.1,
minlen =2),appearance = list(lhs=c("itemA=1","itemB=1"),default="rhs"))

But this code creates the rules that have only itemA, only itemB, or only both of them at the left hand side of the rules. I really appreciate if you could help me.

Mark Olson
  • 55
  • 1
  • 4
  • when you said minlen=2 how it is possible to return one item rules like itemA or itemB? – MTT Aug 08 '13 at 17:25
  • minlen is for both lhs and rhs. So for example it returns itemA -> itemC . Which its length is 2 because totally we have 2 items. – Mark Olson Aug 08 '13 at 21:34

1 Answers1

3

I guess this code works for you:

rules <- apriori(data, parameter = list(support = 0.1, confidence = 0.1,minlen =2))
subrules <- subset(rules, subset = lhs %in% c("itemA=1","itemB=1"))
Mehrdad Rohani
  • 181
  • 1
  • 1
  • 12