我是 Windows 10 机器上的 R 版本 3.4.4,从看起来像这样的 CSV 开始。它有 4247 个条目:
student_id course
1 1 EC402
2 2 EC403
3 3 EC403
4 4 FI201
5 4 LA321
6 4 LA325
我知道 R 不会以这种格式对它做任何事情。我找到了这个寻求帮助:如何为 arules 准备交易数据到购物篮
所以我将它应用于我的数据框:
require(arules)
trans <- as(split(df[,"course"],df[,"student_id"],), "transactions")
我去检查交易,到目前为止,一切都很好。这是一个小片段:
[14] {MG900,MK605} 14
[15] {AC103,EC402,QA811} 15
[16] {EC403,LA301} 16
[17] {EC408} 17
[18] {AC111,AC115,LA325,MG503} 18
[19] {EC403} 19
[20] {QA811} 20
[21] {MG962} 21
[22] {AC104,FI201,MG535,MG565} 22
[23] {FI234,FI253,PO000} 23
[24] {EC411} 24
[25] {CO810,MK611,PO000,SP596} 25
但是现在我想获得一些关联规则,它给了我零规则。
rules <- apriori(trans, parameter = list(supp = 0.2, conf = 0.8))
输出:
Parameter specification:
confidence minval smax arem aval originalSupport maxtime support minlen
0.8 0.1 1 none FALSE TRUE 5 0.2 1
maxlen target ext
10 rules FALSE
Algorithmic control:
filter tree heap memopt load sort verbose
0.1 TRUE TRUE FALSE TRUE 2 TRUE
Absolute minimum support count: 329
set item appearances ...[0 item(s)] done [0.00s].
set transactions ...[153 item(s), 1645 transaction(s)] done [0.00s].
sorting and recoding items ... [0 item(s)] done [0.00s].
creating transaction tree ... done [0.00s].
checking subsets of size 1 done [0.00s].
writing ... [0 rule(s)] done [0.00s].
creating S4 object ... done [0.00s].
有什么我做错了,或者可能是不同的方式吗?谢谢!