在64位Python 2.7.6中,这是真的,但在32位Python 2.7.3中,它是错误的:
random.Random(hash("a")).random() == random.Random("a").random()
Run Code Online (Sandbox Code Playgroud)
那么Python 2.7.3哈希字符串如何用于种子随机数生成器呢?
我正在尝试为scikit-learn DBSCAN实现指定自定义群集功能:
def geodistance(latLngA, latLngB):
print latLngA, latLngB
return vincenty(latLngA, latLngB).miles
cluster_labels = DBSCAN(
eps=500,
min_samples=max(2, len(found_geopoints)/10),
metric=geodistance
).fit(np.array(found_geopoints)).labels_
Run Code Online (Sandbox Code Playgroud)
但是,当我打印出距离函数的参数时,它们完全不是我所期望的:
[ 0.53084126 0.19584111 0.99640966 0.88013373 0.33753788 0.79983037
0.71716144 0.85832664 0.63559538 0.23032912]
[ 0.53084126 0.19584111 0.99640966 0.88013373 0.33753788 0.79983037
0.71716144 0.85832664 0.63559538 0.23032912]
Run Code Online (Sandbox Code Playgroud)
这就是我的found_geopoints数组的样子:
[[ 4.24680600e+01 1.40868060e+02]
[ -2.97677600e+01 -6.20477000e+01]
[ 3.97550400e+01 2.90069000e+00]
[ 4.21144200e+01 1.43442500e+01]
[ 8.56111000e+00 1.24771390e+02]
...
Run Code Online (Sandbox Code Playgroud)
那么为什么不是距离函数纬度经度对的参数呢?
我正在寻找包含 bopomofo 和/或拼音中所有汉字普通话发音的数据集。另外,我需要可以将其复制到我自己的代码库中的开源数据集。