为关联规则创建交互式Paracord图

为关联规则创建交互式Paracord图,r,plotly,apriori,arules,R,Plotly,Apriori,Arules,我用apriori算法创建了关联规则模型,我有两个问题: 1) 我可以在模型可视化中使用“图形”绘图的任何交互式绘图吗? 2) 我可以将普通的“paracoord”情节转换为交互式情节吗? 这是我的代码和示例数据: >summary(topRules) 一套20条规则 rule length distribution (lhs + rhs):sizes 4 5 6 7 1 4 11 4 Min. 1st Qu. Median Mean 3rd Qu.

我用apriori算法创建了关联规则模型,我有两个问题:

1) 我可以在模型可视化中使用“图形”绘图的任何交互式绘图吗? 2) 我可以将普通的“paracoord”情节转换为交互式情节吗?

这是我的代码和示例数据:

>summary(topRules)
一套20条规则

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
绘图(topRules,method=“graph”)
绘图(topRules,method=“paracoord”,control=list(reorder=TRUE))

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


现在最新版本中有几个新的交互式绘图可用。查看以了解更多信息。

您的数据属于
数据类。框架
,我们需要做什么才能使这行:
绘图(topRules,method=“graph”)
生成与您收到的绘图相同的绘图?topRules是一组规则,我通过
toprulesamples将其转换为data.frame形式。如果您能提供原始数据和生成
topRules
所用的方法,我认为这将有助于您的问题。这里的许多用户从未使用过软件包
arules
,但他们是
ggplot
绘图方面的专家,能够绘制几乎任何类型的图形。这将很难做到,因为我的数据有很多事务,即使我选择了前100个样本数据,这将是巨大的,并且不能有效地阐明我的模型和可视化。但是这里有一篇文章讨论这个软件包和这个模型。我还没有时间在平行坐标图上做更多的工作。。。希望有一天!
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')