【发布时间】:2010-07-16 16:51:28
【问题描述】:
感谢那些回答了我之前的问题并让我走到这一步的人。
我有一个包含大约 25,000 个向量的表,每个向量有 48 个维度,值范围为 0-255。
我正在尝试开发一种局部敏感哈希 (http://en.wikipedia.org/wiki/Locality-sensitive_hashing) 算法来查找近邻或最近邻点。
我现在的 LSH 函数是这样的:
def lsh(vector, r = 1.0, a = None, b = None):
if not a:
a = [normalvariate(10, 4) for i in range(48)]
if not b:
b = uniform(0, r)
hashVal = floor((sum([a[i]*vector[i] for i in range(48)]) + b)/r)
return int(hashVal)
此时我的问题是:
答:我的代码的“normalvariate(10, 4)”部分是否有最佳值。这是内置在 random.normalvariate (http://docs.python.org/library/random.html#random.normalvariate) 函数中的 python,我使用它来生成“d 维向量,其条目独立于稳定分布选择”。根据我的实验,这些值似乎并不重要。
B:在维基百科文章的顶部,它指出:
如果 d(p,q)
如果 d(p,q) >= cR,则 h(p) = h(q) 的概率最大为 P2
这里提到的 R 值也是“稳定分布”部分中提到的 R 值吗? (http://en.wikipedia.org/wiki/Locality-sensitive_hashing#Stable_distributions)
C:与我之前的问题(B)有关。我发现在我的 hasing 函数中使用更高的 R 值将我的向量映射到更小的散列值范围。有没有办法优化我的 R 值。
D:一个人大约可以使用多少张桌子?
【问题讨论】: