我有一个大数据集(0和1的矩阵),具有200个变量(每个变量是一个项目)和近1M行(每行是一个事务).我在R中使用"arules"包进行关联规则挖掘.我考虑了 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"))但是此代码创建的规则在规则的左侧仅包含itemA,仅itemB或仅包含这两个规则.如果您能帮助我,我非常感谢.
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.
推荐答案我猜这段代码对您有用:
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"))更多推荐
在R中使用规则创建特定规则
发布评论