在关联式规则R数据格式错误 [英] data format error in association rule learning R

查看:1292
本文介绍了在关联式规则R数据格式错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图寻找在有关该R其他职位,但没有找到重复的问题(至少我的努力)。我知道我需要在图书馆先验功能(一规则),虽然。

I tried to search other posts in R related to this, but did not find duplicated questions(at least to my efforts). I know I need a priori function in library("a rules") though.

我有一个大阵文件中的每一行是一个list

I have a large array file A that each row is a list

user1:  [1,2,3,4]      # [1,2,3,4] is the itemList purchased by this user
user2:  [4]
................

我想找到的往往是一起购买的物品。我应该如何进行?看来我需要将数据也转换为交易格式的文件。

I want to find items that tend to be purchased together. How should I proceed? It seems I need to convert the data to "transaction" format file also.

所以,我没有

temp <- split(A, 1:nrow(A))   # temp is now a list of lists
B <- as(temp, "transactions")

但我得到了错误错误asMethod(对象):可以强迫只用原子组件列表
任何人都可以帮忙吗?

But I got the error "Error in asMethod(object) : can coerce list with atomic components only" Anyone can help?

我GOOGLE了这个例子,然后运行以下code没有问题

I googled this example and run the following code without problem

a_list <- list(c("I1","I2","I5"), c("I2","I4"), c("I2","I3"), c("I1","I2","I4"), c("I1","I3"),c("I2","I3"),c("I1","I3"),
c("I1","I2","I3","I5"), c("I1","I2","I3") )

names(a_list) <- paste("T",c(1:9), "00", sep = "")
table5_1 <- as(a_list, "transactions")

这两个临时的(在我的code)和的a_list是班级名单,然而

Both of temp (in my code) and a_list are of class list, however

     a_list[1]
[[1]]
[1] "I1" "I2" "I5"

     temp[1]
 $`1`
 $`1`$`1`
 [1] 1,2,3,4

我应该如何纠正呢?这是由于我的临时文件是从数据帧导出的因素是什么?

How should I correct this? Is this due to the factor my temp file was derived from a data frame?

感谢

推荐答案

我有同样的错误,无法弄明白。最后,我意识到,我必须在描述/项目领域未来通过空值。我检查过因为这可能是问题未来空/空字符串(假设您已经对一个事务中删除重复记录)。

I had this same error and couldn't figure it out. Finally, I realized that I had null values coming through in the description/item field. I'd check for null/empty strings coming through as that might be the issue (Assuming you have already removed duplicate records for one transaction).

这篇关于在关联式规则R数据格式错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆