库和相应的文档如下——是的,我阅读了所有内容并能够在我自己的代码上“运行”。
http://scikit-learn.org/stable/modules/generated/sklearn.neighbors.LSHForest.html
但结果对我来说真的没有意义,所以我浏览了这个例子(也包含在上一个网页中)
>>> from sklearn.neighbors import LSHForest
>>> X_train = [[5, 5, 2], [21, 5, 5], [1, 1, 1], [8, 9, 1], [6, 10, 2]]
>>> X_test = [[9, 1, 6], [3, 1, 10], [7, 10, 3]]
>>> lshf = LSHForest()
>>> lshf.fit(X_train)
LSHForest(min_hash_match=4, n_candidates=50, n_estimators=10,
n_neighbors=5, radius=1.0, radius_cutoff_ratio=0.9,
random_state=None)
>>> distances, indices = lshf.kneighbors(X_test, n_neighbors=2)
>>> distances
array([[ 0.069..., 0.149...],
[ 0.229..., 0.481...],
[ 0.004..., 0.014...]])
>>> indices
array([[1, 2],
[2, 0],
[4, 0]])
所以我只是尝试通过找到三个测试集 [9, 1, 6], [3, 1, 10], [7, 10, 3] 的最近邻居来验证示例
假设搜索 [9,1,6] 的最近邻居(通过使用欧几里德距离),最近的训练点是 [5, 5, 2] 和 [6, 10, 2] (我认为索引将 [0.4]) ——这与结果显着不同 [1,2]
通过简单的数学计算,距离也完全脱离了主题,附上我的 excel 表
再次感谢您的时间和帮助