Apriori算法使用R生成所有规则

时间:2016-09-10 03:00:44

标签: r apriori arules

这是我在R

中使用arules包生成关联规则的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"))

结果我得到了8条规则。

> 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  

如果我们解决这个问题,我们也可以得到D =&gt; {A,B}作为一项规则。但是,它没有显示在这个程序中。我的代码有什么问题?

1 个答案:

答案 0 :(得分:0)

这是(?apriori)回答你的问题吗?

  

注意:Apriori仅在RHS中创建一个带有一个项目的规则   (因之)!