php - 如何在 PHP 中查找 "related items"

标签 php sql taxonomy

我们经常看到“相关项目”。例如,在博客中我们有相关的帖子,在书籍中我们有相关的书籍等。我的问题是我们如何编译这些相关性?如果只是标签,我经常看到没有相同标签的相关项目。例如,当搜索“粉色”时,相关商品可能带有“紫色”标签。

有人知道吗?

最佳答案

有很多方法可以计算两个项目的相似度,但要获得一种简单的方法,请查看 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/

相关文章:

php - 在分类页面上显示标签

typescript - 获取或阅读数据分类术语库 Sharepoint

php - 如何更改两个单词之间的文本?

php - 使用 PHP 显示来自 mySQL 表的图像/描述

sql - 在 T-SQL/SQL SERVER 中排序(或使用 ORDER BY 子句)而不考虑某些单词

sharepoint - 如何将术语添加到 TermCollection(分类字段)

javascript - 如何根据购物者在自定义字段中输入的字符数动态更改产品价格?

php - 从 Android 上传图像到服务器不起作用

php - SQL 语法错误/无效查询 - WAMP、phpMyAdmin

java - 带sql注释的PreparedStatement