1
$\begingroup$

Using R and arules. I see several opinions on how to remove redundant rules which give different answers.

If this is my example dataset:

    lhs                rhs                support confidence lift 
[1] {r7sVi9T6D1nE}  => {hN1sUFRI}         0.0013  0.80       210.9
[2] {hN1sUFRI}      => {r7sVi9T6D1nE}     0.0013  0.33       210.9
[3] {8l0QeRHU0CWLP} => {XUFbPOzrmrKJgcmi} 0.0016  0.56         5.8
[4] {9f7J8ox1}      => {YTeK1f0yQd9hvPz2} 0.0016  0.36         2.1
[5] {NCzMaUfT}      => {eByLP-ea}         0.0022  0.47        77.7
[6] {eByLP-ea}      => {NCzMaUfT}         0.0022  0.37        77.7
[7] {sUvng3}        => {8D4AhPCsnBT}      0.0016  0.36         9.2

The most common approach I've seen is:

# source: http://www.rdatamining.com/examples/association-rules
rules <- sort(rules, by = 'lift')
subset.matrix <- is.subset(rules, rules)
subset.matrix[lower.tri(subset.matrix, diag=T)] <- NA
redundant <- colSums(subset.matrix, na.rm = TRUE) >= 1
which(redundant)
rules <- rules[!redundant]

Outputs:

    lhs                rhs                support confidence lift 
[1] {r7sVi9T6D1nE}  => {hN1sUFRI}         0.0013  0.80       210.9
[2] {eByLP-ea}      => {NCzMaUfT}         0.0022  0.37        77.7
[3] {sUvng3}        => {8D4AhPCsnBT}      0.0016  0.36         9.2
[4] {8l0QeRHU0CWLP} => {XUFbPOzrmrKJgcmi} 0.0016  0.56         5.8
[5] {9f7J8ox1}      => {YTeK1f0yQd9hvPz2} 0.0016  0.36         2.1

However, arules provides is.redundant:

Provides the generic functions and the S4 method is.redundant to find redundant rules.

If I do in RStudio console:

> is.redundant(rules)
[1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE

Rules all show FALSE indicating no rules are considered redundant.

Another source shows the following approach to remove redundant rules:

# source: http://rstatistics.net/association-mining-with-r/
redundant <- which (colSums (is.subset (rules, rules)) > 1) # get redundant rules in vector
rules <- rules[-redundant] # remove redundant rules

But this produces different outputted results than above:

    lhs                rhs                support confidence lift
[1] {8l0QeRHU0CWLP} => {XUFbPOzrmrKJgcmi} 0.0016  0.56       5.8 
[2] {9f7J8ox1}      => {YTeK1f0yQd9hvPz2} 0.0016  0.36       2.1 
[3] {sUvng3}        => {8D4AhPCsnBT}      0.0016  0.36       9.2 

Which Approach Is Right And Correct?

$\endgroup$

closed as off-topic by rolando2, Peter Flom Apr 26 '17 at 22:11

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question appears to be off-topic because EITHER it is not about statistics, machine learning, data analysis, data mining, or data visualization, OR it focuses on programming, debugging, or performing routine operations within a statistical computing platform. If the latter, you could try the support links we maintain." – rolando2, Peter Flom
If this question can be reworded to fit the rules in the help center, please edit the question.

0
$\begingroup$

I dont think the last approach is right. Looking at your output, the last approach removes the non redundant rules as well. For me the 1st approach gave me an empty set.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.