SKLEARN NEAREST NEIGHBOR & KNeighborsClassifier
ALGORITHM-1NN
from sklearn.neighbors import NearestNeighbors
import numpy as np
X = np.array([[-1, -1], [1, 1], [-3, -2], [1, 1], [2, 1], [3, 2]])
nbrs = NearestNeighbors(n_neighbors=2, algorithm='ball_tree').fit(X)
distances, indices = nbrs.kneighbors(X)
原创
2020-12-10 11:29:58 ·
204 阅读 ·
0 评论