Among generated rules, we sometimes find repeated or redundant rules (for instance, one rule is the super rule of another rule). In this recipe, we will show how to prune (or remove) repeated or redundant rules.
In this recipe, one has to have completed the previous recipe by generating rules and having these stored in a variable named rules
.
Perform the following steps to prune redundant rules:
First, you need to identify the redundant rules:
> rules.sorted = sort(rules, by="lift") > subset.matrix = is.subset(rules.sorted, rules.sorted) > subset.matrix[lower.tri(subset.matrix, diag=T)] = NA > redundant = colSums(subset.matrix, na.rm=T) >= 1
You can then remove the redundant rules:
> rules.pruned = rules.sorted[!redundant] > inspect(rules.pruned) lhs rhs support confidence lift 1 {P0014252070} => {P0014252066} 0.001321491 0.2704403 27.32874 5 {P0014252055} => {P0014252066...