I'm using Arules library in R to generate rules:
rules = apriori(data = dataset, parameter = list(support = 0.001, confidence = 0.6, minlen=2))
I understand the minlen=2
avoids rules of the form {} => {beer}
.
In arules, is it possible to restrict rules such that LHS and RHS only has a
single item? (i.e. Avoiding rules {milk, nappies} => {beer}
)
Alternatively, is the rule {milk, nappies} => {beer}
equivalent to
saying {milk} => {beer}
and {nappies} => {beer}
?
Any help is appreciated!
I would filter the rules for rules having exactly one item on the LHS.
rules <- rules[sapply(
1:length(rules)
,function(x) length(as(rules@lhs, "list")[[x]])) == 1];
I think, assuming conditional independence of {beer}
and {milk}
, the rule {milk, nappies} => {beer}
is equivalent to saying {nappies} => {beer}
, and assuming conditional independence of {beer}
and {nappies}
, the rule {milk, nappies} => {beer}
is equivalent to the rule {milk} => {beer}
.