【问题标题】:Find all pairs of frequent itemsets that differ only in the last item查找仅在最后一项不同的所有频繁项集对
【发布时间】:2012-08-30 22:19:59
【问题描述】:

我正在尝试实现先验算法,但在编写生成候选项集的方法时遇到了麻烦。这是此功能的屏幕截图。

主要问题是第 2-5 行。我不知道如何获得 f1 和 f2。 f1 和 f2 是最后一项不同的数组,f1 的最后一项小于 f2 的最后一项。

有人知道如何用 Ruby 编写这个吗?

【问题讨论】:

    标签: ruby algorithm apriori


    【解决方案1】:
    f1 = [1,2,3]
    f2 = [1,2,4]
    z = [f1,f2].transpose
    
    if(((z[0...(z.size-1)].collect {|el| el[0] == el[1]}.uniq == [true])) & (z[z.size-1][0] < z[z.size-1][1])) do
    
    # f1 = f2 , except the last element, where the last f1 element is smaller than the last f2 element
    
    end
    

    【讨论】:

      猜你喜欢
      • 2016-01-26
      • 1970-01-01
      • 1970-01-01
      • 2014-03-22
      • 2018-04-22
      • 2014-11-25
      • 2018-11-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多