cSPADE data mining in R using arulesSequences - Error while converting to “transactions” format

雨燕双飞 提交于 2020-01-03 04:07:09

问题


I'm having trouble converting my data into cSPADE compatible format.

My data frame looks like-

 key type1 type2 type3 
 A-1  A     B     C
 B-2  P     Q    NA
 C-3  X     NA   NA

When I use, dataset1<- as(dataset, "transactions") and run-

rules<- cspade(dataset1, parameter = list(support = 0.4), control = list(verbose = TRUE))

It throws an error - Error in cspade(dataset1, parameter = list(support = 0.4), control = list(verbose = TRUE)) : slot transactionInfo: missing 'sequenceID' or 'eventID'

Can anyone please help as to how can the above dataset be converted into the cSPADE compatible format?


回答1:


itry with this:

source dataset in this format:

1 3 A B C
2 2 P Q    
3 1 X

the first column is for the id of sequence, the second columns is for the length of sequence and then the elements of sequences. Then:

data <- read_baskets(con = "./input_file.txt", info = c("sequenceID","eventID","SIZE"))
rules<- cspade(data, parameter = list(support = 0.4), control = list(verbose = TRUE))

let me know if this works.

This is my output:

parameter specification:
support : 0.4
maxsize :  10
maxlen  :  10

algorithmic control:
bfstype  : FALSE
verbose  :  TRUE
summary  : FALSE
tidLists : FALSE

preprocessing ... 1 partition(s), 0 MB [0.1s]
mining transactions ... 0 MB [0.06s]
reading sequences ... [0s]

total elapsed time: 0.16s

 > inspect(rules)
items   support 
1 <{B}> 0.3333333 
2 <{C}> 0.3333333 
3 <{Q}> 0.3333333 
4 <{B,   
 C}> 0.3333333


来源:https://stackoverflow.com/questions/27395786/cspade-data-mining-in-r-using-arulessequences-error-while-converting-to-trans

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!