Creating specific rules with arules in r

吃可爱长大的小学妹 提交于 2019-12-11 01:53:40

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!