在 Stanford Information Retreival book ,我试图弄清楚如何将查询转换为单位向量。考虑查询 q = 嫉妒的八卦。该查询转化为图 6.12 和 6.13 三个坐标上的单位向量 ⃗v(q) = (0, 0.707, 0.707)。 (0, 0.707, 0.707) 是如何实现的?
最佳答案
这是一个标准的向量归一化。向量被称为 normalized如果它与 0 [(0,0,0)
在你的情况下]的距离恰好是 1,正如你所看到的,这就是这个向量中的情况(直到舍入差异)。
标准化是通过以下方式完成的:
Let the vector be x = (x_1,x_2,...,x_n)
let s = x_1^2 + x_2^2 + ... + x_n^2 [sum of squares]
let the normalized vector n = x/sqrt(s) = (x_1/sqrt(s), x_2/sqrt(s), ..., x_n/sqrt(s))
在您的示例中,查询“jealous gossip”会生成非正态化向量 (0,1,1)
(因为字典包含 3 个单词affect、jealous、gossip)。通过调用上述算法,您将得到 s=2
,因此归一化向量为 n=(0/sqrt(2), 1/sqrt(2), 1/sqrt(2) ) ~= (0,0.707,0.707)
关于algorithm - 如何使用术语频率和归一化将本示例中的查询转换为单位向量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26986323/