我是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在这种格式下不会做任何事情。我找到了这个来寻求帮助:How to prep transaction data into basket for 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].
我在做错什么吗,或者做这件事的另一种方式?谢谢!