象夫推荐者

发布于 2024-12-17 23:46:58 字数 427 浏览 1 评论 0原文

Apache Mahout 推荐文档 提到以下内容:

// Construct the list of pre-computed correlations
Collection <GenericItemSimilarity.ItemItemSimilarity>  correlations = ...;

我不确定实际情况如何施工是在上面的线路中完成的。有人可以举个例子吗?

ItemSimilarity itemSimilarity  =  new GenericItemSimilarity(correlations);

The Apache Mahout Recommender Documentation mentions the following:

// Construct the list of pre-computed correlations
Collection <GenericItemSimilarity.ItemItemSimilarity>  correlations = ...;

I'm not sure how the actual construction is done in the above line. Can someone provide an example?

ItemSimilarity itemSimilarity  =  new GenericItemSimilarity(correlations);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

街道布景 2024-12-24 23:46:59

此示例指的是您已经通过 Hadoop 作业计算出相似性并将其存储在文件系统或数据库中的情况。正如构造函数文档所述:

一个“通用”{@link ItemSimilarity},它采用预先计算的项目相似性的静态列表,并仅以此为基础进行响应。这些值可能已由另一个进程预先离线计算,存储在文件中,然后读取并输入到此类的实例中。

如果您有数千万或更少的推荐,您可以简单地计算飞行并使用其他 GenericItemSimilarity 构造函数 - GenericItemSimilarity(ItemSimilarity otherSimilarity, DataModel dataModel)

例如:

DataModel dataModel = new FileDataModel(new File("path://to/file.csv"));
ItemSimilarity itemSimilarity = new LogLikelihoodSimilarity(dataModel);
ItemSimilarity itemSimilarity = new GenericItemSimilarity(itemSimilarity, dataModel);

This example refers to the case where you have the similarities already computed, by the Hadoop job for example, and stored on the filesystem or database . As the constructor documentation reads:

A "generic" {@link ItemSimilarity} which takes a static list of precomputed item similarities and bases its responses on that alone. The values may have been precomputed offline by another process, stored in a file, and then read and fed into an instance of this class.

If you have tens of millions of recommendations or less, you can simply compute similarities on the fly and use the other GenericItemSimilarity constructor - GenericItemSimilarity(ItemSimilarity otherSimilarity, DataModel dataModel)

For example:

DataModel dataModel = new FileDataModel(new File("path://to/file.csv"));
ItemSimilarity itemSimilarity = new LogLikelihoodSimilarity(dataModel);
ItemSimilarity itemSimilarity = new GenericItemSimilarity(itemSimilarity, dataModel);
冰葑 2024-12-24 23:46:59

这里没有什么魔力,它只是建议您创建一堆 ItemItemSimilarity 对象,每个对象对应您所了解的每个项目之间的相似性。

Collection<GenericItemSimilarity.ItemItemSimilarity> correlations = 
  new ArrayList<GenericItemSimilarity.ItemItemSimilarity>();
correlations.add(new GenericItemSimilarity.ItemItemSimilarity(1, 2, 0.5));
...

您可以采用这种方式或任何您想要的其他方式。

There's no magic here, it's just suggesting you create a bunch of those ItemItemSimilarity objects, one for each item-item similarity that you know about.

Collection<GenericItemSimilarity.ItemItemSimilarity> correlations = 
  new ArrayList<GenericItemSimilarity.ItemItemSimilarity>();
correlations.add(new GenericItemSimilarity.ItemItemSimilarity(1, 2, 0.5));
...

You can make it this way or any other way you want.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文