I used to find nearest neighbours in data array X with sklearn.neighbors.NearestNeighbors like this:
from sklearn.neighbors import NearestNeighbors
import numpy as np
nn = NearestNeighbors(n_neighbors=2).fit(X)
distances, indices = nn.nkneighbors(X)
In this case, I could get two closest neighbours in X to each row in the same X, that's straightforward. However, I'm confused about applying fitted nn.nkneighbors(X) to another array Y:
distances, indices = nn.nkneighbors(Y)
This gives 2 neighbours to each row in Y, but how to interpret this? Are the found neighbours from X or Y?
And how to interpret kneighbors([X, n_neighbors, return_distance]) in Sklearn's documentation page, what is n_neighbors here?
