from sklearn.neighbors import NearestNeighbors
import numpy as np
X = np.array([[-1,-1],[-2, -1],[1,1],[2,1],[3,2]])
nbrs = NearestNeighbors(n_neighbors=2, algorithm='ball_tree').fit(X)
distance, indices = nbrs.kneighbors(X)
indices

distance

"""
Explanation: K-Nest-Neighbors 
1 Unsupervised Neast Neighbors
It acts as a uniform unterface to three different nestest neighbors algorithms: BallTree, KDTree, and burte-force algorithm based on routines in sklearn.metrics.pariwise
End of explanation
"""


from sklearn.neighbors import KDTree
import numpy as np
X = np.array([[-1,-1],[-2, -1],[1,1],[2,1],[3,2]])
kdt=KDTree(X, leaf_size=30, metric='euclidean')
kdt.query(X, k=2, return_distance=False)

"""
Explanation: We can also use the KDTree and BallTree classes directly to find the nearest neighbors, alternatively.
End of explanation
"""


