使用 hadoop/pig 从日志中提取相似用户
作为我们的初创产品的一部分,我们需要计算“相似的用户特征”。我们决定选择猪。 我已经学习pig几天了并且了解它是如何工作的。 首先我们来看看日志文件的样子。
user url time
user1 http://someurl.com 1235416
user1 http://anotherlik.com 1255330
user2 http://someurl.com 1705012
user3 http://something.com 1705042
user3 http://someurl.com 1705042
由于用户和 url 的数量可能很大,我们不能在这里使用暴力方法,因此首先我们需要找到至少有权访问公共 url 的用户。
该算法可以拆分如下:
- 查找访问过某些常见 URL 的所有用户。
- 为访问的每个资源生成所有用户的成对组合。
- 对于每对 和 和 url,计算这些用户的相似度:相似度取决于访问之间的时间间隔(因此我们需要跟踪时间)。
- 总结每对 url 的相似度。
这是我到目前为止所写的内容:
A = LOAD 'logs.txt' USING PigStorage('\t') AS (uid:bytearray, url:bytearray, time:long);
grouped_pos = GROUP A BY ($1);
我知道还不是很多,但现在我不知道如何生成该对或进一步移动。 因此,任何帮助将不胜感激。
谢谢。
We need as part of our start-up product to compute "similar user feature". And we've decided to go with pig for it.
I've been learning pig for a few days now and understand how it work.
So to start here is how the log file look like.
user url time
user1 http://someurl.com 1235416
user1 http://anotherlik.com 1255330
user2 http://someurl.com 1705012
user3 http://something.com 1705042
user3 http://someurl.com 1705042
As the number of users and url can be huge, we can't use a bruteforce approach here, so first we need to find the user's that have access at least to on common url.
The algorithm could be splited as bellow:
- Find all users that has accessed to some common urls.
- generate pair-wise combination of all users for each resource accessed.
- for each pair and and url, compute the similarity of those users: the similarity depend of the timeinterval between the access (so we need to keep track of the time).
- sum up for each pair-url the similarity.
here is what i've written so far:
A = LOAD 'logs.txt' USING PigStorage('\t') AS (uid:bytearray, url:bytearray, time:long);
grouped_pos = GROUP A BY ($1);
I know it is not much yet, but now i don't know how to generate the pair or move further.
So any help would be appreciated.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
IBM 有一篇很好、详细的论文,介绍了如何进行合作- 使用 MapReduce 进行聚类,可能对您有用。
Google 新闻个性化论文描述了一个相当简单的实施局部敏感哈希来解决同样的问题。
There's a nice, detailed paper from IBM on doing co-clustering with MapReduce that may be useful for you.
The Google News Personalization paper describes a fairly straightforward implementation of Locality Sensitive Hashing for solving the same problem.
对于算法,请查看有关查询/URL 二分图的论文。这里有几个链接:
使用点击时间的查询建议
作者:Qiaozhu Mei、Dengyong Zhou、Kenneth Church
http://www-personal.umich.edu/~qmei/pub /cikm08-sugg.ppt
点击图上的随机游走
尼克·克拉斯韦尔和马丁·苏默
2007年7月
http://research.microsoft.com/apps/pubs/default.aspx ?id=65235
For algorithms, look at papers on query/URL bipartite graphs. Here are a couple of links:
Query suggestion using hitting time
by Qiaozhu Mei, Dengyong Zhou, Kenneth Church
http://www-personal.umich.edu/~qmei/pub/cikm08-sugg.ppt
Random walks on the click graph
Nick Craswell and Martin Szummer
July 2007
http://research.microsoft.com/apps/pubs/default.aspx?id=65235