[英]r association rules apriori
hh<-read.csv("MT_MBR_CTGR_BUY_PTTRN_DAY.csv")
library(arules)
aa<-subset(hh, select=c(mbr_no,ctgr_flag_nm))
'data.frame': 643241 obs. of 2 variables:
$ mbr_no : num 2.01e+14 2.01e+14 2.01e+14 2.01e+14 2.01e+14 ...
$ ctgr_flag_nm: Factor w/ 7 levels "그린핑거","기저귀",..: 1 4 4 4 4 4 4 4 7 7 ...
aa$mbr_no<-as.factor(aa$mbr_no)
rioter.transaction<-as(aa, "transactions")
rioter.transaction
transactions in sparse format with
643241 transactions (rows) and
178834 items (columns)
rules = apriori(rioter.transaction)
summary(rules)
set of 0 rules
Why do I have 0 rules? 为什么我有0条规则?
I was tring to do read.transactions 我很想读.transactions
or mbr_no type conversion in other ways 或其他方式的mbr_no类型转换
but it still doesn't work 但它仍然不起作用
how can I fix it? 我该如何解决?
Your variable mbr_no
seems to be continuous with 178834-7 different values occurring in your data. 您的变量
mbr_no
似乎是连续的,并且数据中出现了178834-7个不同的值。 You need to discretize the continuous variable. 您需要离散化连续变量。
as.factor
will not do this, but assign a level to each distinct value of the variable. as.factor
不会执行此操作,而是为变量的每个不同值分配一个级别。 So you should do something like this instead: 因此,您应该执行以下操作:
aa$mbr_no <- discretize(aa$mbr_no)
discretize
is part of the arules
package (see ? discretize
). discretize
是arules
软件包的一部分(请参阅? discretize
)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.