Quantcast
Channel: グラフ - 廿TT
Viewing all articles
Browse latest Browse all 123

R {arules} によるアソシエーション分析の結果をどうやったら見やすく表示できるか試行錯誤中

$
0
0
library(arules)library(cowplot)
data("Adult")

rules <- apriori(Adult, 
                 parameter =list(supp =0.5,conf =0.9,target ="rules",maxlen=2))
rules_lhs <-as(lhs(rules),"list")#条件部
rules_rhs <-as(rhs(rules),"list")#結論部
rules_lhs <- sapply(rules_lhs,function(x)ifelse(length(x)==0,"",x))
lhs_len <-sapply(rules_lhs,length)
item_rhs <- unlist(rules_lhs)
rules_df <-as(rules,"data.frame")
rules_df2 <-data.frame(lhs=unlist(rules_lhs),
                      rhs=rep(unlist(rules_rhs),lhs_len),
                      support=rep(rules_df$support,lhs_len))
ggplot(rules_df2,aes(x = rhs, y = lhs))+
  geom_tile(aes(fill=support))

f:id:abrahamcow:20161106200218p:plain


Viewing all articles
Browse latest Browse all 123

Trending Articles