我正在尝试使用 package.json 进行市场篮子分析arules
。但是,我在使用apriori
算法的时候,R
报了如下信息。
dt <- split(deviceshowlist$prog_title, deviceshowlist$device_id)
dt2 <- as(dt,"transactions")
rules <- apriori(dt2, parameter = list(support = 0.01, confidence = 0.05, minlen=2))
先验的
参数规格:
print.default(参数)中的错误:尝试应用非功能
我查看了我的交易数据结构和 apriori 的功能。似乎没有什么不妥。请希望有人以前遇到过类似的问题并可以帮助我。
谢谢
我的dt和dt2的结构更新如下
> str(dt)
List of 5388
$ 000000006201 : chr [1:2] "Modern Family" "Criminal Minds"
$ 0000000080ed : chr [1:5] "Blindspot" "Supergirl" "The Simpsons" "The Big Bang Theory" ...
$ 000000009c7b : chr [1:9] "Criminal Minds" "The Big Bang Theory" "Life in Pieces" "Limitless" ...
$ 000000009e56 : chr [1:7] "Friends" "2 Broke Girls" "Best Time Ever With Neil Patrick Harris" "Blindspot" ...
> str(dt2)
Formal class 'transactions' [package "arules"] with 3 slots
..@ data :Formal class 'ngCMatrix' [package "Matrix"] with 5 slots
.. .. ..@ i : int [1:25272] 10 21 5 21 27 30 35 0 8 10 ...
.. .. ..@ p : int [1:5389] 0 2 7 16 23 24 32 39 40 50 ...
.. .. ..@ Dim : int [1:2] 37 5388
.. .. ..@ Dimnames:List of 2
.. .. .. ..$ : NULL
.. .. .. ..$ : NULL
.. .. ..@ factors : list()
..@ itemInfo :'data.frame': 37 obs. of 1 variable:
.. ..$ labels: chr [1:37] "2 Broke Girls" "Agent X" "Ash vs Evil Dead" "Benders" ...
..@ itemsetInfo:'data.frame': 5388 obs. of 1 variable:
.. ..$ transactionID: chr [1:5388] "000000006201" "0000000080ed" "000000009c7b" "000000009e56" ...
device_id prog_title
1 0000000080ed Blindspot
2 0000000080ed Supergirl
3 000000009c7b Life in Pieces
4 000000009c7b Limitless
5 000000009c7b Quantico
6 000000009c7b Code Black
7 000000009c7b The Muppets
8 000000009c7b Supergirl