omranian at uni-potsdam.de
2010-Feb-18 10:27 UTC
[R] how to change number of itemes appeare in right-hand-side of the rule with apriori in R(arules)?
Hi All, I use arules library, and try to create an association rules for this transaction file: a,c,f,3,4,5 b,e,1,2,4 a,c,e,f,1,3,4,5 d,5 b,c,e,f,1,2,3,4 a,c,e,f,1,3,4,5 b,c,e,f,1,3,4 b,e,1,2,4 a,c,e,f,1,3,4,5 a,b,c,e,f,1,3,4 a,c,d,f,3,4,5 I want to get the rule such: {c,e,f}=> {3,4,5} I used this command: ar=apriori(tr, parameter=list(support=.4, confidence=0.8, maxlen=11), appearance =list(lhs=c("a","b","c","d","e","f"),rhs=c("1","2","3","4","5"))) and I just get the rule such: {c,e,f} => {3} {c,e,f} => {4} and the number of items appear in the right hand side of the rules is always 1. but I want to see more than 1 item in the right hand side of the rules such left hand size.in the left hand side I can see 1, 2 or 5 item but in the rhs just one. I need to have more than 1 item in rhs. thanks a lot Nooshin
Michael Hahsler
2010-Feb-18 14:53 UTC
[R] how to change number of itemes appeare in right-hand-side of the rule with apriori in R(arules)?
Nooshin, arules currently only implements mining algorithms that produce rules with one item in the right-hand-side (RHS) (apriori, ruleInduction). If you need rules with more than one items then you can mine frequent itemsets (with eclat or apriori). Then you take each itemset, e.g., {1, 2, 3} and you can create the rules {1} -> {2, 3}, {2} -> {1, 3}, etc. You can calculate the the confidence of the rules by support(itemset) / support(lhs). This is not very efficient since the number of possible rules to check will be very high. That is why most algorithms only mine rules with one item in the RHS. Hope that helps, Michael -- Michael Hahsler email: michael at hahsler.net web: http://michael.hahsler.net