【问题标题】:R : Subscript out of Bond using aruleR : 使用 arule 从 Bond 中下标
【发布时间】:2018-04-30 21:01:22
【问题描述】:

我正在使用 arules 包,正在寻找规则我遇到了这个问题:

注意:txn 是我的交易矩阵

你可以在这里下载我的 CSV

My CVS File

将 csv 文件转换为购物篮格式

library(arules)

txn = read.transactions(file="ItemList.csv", rm.duplicates= FALSE, format="basket",sep=",",cols=1);

从交易中删除报价

txn@itemInfo$labels <- gsub("\"","",txn@itemInfo$labels)

rules <- apriori(txn,
                 parameter = list(support=.001,
                                  confidence=.5,
                                  minlen=2,
                                  target='rules' # to mine for rules
                 ))
>summary(rules)

... etc

> inspect(sort(rules, by='lift', decreasing = T)[1:5])
Error in slot(x, s)[i] : subscript out of bounds

最后,我的错误是

slot(x, s)[i] 中的错误:下标超出范围

我在网上看到我的问题不应该来自“错误代码”,而是来自 R 设置。 谢谢大家的帮助!

【问题讨论】:

  • 一般来说,如果出现奇怪的错误,首先要做的是options(error = recover) 并使用调试器。见?recover
  • 另外,请使用dput 创建minimal reproducible example。然后人们可以通过运行您的代码来调试它来帮助您。谢谢,欢迎来到 SO!
  • 好的,我会按照你的建议去做

标签: r bounds arules


【解决方案1】:

刚刚解决。在规则中设置 Support=0.00001 使一切正常

rules <- apriori(txn,
                 parameter = list(support=.00001,
                                  confidence=.5,
                                  minlen=2,
                                  target='rules' # to mine for rules
                 ))

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-08
    • 2017-01-22
    • 1970-01-01
    • 1970-01-01
    • 2019-02-20
    相关资源
    最近更新 更多