sklearn.neighbors.NearestNeighbors - knn for unsupervised learning?
The unsupervised version simply implements different algorithms to find the nearest neighbor(s) for each sample. 

The kNN algorithm consists of two steps:


Compute and store the k nearest neighbors for each sample in the training set ("training") 
For an unlabeled sample, retrieve the k nearest neighbors from dataset and predict label through majority vote / interpolation (or similar) among k nearest neighbors ("prediction/querying")


The unsupervised version is basically only step 1, the training phase of the kNN algorithm. 

(This is useful because if your dataset is large, a pairwise comparison for all samples (algorithm='brute') is often infeasible. Therefore two alternative algorithms for the training stage are implemented that make use of previous comparisons to reduce the number of distance calculations. See the documentation here.)