Arun - 1 year ago 87

R Question

Here is my R code for generating association rules using arules package in R

`c1 <- c("A","F","D","B")`

c2 <- c("D","B","A","C","E")

c3 <- c("C","B","A","E")

c4 <- c("B","D","A")

transactions <- list(c1,c2,c3,c4)

rules_b <- apriori(transactions, parameter = list(supp = 0.6, conf = 0.8, target = "rules"))

I'm getting just 8 rules as a result.

`> inspect(rules_b)`

lhs rhs support confidence lift

1 {} => {B} 1.00 1 1

2 {} => {A} 1.00 1 1

3 {D} => {B} 0.75 1 1

4 {D} => {A} 0.75 1 1

5 {B} => {A} 1.00 1 1

6 {A} => {B} 1.00 1 1

7 {B,D} => {A} 0.75 1 1

8 {A,D} => {B} 0.75 1 1

If we solve this, we can also get D => {A,B} as a rule. But, it's not displaying in this program. What's wrong in my code?

Answer Source

Does this(`?apriori`

) answer your question?

Note: Apriori only creates rules with one item in the RHS (Consequent)!