有沒有一種方法可以使用arulesSequence的ruleInduction輸出使用arulesViz?或者是否有辦法強制/將序列規則輸出(類sequencerules)轉換爲類規則,所以我可以使用arulesViz?使用arulesViz繪製arulesSequences的輸出?或者,將類序列對象強制轉換爲規則的方法? (arulesSequence,R)
目標:我有興趣使用本文中回顧的一些可視化選項,特別是「圖表」選項(https://cran.r-project.org/web/packages/arulesViz/vignettes/arulesViz.pdf)。
通常你會使用arulesViz從arules衍生,像這樣的 「規則」(從暗角):
rules <- apriori(Groceries, parameter=list(support=0.001, confidence=0.5))
plot(x, method = NULL, measure = "support", shading = "lift",
+ interactive = FALSE, data = NULL, control = NULL, ...)
但我想用它cspade + ruleInduction的輸出:
s1 <- cspade(trans, parameter = list(support = 0.001,maxlen=3,maxgap=10), control = list(verbose = TRUE,numpart=1))
summary(s1)
s1_df <- as(s1, "data.frame")
r1 <- ruleInduction(s1, confidence = 0.05, control = list(verbose = TRUE))
r1.subset.rule <- subset(r1, rhs(r1) %in% c("9990") & lift>2 & !lhs(r1) %in% c("300","301","412","4033","4043"))
plot(r1.subset.rule,method="graph",control=list(alpha=1))
Error in as.double(y) :
cannot coerce type 'S4' to vector of type 'double'
有沒有辦法做到這一點?我目前得到上述錯誤。請注意,這與此問題類似:Error in as.double(y) : cannot coerce type 'S4' to vector of type 'double'但在那裏提出的解決方案(確保已加載arulesViz)不起作用/不是問題。
謝謝你的幫助!
如果您覺得這不是一個合適的問題,請留下我的反饋意見/評論 - 我在這裏發表了幾個小時的研究,並且是一個新用戶:我會很高興聽到這可以是改進。