为关联规则创建交互式副坐标图

Create Interactive paracoord plot for association rules

我已经用先验算法创建了一个关联规则模型,我有两个问题:

1) 我可以在模型可视化中使用 "graph" 绘图的任何交互式绘图吗? 2) 我可以将普通的 "paracoord" Plot 转换为交互式 plot_ly "paracoord" 吗?

这是我的示例数据代码:

>summary(topRules)

set of 20 rules

rule length distribution (lhs + rhs):sizes
 4  5  6  7 
 1  4 11  4 

   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
   4.00    5.75    6.00    5.90    6.00    7.00 

summary of quality measures:
    support          confidence          lift           count      
 Min.   :0.01006   Min.   :0.9455   Min.   :1.763   Min.   :164.0  
 1st Qu.:0.01035   1st Qu.:0.9486   1st Qu.:1.772   1st Qu.:168.8  
 Median :0.01098   Median :0.9526   Median :1.781   Median :179.0  
 Mean   :0.01145   Mean   :0.9535   Mean   :2.293   Mean   :186.8  
 3rd Qu.:0.01173   3rd Qu.:0.9561   3rd Qu.:1.796   3rd Qu.:191.2  
 Max.   :0.01631   Max.   :0.9686   Max.   :5.218   Max.   :266.0  

mining info:
 data ntransactions support confidence
   tr         16308    0.01        0.5
plot(topRules, method = "graph")
plot(topRules, method="paracoord",control=list(reorder=TRUE))


toprulesample<- structure(list(rules = structure(c(15L, 16L, 19L, 2L, 9L, 12L, 
3L, 1L, 14L, 4L, 6L, 11L, 5L, 18L, 13L, 7L, 17L, 20L, 10L, 8L
), .Label = c("{Arugula,Carrot,Cucumber,Golden Onion,Green pepper} => {Tomato}", 
"{Arugula,Carrot,frying Potato,Golden Onion,Green pepper} => {Tomato}", 
"{Arugula,Cucumber,frying Potato,Golden Onion,Green pepper} => {Tomato}", 
"{Baladi Cabbage,Coriander,Parsley,Tomato} => {Dill}", "{Baladi Cabbage,Coriander,Parsley} => {Dill}", 
"{Capsicum,Carrot,frying Potato,Green pepper,Red Onion} => {Tomato}", 
"{Capsicum,Coriander,Dill,frying Potato,Golden Onion} => {Tomato}", 
"{Capsicum,Coriander,frying Potato,Golden Onion} => {Tomato}", 
"{Carrot,Cucumber,frying Potato,Green pepper,Red Onion} => {Tomato}", 
"{Carrot,Dill,frying Potato,Green pepper,Local Lemon,Parsley} => {Tomato}", 
"{Carrot,frying Potato,Golden Onion,Green pepper,Local Lemon,Zucchini} => {Tomato}", 
"{Carrot,frying Potato,Golden Onion,Green pepper,NULL,Zucchini} => {Tomato}", 
"{Carrot,frying Potato,Golden Onion,Green pepper,Red Onion} => {Tomato}", 
"{Carrot,frying Potato,Green pepper,Local Banana,Local Lemon,Zucchini} => {Tomato}", 
"{Carrot,frying Potato,Green pepper,Red Onion,Zucchini} => {Tomato}", 
"{Coriander,frying Potato,Green pepper,Local Lemon,Zucchini} => {Tomato}", 
"{Coriander,Parsley,Tomato,White Eggplant} => {Dill}", "{Dill,frying Potato,Green pepper,Local Lemon,Zucchini} => {Tomato}", 
"{frying Potato,Green pepper,Local Lemon,Red Onion,Zucchini} => {Tomato}", 
"{frying Potato,Green pepper,Red Onion,Zucchini} => {Tomato}"
), class = "factor"), support = c(0.0113441255825362, 0.0117120431689968, 
0.0109148883983321, 0.0101790532254108, 0.0123252391464312, 0.0106082904096149, 
0.0103630120186412, 0.0103016924208977, 0.0101790532254108, 0.0111601667893059, 
0.011037527593819, 0.0109148883983321, 0.0142261466764778, 0.0117733627667403, 
0.0102403728231543, 0.010056414029924, 0.0109148883983321, 0.0163110129997547, 
0.0117120431689968, 0.0127544763306353), confidence = c(0.968586387434555, 
0.964646464646465, 0.962162162162162, 0.959537572254335, 0.957142857142857, 
0.955801104972376, 0.954802259887006, 0.954545454545455, 0.954022988505747, 
0.952879581151832, 0.952380952380952, 0.951871657754011, 0.950819672131147, 
0.95049504950495, 0.948863636363636, 0.947976878612717, 0.946808510638298, 
0.94661921708185, 0.945544554455445, 0.945454545454545), lift = c(1.80646235204514, 
1.79911419778757, 1.7944808486437, 1.78958585639567, 1.78511959221017, 
1.78261715689496, 1.78075426054864, 1.78027530566414, 1.77930088020948, 
5.2181196136414, 1.77623840020912, 1.77528854010206, 5.20683922535754, 
1.77272109644633, 1.76967842884471, 1.7680245810174, 5.18487346927111, 
1.76549247394451, 1.76348817406901, 1.76332030275306), count = c(185, 
191, 178, 166, 201, 173, 169, 168, 166, 182, 180, 178, 232, 192, 
167, 164, 178, 266, 191, 208)), .Names = c("rules", "support", 
"confidence", "lift", "count"), row.names = c(42557L, 47757L, 
42552L, 43429L, 42696L, 53931L, 43434L, 43439L, 54111L, 21204L, 
42597L, 53917L, 4762L, 50102L, 42535L, 45432L, 21212L, 26421L, 
53833L, 35432L), class = "data.frame")


plot_ly(toprulesample,type = 'parcoords')

如果您拥有最新版本的 arulesViz(1.3-0 版及更高版本),那么您可以尝试 plot(topRules, method = "graph", engine = "htmlwidget") 获取交互式图表。

最新版本新增了几个互动剧情。查看 https://journal.r-project.org/archive/2017/RJ-2017-047/RJ-2017-047.pdf 以了解更多信息。