【问题标题】:why the result of method mostSimilarItems in mahout is not order by the weight?为什么 mahout 中 mostSimilarItems 方法的结果不是按重量排序?
【发布时间】:2014-05-23 03:34:40
【问题描述】:

我有以下代码:

ItemSimilarity itemSimilarity = new UncenteredCosineSimilarity(dataModel); 
recommender = new GenericItemBasedRecommender(dataModel,itemSimilarity);
List<RecommendedItem> items = recommender.mostSimilarItems(10, 5);

我的数据模型是这样的: uid itemid socre

userid itemid score
  1    6    5
  1   10    3
  1   11    5
  1   12    4
  1   13    5
  2   2     3
  2   6     5
  2   10    3
  2   12    5

当我运行上面的代码时,结果是这样的: 13 6 11 2 12 我调试了代码,发现 List items = Recommendationer.mostSimilarItems(10, 5); 返回相同分数的项目,即为一! 所以,我有一个问题。在我看来,我认为最相似的item应该考虑item co-occurrence matrix:

    2   6   10  11  12  13

2   0   1   1   0   1   0

6   1   0   2   1   2   1

10  1   2   0   1   2   1

11  0   1   1   0   1   1

12  1   2   2   1   0   1

13  0   1   1   1   1   0

在上面的矩阵中,第12项最相似的应该是[6,12,11,13,2],因为第1项和第12项比其他项更相似,不是吗? 现在,谁能帮我解释一下?谢谢!

【问题讨论】:

    标签: machine-learning mahout recommendation-engine collaborative-filtering mahout-recommender


    【解决方案1】:

    在您的矩阵中,您的数据比输入中的数据多得多。特别是您似乎在输入数据中没有的 0 值。这就是为什么您可能会得到与您预期不同的答案。

    【讨论】:

    • 非常感谢您的回复,很抱歉我的描述不好,请再看一遍新的问题,矩阵是指共现矩阵,即常见项出现次数,请看到新的描述,我还是不明白结果[13 6 11 2 12],在我看来,我认为它应该被排序为[[6,12,11,13,2]],因为第1项而且第 12 项比其他项更相似,不是吗?
    【解决方案2】:

    Mahout 期望您的 ID 是从 0 开始的连续整数。您的行 ID 和列 ID 也是如此。您的矩阵看起来缺少 id。仅拥有整数是不够的。

    这可能是问题吗?不确定 Mahout 会对上面的输入做什么。

    我总是保留一本字典来将 Mahout ID 映射到我自己的 ID。

    【讨论】:

    • 感谢您的回复,但我认为这不是真正的原因,也许函数 mostSimilarItems() 没有考虑分数?如果可以的话,你可以有上面的demo试试.
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-22
    • 2010-10-11
    • 1970-01-01
    • 1970-01-01
    • 2013-10-27
    • 2021-08-17
    相关资源
    最近更新 更多