【问题标题】:Use R apriori for numeric/continuous attributes对数字/连续属性使用 R apriori
【发布时间】:2016-11-27 19:36:20
【问题描述】:

我正在尝试将 R 中的 Apriori 用于数字属性。我离散化了属性

mat1 = discretize(table[1:699,1:1])
mat1 = cbind(mat1, discretize(table[1:699,2:2]))
rules <- apriori(mat1, parameter = list(supp = 0.5, conf = 0.9, target = "rules"))

但先验将所有非零值视为 1。

Apriori

Parameter specification:
 confidence minval smax arem  aval originalSupport support minlen maxlen target   ext
        0.9    0.1    1 none FALSE            TRUE     0.5      1     10  rules FALSE

Algorithmic control:
 filter tree heap memopt load sort verbose
    0.1 TRUE TRUE  FALSE TRUE    2    TRUE

Absolute minimum support count: 349 

set item appearances ...[0 item(s)] done [0.00s].
set transactions ...[2 item(s), 699 transaction(s)] done [0.00s].
sorting and recoding items ... [2 item(s)] done [0.00s].
creating transaction tree ... done [0.00s].
checking subsets of size 1 2 done [0.00s].
writing ... [4 rule(s)] done [0.00s].
creating S4 object  ... done [0.00s].
Warning message:
In asMethod(object) :
  matrix contains values other than 0 and 1! Setting all entries != 0 to 1.

由于先验将输入作为二进制值,如何对连续数值属性应用关联规则挖掘?

【问题讨论】:

  • 你能解释一下连续情况下的关联规则是什么样的吗?
  • Something like 1, 2, 3, 7 => 9 根据这个规则,如果输入参数 1,2,3,7 具有相同的值,则第 9 个输入参数也应该具有相同的值.因此,我们可以说第九个输入值取决于其他输入
  • mat1 长什么样子?
  • mat1 的数值为 1,2,3 等
  • 那你可能还需要转成二进制数据!

标签: r machine-learning data-mining apriori


【解决方案1】:

我不会使用 discretize(),我会将 apriori() 函数应用于包含您的数据作为因子的数据帧,您可以这样定义:

mat1 <- data.frame(
  X1 = as.character(table[1:699,1:1])
  ,X2 = as.character(table[1:699,2:2])
  ,stringsAsFactors = TRUE); #also by default

【讨论】:

    猜你喜欢
    • 2017-09-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-29
    • 2016-11-11
    • 1970-01-01
    相关资源
    最近更新 更多