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?
I was tring to do read.transactions
or mbr_no type conversion in other ways
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. You need to discretize the continuous variable. as.factor
will not do this, but assign a level to each distinct value of the variable. So you should do something like this instead:
aa$mbr_no <- discretize(aa$mbr_no)
discretize
is part of the arules
package (see ? discretize
).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.