scikit-learn-contrib / sklearn-ann

Integration with (approximate) nearest neighbors libraries for scikit-learn + clustering based on with kNN-graphs.
https://sklearn-ann.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
14 stars 4 forks source link

[Feature Request] Add `kneighbors_graph` method to all transformers supporting mode={"connectivity", "distance"} and include_self={True,False} #41

Open jolespin opened 4 months ago

jolespin commented 4 months ago

I'm trying to adapt some methods that use kneighbors_graph from scikit-learn but I need access to the mode=connectivity and include_self=True which are not supported in the current fit methods. Here's some more details on the problem: https://stackoverflow.com/questions/78486997/how-to-reproduce-kneighbors-graphinclude-self-true-using-kneighborstransfor . My goal is to speed up some DiffusionMap algorithms that use KNN methods but I need the connectivity and include_self options.

Here's the docs: https://scikit-learn.org/stable/modules/generated/sklearn.neighbors.kneighbors_graph.html#sklearn.neighbors.kneighbors_graph

mode{‘connectivity’, ‘distance’}, default=’connectivity’ Type of returned matrix: ‘connectivity’ will return the connectivity matrix with ones and zeros, and ‘distance’ will return the distances between neighbors according to the given metric.

include_selfbool or ‘auto’, default=False Whether or not to mark each sample as the first nearest neighbor to itself. If ‘auto’, then True is used for mode=’connectivity’ and False for mode=’distance’.