2015-04-01 58 views
0

有沒有辦法在arule包中由apriori生成的單個規則中使用多於一個單一變量級別的變量?從arules中對規則進行後處理

請看下面的例子:

df <- read.table(header = TRUE, text = ' 
V1 V2 V3 
a d x 
a d x   
a d y   
b d x  
b d x  
b d y 
a e y 
a e y 
a e x 
b e y 
b e y 
b e x 
c d y 
') 

library(arules)  
rules <- apriori(df, 
       parameter = list(support= 0.001, confidence = 0.5, target = "rules"), 
       appearance = list(rhs=c("V3=x"), default = 'lhs')) 
inspect(sort(rules, decreasing = TRUE, by = "confidence")) 

輸出>

lhs  rhs  support confidence  lift 
1 {V1=a,           
    V2=d} => {V3=x} 0.1538462 0.6666667 1.444444 
2 {V1=b,           
    V2=d} => {V3=x} 0.1538462 0.6666667 1.444444 
3 {V2=d} => {V3=x} 0.3076923 0.5714286 1.238095 
4 {V1=a} => {V3=x} 0.2307692 0.5000000 1.083333 
5 {V1=b} => {V3=x} 0.2307692 0.5000000 1.083333 

在這個例子中,它會幫助,如果我得到規則{V1=a,b,V2=d}。其他一些工具(例如LISp-Miner)可以在使用多個級別的變量時生成規則。

回答

1

arules遵循標準關聯規則挖掘文獻,並不以這種方式聚合項目。 Itemsets包含或不包含項目。因此,除非您手動添加人造物品V1=aORb,否則您會陷入兩條規則。