问题
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.
回答1:
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"))
来源:https://stackoverflow.com/questions/18131792/creating-specific-rules-with-arules-in-r