我们经常看到“相关项目”。例如,在博客中我们有相关的帖子,在书籍中我们有相关的书籍等。我的问题是我们如何编译这些相关性?如果只是标签,我经常看到没有相同标签的相关项目。例如,当搜索“粉色”时,相关商品可能带有“紫色”标签。
有人知道吗?
最佳答案
有很多方法可以计算两个项目的相似度,但要获得一种简单的方法,请查看 Jaccard 系数。
http://en.wikipedia.org/wiki/Jaccard_index
即:J(a,b) = intersection(a,b)/union(a,b)
So lets say you want to compute the coefficient of two items:
Item A, which has the tags "books, school, pencil, textbook, reading"
Item B, which has the tags "books, reading, autobiography"
intersection(A,B) = books, reading
union(A,B) = books, school, pencil, textbook, reading, autobiography
so J(a,b) = 2/6 = .333
So the most related item to A would be the item which results in the highest Jaccard Coefficient when paired with A.
关于php - 如何在 PHP 中查找 "related items",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2153062/