假设我连接资料库后,导入一个稀疏矩阵如下:
i j x
1 2 3 1
2 3 5 1
3 3 1 1
4 2 5 1
. . . .
. . . .
200000000 . . .
是一个2亿X3大小的稀疏矩阵
我想做关连规则演算,可以直接用稀疏矩阵格式的资料去做吗?
还是一定要转成正常的矩阵才可以用?
我试过以下方式:
channel <- odbcConnect("db")
data<-sqlQuery(channel,"select i,j,x from table")
(args <- data.frame(data))(Aa <- do.call(sparseMatrix, args))
rules <- apriori(Aa)
执行到最后一句出现以下错误:
Error in as(data, "transactions") :
no method or default for coercing “dgCMatrix” to “transactions”
是不是不能直接用arules包的apriori直接处理稀疏矩阵?
应该要套用哪些package 跟哪些class呢?
我有看到:
关联规则(Association Rules):
arules包提供了有效处理稀疏二元数据的数据结构,而且提供函数执Apriori和Eclat算法挖掘频繁项集、最大频繁项集、闭频繁项集和关联规则(http://cran.r-project.org/web/packages/arules/index.html)。
看了itemMatrix-class和tidLists-class
都套不起来
之前都没用过R,在请大家详细指点一下要用哪个包接哪个包语法怎么下?谢谢