def go_nn_kdtree(eps=0, parallel=True):
"""
Using a specialized data structure, the KDTree
This is not as performant because we're in a high dimensional space
0.777 accuracy? Should be 0.794
"""
n_jobs = 1
if parallel:
n_jobs = -1
neighbors = tree.query(Xtest, eps=eps, n_jobs=n_jobs)
predictions = ytrain[neighbors[1]]
acc = np.equal(predictions, ytest).mean()
return acc
评论列表
文章目录